-
Notifications
You must be signed in to change notification settings - Fork 10
Add Android release workflow #52
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
Merged
Merged
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,115 @@ | ||
| name: Android Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag_name: | ||
| description: Git tag and GitHub Release name, for example v2.0.0-pro.1 | ||
| required: true | ||
| type: string | ||
| version_name: | ||
| description: Android versionName | ||
| required: true | ||
| default: 2.0.0-PRO | ||
| type: string | ||
| version_code: | ||
| description: Android versionCode | ||
| required: true | ||
| default: "2" | ||
| type: string | ||
| prerelease: | ||
| description: Mark the GitHub Release as a prerelease | ||
| required: true | ||
| default: true | ||
| type: boolean | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Build Signed Release | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| java-version: "17" | ||
| distribution: temurin | ||
|
|
||
| - name: Cache Gradle packages | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: | | ||
| ~/.gradle/caches | ||
| ~/.gradle/wrapper | ||
| ~/.android/build-cache | ||
| key: gradle-android-${{ runner.os }}-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml') }} | ||
| restore-keys: | | ||
| gradle-android-${{ runner.os }}- | ||
|
|
||
| - name: Validate release secrets | ||
| env: | ||
| ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | ||
| ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | ||
| ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} | ||
| ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} | ||
| run: | | ||
| missing=0 | ||
| for name in ANDROID_KEYSTORE_BASE64 ANDROID_KEYSTORE_PASSWORD ANDROID_KEY_ALIAS ANDROID_KEY_PASSWORD; do | ||
| if [ -z "${!name}" ]; then | ||
| echo "::error::$name is required for Android release signing" | ||
| missing=1 | ||
| fi | ||
| done | ||
| exit "$missing" | ||
|
|
||
| - name: Decode signing keystore | ||
| env: | ||
| ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | ||
| run: | | ||
| printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$RUNNER_TEMP/release-keystore.jks" | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: Build release artifacts | ||
| env: | ||
| ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | ||
| ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} | ||
| ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} | ||
| run: | | ||
| ./gradlew lintDebug testDebugUnitTest assembleRelease bundleRelease \ | ||
| --no-daemon \ | ||
| --max-workers=1 \ | ||
| -Dorg.gradle.jvmargs=-Xmx768m \ | ||
| -PGDEI_RELEASE_STORE_FILE="$RUNNER_TEMP/release-keystore.jks" \ | ||
| -PGDEI_RELEASE_STORE_PASSWORD="$ANDROID_KEYSTORE_PASSWORD" \ | ||
| -PGDEI_RELEASE_KEY_ALIAS="$ANDROID_KEY_ALIAS" \ | ||
| -PGDEI_RELEASE_KEY_PASSWORD="$ANDROID_KEY_PASSWORD" \ | ||
| -PGDEI_VERSION_NAME="${{ inputs.version_name }}" \ | ||
| -PGDEI_VERSION_CODE="${{ inputs.version_code }}" | ||
|
|
||
| - name: Upload release artifacts | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: android-release-${{ inputs.tag_name }} | ||
| path: | | ||
| app/build/outputs/apk/release/*.apk | ||
| app/build/outputs/bundle/release/*.aab | ||
| if-no-files-found: error | ||
| retention-days: 30 | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ inputs.tag_name }} | ||
| name: ${{ inputs.tag_name }} | ||
| prerelease: ${{ inputs.prerelease }} | ||
| generate_release_notes: true | ||
| files: | | ||
| app/build/outputs/apk/release/*.apk | ||
| app/build/outputs/bundle/release/*.aab | ||
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
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
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.
Because these
workflow_dispatchinputs are interpolated directly into the shell script while the signing secrets are present in the environment, a dispatcher can supply a value containing a double quote and shell metacharacters (for example inversion_name) to break out of the quoted-P...argument and run arbitrary commands that can read the keystore passwords or use the write-scopedGITHUB_TOKEN. Put the inputs into stepenvvalues and reference those shell variables instead of embedding${{ inputs.* }}inrun.Useful? React with 👍 / 👎.