ci: enable nightly android builds for windows branch #10
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 and Publish GuGa (PyPI + Android) | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - windows | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-and-publish-pypi: | |
| name: Build and publish Python 🐍 distribution 📦 to PyPI | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Needed to push README back | |
| id-token: write # IMPORTANT: this is required for trusted publishing | |
| attestations: write # REQUIRED: Enables digital attestations (PEP 740) | |
| steps: | |
| - name: Checkout Source Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Sync README version | |
| if: github.event_name == 'release' | |
| run: | | |
| NEW_TAG="${{ github.event.release.tag_name }}" | |
| # Only replace v1.x.x patterns (safest for now) | |
| sed -i "s/v1\.[0-9]\.[0-9]*/$NEW_TAG/g" README.md || true | |
| sed -i "s/v1\.[0-9]\.[0-9]*/$NEW_TAG/g" server/README.md || true | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add README.md server/README.md | |
| git commit -m "chore: sync README versions to $NEW_TAG" || echo "No changes to commit" | |
| # Explicitly push to the latest branch to ensure documentation sync | |
| git push origin HEAD:latest | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Build generic package distributions | |
| run: | | |
| cd server | |
| python -m pip install build | |
| python -m build | |
| - name: Publish package distribution to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: server/dist/ | |
| build-and-upload-android: | |
| name: Build Android APK 📱 | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # IMPORTANT: Required to upload files to GitHub Releases! | |
| steps: | |
| - name: Checkout Source Code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Make gradlew executable | |
| run: chmod +x ./gradlew | |
| working-directory: app-stable | |
| - name: Build APK | |
| # We build assembleDebug here so it is natively signed with the default debug key | |
| # and ready for immediate sideloading without throwing Android "unsigned" errors! | |
| run: ./gradlew assembleDebug | |
| working-directory: app-stable | |
| - name: Rename APK | |
| run: mv app-stable/app/build/outputs/apk/debug/app-debug.apk app-stable/app/build/outputs/apk/debug/guga-stable.apk | |
| - name: Upload APK to GitHub Release | |
| # Upload if it's a release, a manual trigger, or a push to the windows branch | |
| if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/windows') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| # Use the release tag if it exists, otherwise default to 'nightly' | |
| tag_name: ${{ github.event_name == 'release' && github.event.release.tag_name || 'nightly' }} | |
| files: app-stable/app/build/outputs/apk/debug/guga-stable.apk | |
| prerelease: true | |
| generate_release_notes: true |