diff --git a/.github/workflows/production_android.yml b/.github/workflows/production_android.yml new file mode 100644 index 0000000..dce9aab --- /dev/null +++ b/.github/workflows/production_android.yml @@ -0,0 +1,99 @@ +name: Release Android production version +on: + push: + tags: + - 'v*' +jobs: + build: + name: Test, build and release + runs-on: ubuntu-latest + steps: + ############################################## + # setup variables + ############################################## + - name: Prepare variables + id: prepare_variables + run: | + semver_regex="^([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)\.([0-9]|[1-9][0-9]*)$" + BUILD_NAME="${GITHUB_REF:20}" + [[ $BUILD_NAME =~ $semver_regex ]] && echo ::set-output name=build_name::"$BUILD_NAME" || (echo "Build name $BUILD_NAME is not semver" && exit 1); + TIMESTAMP=`date +%s` + echo ::set-output name=build_number::$TIMESTAMP + echo ::set-output name=release_name::"$BUILD_NAME+$TIMESTAMP" + + ############################################## + # setup actions + ############################################## + - uses: actions/checkout@v1 + - uses: actions/setup-java@v1 + with: + java-version: '12.x' + - uses: subosito/flutter-action@v1 + with: + channel: 'beta' + + ############################################## + # setup-gcloud + ############################################## + # the setup-gcloud action seems to need python + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + # use setup-gcloud configured with auth credentials + - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master + with: + version: '270.0.0' + service_account_email: ${{ secrets.GCS_EMAIL }} + service_account_key: ${{ secrets.GCS_KEY }} + + ############################################ + # download credential files + ############################################ + - name: Download credential files + run: ./get-credentials.sh + + ############################################ + # test and build the app + ############################################ + - name: Run Flutter tests + run: | + flutter pub get + flutter test + + ############################################ + # build AAB and upload to the Play Store using Fastlane + ############################################ + - name: Build AAB + run: flutter build appbundle --build-name=${{ steps.prepare_variables.outputs.build_name }} --build-number=${{ steps.prepare_variables.outputs.build_number }} + - name: Upload to the production track on the Play Store + uses: maierj/fastlane-action@v1.4.0 + with: + lane: 'production' + subdirectory: 'android' + + ############################################ + # build APK and create a prerelase on GitHub + ############################################ + - name: Build (fat) APK + run: flutter build apk --build-name=${{ steps.prepare_variables.outputs.build_name }} --build-number=${{ steps.prepare_variables.outputs.build_number }} + - name: Create Release + id: create_release + uses: fleskesvor/create-release@feature/support-target-commitish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + release_name: ${{ steps.prepare_variables.outputs.release_name }} + tag_name: v${{ github.ref }} + commitish: ${{ github.sha }} + draft: false + prerelease: false + - 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: tormented-player-${{ steps.prepare_variables.outputs.release_name }}.apk + asset_content_type: application/vnd.android.package-archive \ No newline at end of file diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index 525d200..fef761a 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -16,25 +16,33 @@ default_platform(:android) platform :android do - desc "Submit a new Alpha Build to Google Play" + desc "Submit a new Alpha build to Google Play" lane :alpha do # Upload the existing build to the alpha track upload_to_play_store( track: 'alpha', aab: '../build/app/outputs/bundle/release/app-release.aab', - skip_upload_changelogs: true ) end - desc "Submit a new Beta Build to Google Play" + desc "Submit a new Beta build to Google Play" lane :beta do # Upload the existing build to the beta track upload_to_play_store( track: 'beta', aab: '../build/app/outputs/bundle/release/app-release.aab', - skip_upload_changelogs: true + ) + end + + desc "Submit a new Production build to Google Play" + lane :production do + # Upload the existing build to the production track + + upload_to_play_store( + track: 'production', + aab: '../build/app/outputs/bundle/release/app-release.aab', ) end end