Skip to content

Build Android Release APK #8

Build Android Release APK

Build Android Release APK #8

Workflow file for this run

name: Build Android Release APK
on:
workflow_dispatch:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
name: Build APK
runs-on: ubuntu-latest
environment:
name: production
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'oracle'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.19.x'
- name: Install Futter dependencies
run: flutter pub get
- name: Decode keystore file
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: |
echo "$KEYSTORE_BASE64" | base64 --decode > ./key.jks
- name: Extract version information
run: |
echo "VERSION_V=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_ENV
echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3 | cut -c 2-)" >> $GITHUB_ENV
echo "BUILD=$(flutter pub run cider version | cut -d '+' -f 2)" >> $GITHUB_ENV
- name: Bump pubspec version
run: |
flutter pub run cider version ${{ env.VERSION }}+${{ env.BUILD }}
flutter pub run cider bump build
- name: Build APK
run: |
cp .env.production .env
echo "storePassword="${{ env.STOREPASSWORD }} > android/.key.properties
echo "keyPassword="${{ env.STOREPASSWORD }} >> android/.key.properties
echo "keyAlias="${{ env.KEYALIAS }} >> android/.key.properties
echo "storeFile=../key.jks" >> android/.key.properties
cat android/.key.properties
flutter build apk --release
- name: Make Github release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
files: |
build/app/outputs/flutter-apk/app-release.apk
# Note: the original tag that triggered the workflow is in the form vX.Y.Z
# but the pubspec.yaml is committed in the commit after that one.
# Since we need the tag to point to the correct commit for other workflows
# such as f-droid we need a way to correct it. Only moving the tag
# would not work, as it would trigger this workflow again. So as
# a workaround, we use the v-tag to trigger this workflow, add a new
# one without the v and push it.
- name: Commit pubspec version and delete tag
run: |
git config user.name Github-Actions
git config user.email [email protected]
git checkout -b release-${{ env.VERSION }}
git add pubspec.yaml
git commit -m "Bump version to $( flutter pub run cider version )"
git push origin --delete ${{ env.VERSION_V }}
git push --set-upstream origin release-${{ env.VERSION }}