Created
May 13, 2020 10:42
-
-
Save RockerFlower/8dc23e71fd44d70f31ccd840b4bb53c4 to your computer and use it in GitHub Desktop.
Flutter Build, Test and Release config for GitHub actions
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: Test, Build and Release | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
push: | |
branches: | |
- master | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;20.0.5594570" | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: '8' | |
- name: Get key file | |
id: write_file | |
uses: timheuer/[email protected] | |
with: | |
fileName: 'key' | |
encodedString: ${{ secrets.KEY_FILE }} | |
- uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '1.12.13+hotfix.9' | |
- run: flutter pub get | |
- run: flutter test | |
- run: flutter build apk --release | |
env: | |
KEY_STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
KEY_ALIAS: oreo | |
KEY_PATH: ${{ steps.write_file.outputs.filePath }} | |
- name: Read version code from local.properties | |
id: read_version_code | |
uses: christian-draeger/[email protected] | |
with: | |
path: './android/local.properties' | |
property: 'flutter.versionCode' | |
- name: Read version name from local.properties | |
id: read_version_name | |
uses: christian-draeger/[email protected] | |
with: | |
path: './android/local.properties' | |
property: 'flutter.versionName' | |
- name: Get current time | |
uses: 1466587594/get-current-time@v1 | |
id: current-time | |
with: | |
format: YYYYMMDDHH | |
utcOffset: "+08:00" | |
- name: Create a Release APK | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: "v${{ steps.read_version_name.outputs.value }}(${{ steps.read_version_code.outputs.value }})" | |
release_name: "Release v${{ steps.read_version_name.outputs.value }}(${{ steps.read_version_code.outputs.value }})" | |
body: | | |
A New Release | |
draft: false | |
prerelease: true | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: build/app/outputs/apk/release/app-release.apk | |
asset_name: "app_release_${{ steps.read_version_name.outputs.value }}_${{ steps.read_version_code.outputs.value }}_${{ steps.current-time.outputs.formattedTime }}.apk" | |
asset_content_type: application/zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment