Skip to content

Commit

Permalink
ci: add workflow for production deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Jei committed May 16, 2020
1 parent b247bba commit 7e3d05f
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 4 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/production_android.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
16 changes: 12 additions & 4 deletions android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7e3d05f

Please sign in to comment.