Build macOS #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build macOS | |
on: | |
workflow_dispatch: | |
jobs: | |
build-macos-14-arm: | |
strategy: | |
matrix: | |
architecture: [arm64] | |
runs-on: macos-14 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
pip install --timeout=300 -r requirements.txt | |
- name: Build with Nuitka | |
run: | | |
python3 -c "import sys; sys.path.append('./app/common'); import config; print(config.VERSION)" > version.txt | |
version=$(sed -n '4p' version.txt) | |
echo "VERSION=${version}" >> "$GITHUB_ENV" | |
rm -rf version.txt | |
python3 deploy.py | |
chmod +x "dist/Ghost-Downloader-3.app/Contents/MacOS/Ghost-Downloader-3" | |
rm -rf "dist/Ghost-Downloader-3.build" | |
rm -rf "dist/Ghost-Downloader-3.dist" | |
mv "dist/Ghost-Downloader-3.app" "dist/Ghost Downloader.app" | |
mv "resources/修复软件损坏" "dist/修复软件损坏" | |
- name: Create DMG | |
run: | | |
ln -s /Applications dist/Applications | |
attempt=0 | |
max_attempts=10 | |
while [ $attempt -lt $max_attempts ]; do | |
hdiutil create -srcfolder "dist/" -volname "Ghost-Downloader" -fs HFS+ \ | |
-fsargs "-c c=64,a=16,e=16" -format UDZO -size 400m \ | |
"Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg" && break | |
attempt=$((attempt + 1)) | |
echo "Attempt $attempt failed, retrying..." | |
sleep 1 # 等待 1 秒后重试 | |
done | |
if [ $attempt -eq $max_attempts ]; then | |
echo "Failed to create DMG after $max_attempts attempts" | |
fi | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }} | |
path: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg | |
build-macos-13-x86_64: | |
strategy: | |
matrix: | |
architecture: [x86_64] | |
runs-on: macos-13 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Remove problematic brew libs | |
run: | | |
brew remove --force --ignore-dependencies openssl@3 | |
brew cleanup openssl@3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
pip install --timeout=300 -r requirements.txt | |
- name: Build with Nuitka | |
run: | | |
python3 -c "import sys; sys.path.append('./app/common'); import config; print(config.VERSION)" > version.txt | |
version=$(sed -n '4p' version.txt) | |
echo "VERSION=${version}" >> "$GITHUB_ENV" | |
rm -rf version.txt | |
python3 deploy.py | |
chmod +x "dist/Ghost-Downloader-3.app/Contents/MacOS/Ghost-Downloader-3" | |
rm -rf "dist/Ghost-Downloader-3.build" | |
rm -rf "dist/Ghost-Downloader-3.dist" | |
mv "dist/Ghost-Downloader-3.app" "dist/Ghost Downloader.app" | |
mv "resources/修复软件损坏" "dist/修复软件损坏" | |
- name: Reinstall openssl libs | |
run: | | |
brew install openssl@3 | |
- name: Create DMG | |
run: | | |
ln -s /Applications dist/Applications | |
sleep 1 | |
hdiutil create -srcfolder "dist/" -volname "Ghost-Downloader-3" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDZO -size 400m "Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }} | |
path: Ghost-Downloader-v${{ env.VERSION }}-macOS-${{ matrix.architecture }}.dmg |