Android Deploy Prod #27
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: Android Deploy Prod | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy_prod: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - run: | | |
| echo "${{ secrets.KEYSTORE }}" > keystore.jks.asc | |
| gpg -d --passphrase "${{ secrets.KEYSTORE_PASSPHRASE }}" --batch keystore.jks.asc > keystore.jks | |
| - name: Update Version | |
| run: bash ./.github/scripts/update_versions.sh | |
| - name: Read version from toml | |
| id: version | |
| run: | | |
| VERSION_NAME=$(awk -F '"' '/versionName = "/{print $2}' gradle/libs.versions.toml) | |
| VERSION_CODE=$(awk -F '"' '/versionCode = "/{print $2}' gradle/libs.versions.toml) | |
| echo "name=$VERSION_NAME" >> "$GITHUB_OUTPUT" | |
| echo "code=$VERSION_CODE" >> "$GITHUB_OUTPUT" | |
| - name: Get previous release tag | |
| id: prev_tag | |
| run: | | |
| PREV_TAG=$(git describe --tags --abbrev=0 --match="release-*" 2>/dev/null || echo "") | |
| if [ -z "$PREV_TAG" ]; then | |
| # If no previous release tag, use first commit | |
| PREV_TAG=$(git rev-list --max-parents=0 HEAD) | |
| fi | |
| echo "tag=$PREV_TAG" >> "$GITHUB_OUTPUT" | |
| echo "Previous tag: $PREV_TAG" | |
| - name: Generate changelogs | |
| env: | |
| VERSION_CODE: ${{ steps.version.outputs.code }} | |
| run: | | |
| FROM_TAG="${{ steps.prev_tag.outputs.tag }}" | |
| TO_TAG="${{ github.sha }}" | |
| # Generate Play Store changelog | |
| bash ./.github/scripts/generate_changelog.sh "$FROM_TAG" "$TO_TAG" play "$VERSION_CODE" | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3' | |
| - name: Cache Ruby - Bundler | |
| uses: actions/cache@v4 | |
| with: | |
| path: vendor/bundle | |
| key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gems- | |
| - name: set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Grant Permission to Execute | |
| run: chmod +x gradlew | |
| - name: Use CI-optimized Gradle properties | |
| run: cp .github/properties/gradle-ci.properties gradle.properties | |
| - name: Use CI-optimized Convention Gradle properties | |
| run: cp .github/properties/gradle-convention-ci.properties build-logic/gradle.properties | |
| - name: Install bundle | |
| run: | | |
| bundle config path vendor/bundle | |
| bundle install --jobs 4 --retry 3 | |
| - name: Configure Keystore | |
| env: | |
| KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }} | |
| KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }} | |
| KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }} | |
| run: | | |
| echo "storeFile=keystore.jks" >> keystore.properties | |
| echo "keyAlias=$KEYSTORE_KEY_ALIAS" >> keystore.properties | |
| echo "storePassword=$KEYSTORE_STORE_PASSWORD" >> keystore.properties | |
| echo "keyPassword=$KEYSTORE_KEY_PASSWORD" >> keystore.properties | |
| - name: Create Google Play Config file | |
| env: | |
| PLAY_CONFIG_JSON: ${{ secrets.PLAY_CONFIG_JSON }} | |
| run: | | |
| echo "$PLAY_CONFIG_JSON" > play_config.json.b64 | |
| base64 -d -i play_config.json.b64 > play_config.json | |
| - name: Create Google Services Config file | |
| env: | |
| GOOGLE_SERVICES_JSON_STORE: ${{ secrets.GOOGLE_SERVICES_JSON_STORE }} | |
| run: | | |
| echo "$GOOGLE_SERVICES_JSON_STORE" > app/store/google-services.json.b64 | |
| base64 -d -i app/store/google-services.json.b64 > app/store/google-services.json | |
| - name: Distribute app to Prod track 🚀 | |
| run: bundle exec fastlane deploy | |
| - name: Commit files | |
| run: | | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add . | |
| git commit -a -m "release: v${{ steps.version.outputs.name }} (code ${{ steps.version.outputs.code }})" || echo "No changes to commit" | |
| # Create an annotated tag for this release | |
| TAG_NAME="release-v${{ steps.version.outputs.name }}" | |
| # Avoid failure if tag already exists in repo history | |
| if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then | |
| echo "Tag $TAG_NAME already exists; skipping create" | |
| else | |
| git tag -a "$TAG_NAME" -m "Release $TAG_NAME" | |
| fi | |
| - name: Push changes | |
| uses: ad-m/github-push-action@master | |
| with: | |
| github_token: ${{ secrets.PUSH_TOKEN }} | |
| branch: ${{ github.ref }} | |
| tags: true |