-
Notifications
You must be signed in to change notification settings - Fork 0
Enable Android APK build with Capacitor and add multi-platform CI/CD #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TechnologyStar
wants to merge
1
commit into
main
Choose a base branch
from
feat-android-apk-multi-platform-actions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| name: Multi-Platform Build & Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - '**' | ||
| tags: | ||
| - 'v*' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - master | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| # Windows Build | ||
| build-windows: | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| - name: Package Windows | ||
| run: npm run package:win | ||
|
|
||
| - name: Upload Windows Artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: windows-builds | ||
| path: | | ||
| release/*.exe | ||
| release/*.zip | ||
| retention-days: 7 | ||
|
|
||
| # macOS Build | ||
| build-macos: | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| - name: Package macOS | ||
| run: npm run package:mac | ||
|
|
||
| - name: Upload macOS Artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: macos-builds | ||
| path: | | ||
| release/*.dmg | ||
| release/*.zip | ||
| retention-days: 7 | ||
|
|
||
| # Linux Build | ||
| build-linux: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| - name: Package Linux | ||
| run: npm run package:linux | ||
|
|
||
| - name: Upload Linux Artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: linux-builds | ||
| path: release/*.AppImage | ||
| retention-days: 7 | ||
|
|
||
| # Android Build | ||
| build-android: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
|
|
||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'temurin' | ||
|
|
||
| - name: Setup Android SDK | ||
| uses: android-actions/setup-android@v3 | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build Android | ||
| run: npm run build:android | ||
|
|
||
| - name: Make gradlew executable | ||
| run: chmod +x android/gradlew | ||
|
|
||
| - name: Build APK (Debug) | ||
| run: | | ||
| cd android | ||
| ./gradlew assembleDebug | ||
|
|
||
| - name: Upload Android APK | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: android-builds | ||
| path: android/app/build/outputs/apk/debug/*.apk | ||
| retention-days: 7 | ||
|
|
||
| # Create Release (only on tags) | ||
| release: | ||
| needs: [build-windows, build-macos, build-linux, build-android] | ||
| runs-on: ubuntu-latest | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| steps: | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
|
|
||
| - name: Display structure of downloaded files | ||
| run: ls -R artifacts | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| files: | | ||
| artifacts/windows-builds/* | ||
| artifacts/macos-builds/* | ||
| artifacts/linux-builds/* | ||
| artifacts/android-builds/* | ||
| draft: false | ||
| prerelease: false | ||
| generate_release_notes: true | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # Create auto release on every push (non-tag) | ||
| auto-release: | ||
| needs: [build-windows, build-macos, build-linux, build-android] | ||
| runs-on: ubuntu-latest | ||
| if: "!startsWith(github.ref, 'refs/tags/')" | ||
| steps: | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
|
|
||
| - name: Create Auto Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| files: | | ||
| artifacts/windows-builds/* | ||
| artifacts/macos-builds/* | ||
| artifacts/linux-builds/* | ||
| artifacts/android-builds/* | ||
| tag_name: build-${{ github.ref_name }}-${{ github.run_number }} | ||
| name: Build ${{ github.ref_name }} #${{ github.run_number }} | ||
| body: | | ||
| 🤖 Automated build from commit ${{ github.sha }} | ||
|
|
||
| **Branch:** ${{ github.ref_name }} | ||
| **Platforms:** Windows, macOS, Linux, Android | ||
|
|
||
| 📦 **Downloads:** | ||
| - Windows: `.exe` installer and portable `.zip` | ||
| - macOS: `.dmg` installer and `.zip` archive | ||
| - Linux: `.AppImage` (universal package) | ||
| - Android: `.apk` (debug build) | ||
| draft: false | ||
| prerelease: true | ||
| target_commitish: ${{ github.sha }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
auto-releasejob is gated only byif: "!startsWith(github.ref, 'refs/tags/')", so it runs for pull_request events as well as pushes, yet the steps later in the job callsoftprops/action-gh-releasewithGITHUB_TOKEN. On pull_request workflows—especially those from forks—GitHub supplies a read-only token that cannot create releases, so this job will fail and block PR CI even though no release should be published. Restrict the job to push/tag events or skip it for pull_request to avoid PR build failures.Useful? React with 👍 / 👎.