add build and release workflow #1
This file contains 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 build and release | |
on: | |
push: | |
branches: develop | |
workflow_dispatch: | |
jobs: | |
version: | |
name: Create version number | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0.9.7 | |
with: | |
versionSpec: "5.x" | |
- name: Use GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0.9.7 | |
- name: Create version.txt with nuGetVersion | |
run: echo ${{ steps.gitversion.outputs.nuGetVersion }} > version.txt | |
- name: Upload version.txt | |
uses: actions/upload-artifact@v2 | |
with: | |
name: gitversion | |
path: version.txt | |
build: | |
name: Create Android Release | |
needs: version | |
runs-on: ubuntu-latest | |
steps: | |
- name: 📚 Git Checkout | |
uses: actions/checkout@v1 | |
- name: Git version.txt | |
uses: actions/download-artifact@v2 | |
with: | |
name: gitversion | |
- name: Create new file without newline char from version.txt | |
run: tr -d '\n' < version.txt > version1.txt | |
- name: Read version | |
id: version | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: version1.txt | |
- name: Update version in YAML | |
run: sed -i 's/99.99.99+99/${{ steps.version.outputs.content }}+${{ github.run_number }}/g' pubspec.yaml | |
- name: Download Android keystore | |
id: android_keystore | |
uses: timheuer/base64-to-file@v1.0.3 | |
with: | |
fileName: upload-keystore.jks | |
encodedString: ${{ secrets.KEYSTORE_BASE64 }} | |
- name: Create key.properties | |
run: | | |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties | |
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/key.properties | |
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties | |
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties | |
- name: Download Android keystore | |
id: google_play_service | |
uses: timheuer/base64-to-file@v1.0.3 | |
with: | |
fileName: app/google-services.json | |
encodedString: ${{ secrets.GOOGLE_SERVICE_BASE64 }} | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: "zulu" | |
java-version: "12.x" | |
cache: gradle | |
- name: 🐦 Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
cache: true | |
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} | |
- name: 📦 Install Dependencies | |
run: | | |
flutter packages get | |
- name: ✨ Check Formatting | |
run: dart format --line-length 80 --set-exit-if-changed lib test | |
- name: 🏗️ Generate build_runner | |
run: dart run build_runner build -d | |
- name: 🌐 Generate Locale Keys | |
run: dart run easy_localization:generate -S assets/translations -O lib/src/l10n -o locale_keys.g.dart -f keys | |
- name: Start Android Release Build | |
run: apk --split-per-abi --target lib/main.dart --dart-define-from-file=.env | |
- name: Upload Android Release | |
uses: actions/upload-artifact@v2 | |
with: | |
name: android-release | |
path: build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk | |
# path: build/app/outputs/bundle/release/app-release.aab |