mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 15:00:40 +00:00
ML-61 Try to automate GP & Github releases via Github Actions (#103)
* Added option to create separate releases * Removed branch condition * Added default values to releases checkboxes * Removed user fraction * Remove .md extension for GP release * More refined releases conditions * Parse release name * Create Google Play release name * Checkout first * Update create_release.yml * Increment build number only for GH release * Release with status `complete` * typo
This commit is contained in:
parent
6e3588a72e
commit
4917ee8aef
1 changed files with 35 additions and 5 deletions
40
.github/workflows/create_release.yml
vendored
40
.github/workflows/create_release.yml
vendored
|
@ -23,6 +23,14 @@ on:
|
|||
description: "Release notes"
|
||||
required: true
|
||||
type: string
|
||||
github-release:
|
||||
type: boolean
|
||||
description: Create Github release
|
||||
default: true
|
||||
google-play-release:
|
||||
type: boolean
|
||||
description: Create Google Play release
|
||||
default: true
|
||||
|
||||
env:
|
||||
BUILD_ARGS: --release --flavor prod --dart-define cameraPreviewAspectRatio=240/320 -t lib/main_prod.dart
|
||||
|
@ -30,6 +38,7 @@ env:
|
|||
jobs:
|
||||
build:
|
||||
name: Build .apk & .aab
|
||||
if: ${{ inputs.github-release }} || ${{ inputs.google-play-release }}
|
||||
runs-on: macos-11
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
|
@ -70,7 +79,10 @@ jobs:
|
|||
echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
|
||||
cp $FIREBASE_OPTIONS_PATH ./lib
|
||||
|
||||
# This step makes sense when Github release is enabled because this release increments the build number.
|
||||
# Therefore here we have to increment it as well to build an apk with the same build number.
|
||||
- name: Increment build number & replace version number
|
||||
if: ${{ inputs.github-release }}
|
||||
run: perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+)(\+)(\d+)$/$1."${{ github.event.inputs.version }}".$3.($4+1)/e' pubspec.yaml
|
||||
|
||||
- name: Install Flutter
|
||||
|
@ -86,18 +98,22 @@ jobs:
|
|||
flutter pub run intl_utils:generate
|
||||
|
||||
- name: Build apk
|
||||
if: ${{ inputs.github-release }}
|
||||
run: flutter build apk $BUILD_ARGS
|
||||
|
||||
- name: Upload apk to artifacts
|
||||
if: ${{ inputs.github-release }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: m3_lightmeter_apk
|
||||
path: build/app/outputs/flutter-apk/app-prod-release.apk
|
||||
|
||||
- name: Build appbundle
|
||||
if: ${{ inputs.google-play-release }}
|
||||
run: flutter build appbundle $BUILD_ARGS
|
||||
|
||||
- name: Upload app bundle to artifacts
|
||||
if: ${{ inputs.google-play-release }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: m3_lightmeter_bundle
|
||||
|
@ -120,6 +136,7 @@ jobs:
|
|||
|
||||
update-version-in-repo:
|
||||
name: Update repo version
|
||||
if: ${{ inputs.github-release }}
|
||||
needs: [build]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -146,7 +163,7 @@ jobs:
|
|||
|
||||
create-github-release:
|
||||
name: Create Github release
|
||||
if: github.ref_name == 'main'
|
||||
if: ${{ inputs.github-release }}
|
||||
needs: [build, generate-release-notes, update-version-in-repo]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
|
@ -179,10 +196,14 @@ jobs:
|
|||
|
||||
create-google-play-release:
|
||||
name: Create Google Play release
|
||||
if: github.ref_name == 'main'
|
||||
if: ${{ inputs.google-play-release }}
|
||||
needs: [build, generate-release-notes]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Download app bundle
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
|
@ -200,8 +221,17 @@ jobs:
|
|||
|
||||
- name: Move release notes to a folder
|
||||
run: |
|
||||
mv whatsnew-en-US.md whatsnew-en-US
|
||||
mkdir whatsnew
|
||||
mv whatsnew-en-US.md whatsnew
|
||||
mv whatsnew-en-US whatsnew
|
||||
|
||||
# https://unix.stackexchange.com/questions/13466/can-grep-output-only-specified-groupings-that-match'
|
||||
# https://stackoverflow.com/questions/74353311/github-workflow-unable-to-process-file-command-env-successfully
|
||||
- name: Create Google Play release name
|
||||
id: release-name
|
||||
run: |
|
||||
RELEASE_NAME=$(echo "$(cat pubspec.yaml)" | sed -n -r "s/^version:\s{1}(.*)[+](.*)$/700\2 (\1)/p")
|
||||
echo "release_name=$RELEASE_NAME" >> $GITHUB_ENV
|
||||
|
||||
- name: Create Google Play release
|
||||
id: create-google-play-release-step
|
||||
|
@ -210,9 +240,9 @@ jobs:
|
|||
serviceAccountJsonPlainText: ${{ secrets.GH_ACTIONS_SERVICE_ACCOUNT_JSON }}
|
||||
packageName: com.vodemn.lightmeter
|
||||
releaseFiles: app-prod-release.aab
|
||||
releaseName: ${{ env.release_name }}
|
||||
track: production
|
||||
status: draft
|
||||
userFraction: 1.0
|
||||
status: completed
|
||||
debugSymbols: merged_native_libs.zip
|
||||
whatsNewDirectory: whatsnew
|
||||
|
||||
|
|
Loading…
Reference in a new issue