Release Pocket (Android) #100
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: Release Pocket (Android) | |
| permissions: | |
| contents: write | |
| actions: read | |
| on: | |
| release: | |
| types: | |
| - prereleased | |
| workflow_dispatch: | |
| inputs: | |
| build_only: | |
| description: Build only (no upload to release) | |
| required: false | |
| default: false | |
| type: boolean | |
| tag: | |
| description: Specific tag for the release upload | |
| required: false | |
| type: string | |
| schedule: | |
| - cron: '0 1 * * *' | |
| jobs: | |
| build: | |
| name: Build Android APK | |
| runs-on: ubuntu-latest | |
| env: | |
| PRODUCT_NAME: 'AIRI' | |
| # Every current trigger path produces an installable APK artifact, so ship the analytics-enabled build consistently. | |
| VITE_ENABLE_POSTHOG: 'true' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: lts/* | |
| cache: pnpm | |
| - name: Install Android build tools | |
| run: | | |
| sdkmanager "build-tools;36.1.0" | |
| echo "${ANDROID_SDK_ROOT:-$ANDROID_HOME}/build-tools/36.1.0" >> "$GITHUB_PATH" | |
| - run: pnpm install --frozen-lockfile | |
| - run: pnpm run build:packages | |
| - name: Validate workflow dispatch release tag | |
| if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.tag == '' }} | |
| run: | | |
| echo "workflow_dispatch release uploads require the tag input" | |
| exit 1 | |
| - name: Build web assets | |
| run: pnpm -F @proj-airi/stage-pocket run build | |
| - name: Capacitor sync | |
| run: pnpm -F @proj-airi/stage-pocket exec cap sync android | |
| - name: Extract android keystore | |
| run: echo "${{ secrets.CAPACITOR_ANDROID_KEYSTORE_BASE64 }}" | base64 -d > ${{ github.workspace }}/apps/stage-pocket/airi-pocket.jks | |
| - name: Build APK | |
| working-directory: apps/stage-pocket/android | |
| run: pnpm -F @proj-airi/stage-pocket exec cap build android | |
| env: | |
| CAPACITOR_ANDROID_KEYSTORE_PATH: ${{ github.workspace }}/apps/stage-pocket/airi-pocket.jks | |
| CAPACITOR_ANDROID_KEYSTORE_ALIAS: ${{ secrets.CAPACITOR_ANDROID_KEYSTORE_ALIAS }} | |
| CAPACITOR_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.CAPACITOR_ANDROID_KEYSTORE_PASSWORD }} | |
| CAPACITOR_ANDROID_KEYSTORE_ALIAS_PASSWORD: ${{ secrets.CAPACITOR_ANDROID_KEYSTORE_ALIAS_PASSWORD }} | |
| - name: Rename APK for distribution | |
| env: | |
| RELEASE_TAG_NAME: ${{ github.event.release.tag_name || inputs.tag }} | |
| run: | | |
| VERSION="${RELEASE_TAG_NAME#v}" | |
| if [ -z "$VERSION" ]; then | |
| VERSION="$(sed -n 's/^AIRI_VERSION_NAME=//p' apps/stage-pocket/android/app-version.properties)" | |
| fi | |
| APK_NAME="${PRODUCT_NAME}-${VERSION}-android.apk" | |
| APK_SOURCE="apps/stage-pocket/android/app/build/outputs/apk/release/app-release-signed.apk" | |
| APK_BUNDLE_DIR="apps/stage-pocket/android/bundle" | |
| mkdir -p "$APK_BUNDLE_DIR" | |
| mv "$APK_SOURCE" "$APK_BUNDLE_DIR/$APK_NAME" | |
| echo "APK_NAME=$APK_NAME" >> "$GITHUB_ENV" | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.APK_NAME }} | |
| path: apps/stage-pocket/android/bundle/${{ env.APK_NAME }} | |
| if-no-files-found: error | |
| - name: Upload to GitHub Releases | |
| id: upload-github-release | |
| if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.build_only) }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: apps/stage-pocket/android/bundle/${{ env.APK_NAME }} | |
| append_body: true | |
| tag_name: ${{ github.event.release.tag_name || inputs.tag }} | |
| - name: Setup butler | |
| uses: remarkablegames/setup-butler@v2 | |
| # https://itch.io/docs/butler/pushing.html | |
| - name: Upload Android to itch.io | |
| if: ${{ github.event_name == 'release' }} | |
| run: butler push apps/stage-pocket/android/bundle/${{ env.APK_NAME }} nekomeowww/airi:android --userversion ${{ env.VERSION }} | |
| env: | |
| BUTLER_API_KEY: ${{ secrets.GAME_PUBLISHING_ITCHIO }} | |
| - name: Publish release assets to GitCode | |
| if: ${{ always() && github.repository == 'moeru-ai/airi' && steps.upload-github-release.outcome == 'success' && (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.build_only)) }} | |
| continue-on-error: true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }} | |
| GITCODE_OWNER: ${{ secrets.GITCODE_OWNER }} | |
| GITCODE_REPO: ${{ secrets.GITCODE_REPO }} | |
| GITCODE_RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }} | |
| run: bash .github/scripts/publish-gitcode-release.sh |