build: configure release pipeline and add flavor dimensions #9
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build-release-apk: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: 21 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Extract version info from tag | |
| id: extract-versions | |
| run: | | |
| set -e | |
| # Example: Extracting from a tag like v1.2.3(45) | |
| TAG_NAME=${GITHUB_REF#refs/tags/} # e.g., v1.2.3(45) | |
| VERSION_NAME=$(echo "$TAG_NAME" | sed -n 's/^v\([^(]*\).*$/\1/p') # Extracts 1.2.3 | |
| VERSION_CODE=$(echo "$TAG_NAME" | sed -n 's/.*(\([0-9]*\)).*$/\1/p') # Extracts 45 | |
| # Fallback to gradle file if parsing tag fails or if you prefer this method | |
| if [ -z "$VERSION_NAME" ] || [ -z "$VERSION_CODE" ]; then | |
| echo "Could not parse version from tag, falling back to build.gradle.kts" | |
| VERSION_NAME=$(grep -E 'versionName\s' app/build.gradle.kts | sed -n 's/.*versionName\s*=\s*["'\'']\([^"'\'']*\)["'\''].*/\1/p') | |
| VERSION_CODE=$(grep 'versionCode' app/build.gradle.kts | sed -n 's/.*versionCode\s*=\s*\([0-9]*\).*/\1/p') | |
| fi | |
| echo "VERSION_NAME=${VERSION_NAME}" >> $GITHUB_ENV | |
| echo "VERSION_CODE=${VERSION_CODE}" >> $GITHUB_ENV | |
| echo "Tag: ${TAG_NAME}" | |
| echo "Version Name: ${VERSION_NAME}" | |
| echo "Version Code: ${VERSION_CODE}" | |
| - name: Setup Keystore | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }} | |
| run: | | |
| echo "$KEYSTORE_BASE64" | base64 --decode > release.jks | |
| echo "storeFile=release.jks" > keystore.properties | |
| echo "keyAlias=$KEY_ALIAS" >> keystore.properties | |
| echo "keyPassword=$KEY_PASSWORD" >> keystore.properties | |
| echo "storePassword=$STORE_PASSWORD" >> keystore.properties | |
| - name: Create release folder | |
| run: mkdir -p app/build/outputs/apk/release | |
| - name: Build release artifacts | |
| run: ./gradlew clean assembleRelease bundleGmsRelease | |
| - name: Rename artifacts | |
| run: | | |
| mv "app/build/outputs/apk/gms/release/app-gms-release.apk" "app/build/outputs/apk/release/SummaryExpressive-gms-${{ env.VERSION_NAME }}(${{ env.VERSION_CODE }}).apk" | |
| mv "app/build/outputs/apk/standalone/release/app-standalone-release.apk" "app/build/outputs/apk/release/SummaryExpressive-standalone-${{ env.VERSION_NAME }}(${{ env.VERSION_CODE }}).apk" | |
| - name: Publish GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: "Release ${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})" | |
| prerelease: false | |
| draft: false | |
| files: app/build/outputs/apk/release/SummaryExpressive-*.apk |