Create static.yml #20
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 Build and Upload Android APK | |
on: | |
push: # This is the condition that the action will run on | |
branches: [ main ] # In this case when you push your code into GitHub | |
# tags: | |
# - "v*.*.*" # In this case when you tag your commit with v1.0.0 for example | |
jobs: | |
build: | |
runs-on: ubuntu-latest # This is the type of machine we want to run the action on | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 # Checkout the Repository on the Virtual Machine | |
- name: Set up JDK # Setup JAVA to build the Android APK for us | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: microsoft | |
# Decode keystore File from repository secrets | |
# Keep the keystore file private; don’t check it into public source control! | |
#- name: Decode KeyStore File (.jks) | |
# run: echo "${{ secrets.KEYSTORE_JKS_PROD }}" | base64 --decode > android/keystore.jks | |
#- name: Decode android/key.properties | |
# run: echo "${{ secrets.KEY_PROPERTIES_PROD }}" | base64 --decode > android/key.properties | |
- name: Install yq | |
uses: mikefarah/[email protected] | |
- name: Get pubspec version | |
id: get_flutter_app_version | |
run: | | |
VERSION=$(yq e '.version' pubspec.yaml | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\+[0-9]+') | |
echo "TAG_VERSION=${VERSION%%+*}" >> $GITHUB_ENV | |
echo "::set-output name=TAG_VERSION::${VERSION%%+*}" | |
- name: Create git tag | |
run: | | |
git tag "v${{ steps.get_flutter_app_version.outputs.TAG_VERSION }}" | |
git push origin "v${{ steps.get_flutter_app_version.outputs.TAG_VERSION }}" | |
- name: Install Flutter # Install Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: 'main' | |
- name: Get Flutter dependencies # Get the Libraries and Dependencies | |
run: flutter pub get | |
- name: Build APK Release # Build a release | |
run: flutter build apk --release | |
- name: Build an AppBundle # App Bundles are useful for Google Play Store | |
run: flutter build appbundle --release | |
- name: Save APK to Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: flutter-apk | |
path: build/app/outputs/flutter-apk/*.apk | |
- name: Save APPBUNDLE to Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: flutter-appbundle | |
path: build/app/outputs/bundle/release/*.aab | |
- name: Create Github Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "build/app/outputs/bundle/release/*.aab,build/app/outputs/flutter-apk/*.apk" | |
tag: "v${{ steps.get_flutter_app_version.outputs.TAG_VERSION }}" | |
# TODO: Upload to Firebase - for App Distribution | |
# Release job, upload the apk or aab to Firebase App Distribution | |
# release: | |
# name: Sends Release APK to Firebase | |
# needs: [ build ] | |
# runs-on: ubuntu-latest | |
# steps: | |
# # Retrieve apk file from GitHub artifacts | |
# - uses: actions/checkout@v3 | |
# - name: Get flutter-apk from artifacts | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: flutter-apk | |
# OR | |
# name: flutter-appbundle | |
# # Upload apk file to Firebase | |
# - name: Upload artifact to Firebase App Distribution | |
# uses: wzieba/Firebase-Distribution-Github-Action@v1 | |
# with: | |
# appId: ${{secrets.FIREBASE_IOS_APP_ID}} | |
# serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }} | |
# groups: android-developers | |
# file: ${{secrets.APP_NAME}}.apk | |
# OR | |
# file: ${{secrets.APP_NAME}}.aab |