add release action #21
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 CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| # This creates 4 parallel jobs: dev-debug, dev-release, prod-debug, prod-release | |
| matrix: | |
| flavor: [dev, prod] | |
| buildType: [debug, release] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Generate Version Info | |
| id: vars | |
| run: | | |
| # 558 is a base version code. github.run_number increments by 1 every build. | |
| echo "version_code=$((558 + ${{ github.run_number }}))" >> $GITHUB_OUTPUT | |
| echo "short_hash=-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Build and Test with Gradle | |
| run: | | |
| # Convert 'dev' to 'Dev' and 'debug' to 'Debug' | |
| FLAVOR_CAP=$(echo ${{ matrix.flavor }} | sed 's/./\u&/') | |
| TYPE_CAP=$(echo ${{ matrix.buildType }} | sed 's/./\u&/') | |
| # Run tests and build the specific combination | |
| ./gradlew "test${FLAVOR_CAP}${TYPE_CAP}UnitTest" \ | |
| "assemble${FLAVOR_CAP}${TYPE_CAP}" \ | |
| -PnewVersionCode=${{ steps.vars.outputs.version_code }} \ | |
| -PversionNameSuffix=${{ steps.vars.outputs.short_hash }} | |
| - name: Sign APK | |
| uses: ilharp/sign-android-release@v2 | |
| id: sign_app | |
| with: | |
| releaseDir: app/build/outputs/apk/${{ matrix.flavor }}/${{ matrix.buildType }} | |
| signingKey: ${{ secrets.SIGNING_KEY }} | |
| keyAlias: ${{ secrets.SIGNING_KEY_ALIAS }} | |
| keyStorePassword: ${{ secrets.SIGNING_KEY_STORE_PASSWORD }} | |
| keyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
| buildToolsVersion: 36.1.0 | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ActivityManager-${{ matrix.flavor }}-${{ matrix.buildType }}-${{ steps.vars.outputs.version_code }} | |
| path: ${{ steps.sign_app.outputs.signedFile }} | |
| archive: false | |
| - name: Test Summary | |
| uses: test-summary/action@v2 | |
| with: | |
| paths: "app/build/test-results/**/TEST-*.xml" | |
| if: always() |