Create macOS binary #62
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
| # Checks BiaPy code consistency | |
| name: Create macOS binary | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| jobs: | |
| run: | |
| runs-on: macos-14 | |
| # runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| cache: "pip" # caching pip dependencies | |
| - name: Installing BiaPy-GUI dependencies | |
| run: pip install -r requirements.txt | |
| - name: Creating macOS binary | |
| run: | | |
| cp dist-macOS/main.spec main.spec | |
| pyinstaller main.spec | |
| - name: Check dist folder contents | |
| run: | | |
| echo "== dist tree ==" | |
| ls -R dist || true | |
| # Zip the .app bundle | |
| - name: Create macOS zip (preserve bundle attrs) | |
| run: | | |
| test -d "dist/BiaPy.app" || { echo "dist/BiaPy.app not found"; exit 1; } | |
| # eg: BiaPy-GUI-<tag>-macOS.zip | |
| NAME="BiaPy-GUI-${{ github.ref_name }}-macOS.zip" | |
| ditto -c -k --sequesterRsrc --keepParent "dist/BiaPy.app" "dist/${NAME}" | |
| ls -lh "dist/${NAME}" | |
| # Install Google client libs, decode creds, and upload the ZIP | |
| - name: Upload ZIP to Google Drive | |
| env: | |
| FOLDER_ID: ${{ secrets.FOLDER_FOR_NEW_BINARIES }} | |
| run: | | |
| python -m pip install --quiet google-api-python-client google-auth google-auth-httplib2 google-auth-oauthlib | |
| echo "${{ secrets.DRIVE_CREDENTIALS }}" | base64 -d > sa.json | |
| python - <<'PY' | |
| import os | |
| from google.oauth2.service_account import Credentials | |
| from googleapiclient.discovery import build | |
| from googleapiclient.http import MediaFileUpload | |
| FOLDER_ID = os.environ["FOLDER_ID"] | |
| # Match the NAME used above | |
| ZIP_PATH = os.path.join("dist", f"BiaPy-GUI-{os.environ.get('GITHUB_REF_NAME','local')}-macOS.zip") | |
| if not os.path.exists(ZIP_PATH): | |
| # fallback: find the first .zip in dist | |
| zips = [p for p in os.listdir("dist") if p.endswith(".zip")] | |
| if not zips: | |
| raise SystemExit("No ZIP found to upload") | |
| ZIP_PATH = os.path.join("dist", zips[0]) | |
| creds = Credentials.from_service_account_file("sa.json", scopes=["https://www.googleapis.com/auth/drive"]) | |
| drive = build("drive","v3",credentials=creds, cache_discovery=False) | |
| media = MediaFileUpload(ZIP_PATH, mimetype="application/zip", resumable=True) | |
| body = {"name": os.path.basename(ZIP_PATH), "parents": [FOLDER_ID]} | |
| print(f"Uploading {ZIP_PATH} to folder {FOLDER_ID} ...") | |
| req = drive.files().create(body=body, media_body=media, fields="id,name") | |
| result = req.execute() | |
| print(f"✅ Uploaded {result['name']} (id: {result['id']})") | |
| PY |