fix flutter_ci.yml #21
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: Flutter CI/CD | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
jobs: | |
build-android: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout from GitHub | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # for GitVersion | |
# cf https://github.com/GitTools/actions/blob/v0.10.2/docs/examples/github/gitversion/setup/usage-examples.md | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: "5.x" | |
# cf https://github.com/GitTools/actions/blob/v0.10.2/docs/examples/github/gitversion/execute/usage-examples.md#example-5 | |
- name: Use GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
- name: Decode keystore | |
run: echo "${{ secrets.UPLOAD_KEYSTORE_BASE64 }}" | base64 --decode > android/app/upload-keystore.jks | |
- name: Create key.properties | |
run: | | |
echo "storeFile=upload-keystore.jks" > android/key.properties | |
echo "storePassword=${{ secrets.UPLOAD_KEYSTORE_PASSWORD }}" >> android/key.properties | |
echo "keyPassword=${{ secrets.UPLOAD_KEY_PASSWORD }}" >> android/key.properties | |
echo "keyAlias=upload" >> android/key.properties | |
- name: Setup Java JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: "11" | |
cache: "gradle" | |
- name: Check Java | |
run: java -version | |
- name: Set up Flutter actions | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
cache: true | |
cache-key: 'flutter-:os:-:channel:-:version:-:arch:' | |
- name: Install dependencies | |
run: flutter pub get | |
# - name: Run tests | |
# run: flutter test | |
- name: Build APK | |
run: flutter build apk --build-name=${{ steps.gitversion.outputs.majorMinorPatch }}+${{ steps.gitversion.outputs.ShortSha }} --build-number=${{ github.run_number }} | |
# - name: Upload APK | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: app-release.apk | |
# path: build/app/outputs/flutter-apk/app-release.apk | |
- name: Build App Bundle | |
run: flutter build appbundle --build-name=${{ steps.gitversion.outputs.majorMinorPatch }}+${{ steps.gitversion.outputs.ShortSha }} --build-number=${{ github.run_number }} | |
# - name: Upload App Bundle | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: app-release.aab | |
# path: build/app/outputs/bundle/release/app-release.aab | |
# if a tag is being pushed, upload to Google Play | |
- name: Upload to Google Play | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} | |
packageName: nbros.ong_music | |
releaseFiles: build/app/outputs/bundle/release/app-release.aab | |
track: 'alpha' # internal, alpha, beta, production | |
status: completed # draft, or completed(default) to release directly | |
build-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout from GitHub | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # for GitVersion | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: "5.x" | |
- name: Use GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
- name: Set up Flutter actions | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
cache: true | |
cache-key: 'flutter-:os:-:channel:-:version:-:arch:' | |
- name: Install dependencies | |
run: flutter pub get | |
# - name: Run tests | |
# run: flutter test | |
- name: Build Windows app | |
run: flutter build windows --release --build-name=${{ steps.gitversion.outputs.majorMinorPatch }} --build-number=${{ github.run_number }} | |
- name: Compute zip name | |
id: zip-name | |
run: | | |
echo "::set-output name=zip_name::Ong_Music-windows-${{ steps.gitversion.outputs.majorMinorPatch }}+${{ github.run_number }}.zip" | |
- name: Download sqlite3.dll | |
run: curl -o build/windows/x64/runner/Release/sqlite3.dll https://github.com/tekartik/sqflite/raw/master/sqflite_common_ffi/lib/src/windows/sqlite3.dll | |
- name: Zip Windows build | |
run: 7z a ${{ steps.zip-name.outputs.zip_name }} build/windows/x64/runner/Release/ | |
- name: Upload Windows app zip | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ steps.zip-name.outputs.zip_name }} | |
- name: Read tag message | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
git tag -l --format='%(contents)' ${{ github.ref }} > tag-message.txt | |
- name: Create GitHub Release and Upload Asset | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: ${{ steps.zip-name.outputs.zip_name }} | |
body_path: tag-message.txt | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |