Test & Build & Release with Android #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: Test & Build & Release with Android | |
on: | |
workflow_dispatch: | |
jobs: | |
test: | |
name: flutter test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ vars.JAVA_VERSION }} | |
- uses: dart-lang/setup-dart@v1 | |
with: | |
sdk: ${{ vars.DART_VERSION }} | |
- run: dart --version | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- run: flutter --version | |
- run: flutter pub get | |
- name: Verify formatting | |
run: dart format --output=none --set-exit-if-changed . | |
- run: flutter analyze | |
- run: flutter test | |
- uses: actions/checkout@v2 | |
version: | |
name: flutter version | |
runs-on: ubuntu-latest | |
outputs: | |
releaseversion: ${{ steps.v.outputs.version }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.head_ref }} # checkout the correct branch name | |
fetch-depth: 0 # fetch the whole repo history | |
- name: Git Version | |
id: gitversion | |
uses: codacy/git-version@2.2.0 | |
with: | |
dev-branch: develop | |
prefix: v | |
- name: Save git-version | |
id: v | |
run: echo "::set-output name=version::${{ steps.gitversion.outputs.VERSION }}" | |
build_android: | |
needs: [test, version] | |
name: Build Android | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo ${{needs.version.outputs.releaseversion}} | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup java | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ vars.JAVA_VERSION }} | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- run: flutter pub get | |
- run: flutter build apk --debug | |
- run: flutter build appbundle | |
- name: Upload Android build artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: android-artifacts | |
path: build/app/outputs | |
release: | |
needs: [version, build_android] | |
name: Create a Release in GitHub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Download Android build artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: android-artifacts | |
path: android-artifacts | |
- name: Create a Release in GitHub | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: | | |
android-artifacts/bundle/release/* | |
android-artifacts/apk/debug/* | |
tag: ${{needs.version.outputs.releaseversion}} | |
commit: ${{ github.sha }} |