mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
reuse Build Android workflow
This commit is contained in:
parent
f314102c4b
commit
4ed3d4efb9
2 changed files with 86 additions and 153 deletions
116
.github/workflows/build_apk.yml
vendored
116
.github/workflows/build_apk.yml
vendored
|
@ -3,29 +3,65 @@
|
||||||
# separate terms of service, privacy policy, and support
|
# separate terms of service, privacy policy, and support
|
||||||
# documentation.
|
# documentation.
|
||||||
|
|
||||||
name: Build .apk
|
name: Build Android
|
||||||
|
|
||||||
|
run-name: Build ${{ inputs.binary-type == 'apk' && '.apk' || '.aab' }} v${{ inputs.version }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Version"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
binary-type:
|
||||||
|
description: "Binary type"
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
flavor:
|
||||||
|
description: "Flavor"
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
include-iap:
|
||||||
|
type: boolean
|
||||||
|
description: Include IAP package
|
||||||
|
default: true
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Version"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
binary-type:
|
||||||
|
description: "Binary type"
|
||||||
|
type: choice
|
||||||
|
required: true
|
||||||
|
options:
|
||||||
|
- apk
|
||||||
|
- appbundle
|
||||||
flavor:
|
flavor:
|
||||||
description: 'Flavor'
|
description: "Flavor"
|
||||||
type: choice
|
type: choice
|
||||||
required: true
|
required: true
|
||||||
options:
|
options:
|
||||||
- dev
|
- dev
|
||||||
- prod
|
- prod
|
||||||
default: 'dev'
|
default: dev
|
||||||
include-iap:
|
include-iap:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Include IAP package
|
description: Include IAP package
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
BUILD_ARGS: --release --flavor ${{ inputs.flavor }} -t lib/main_${{ inputs.flavor }}.dart
|
||||||
|
BUILD_APK_PATH: build/app/outputs/flutter-apk/app-${{ inputs.flavor }}-release.apk
|
||||||
|
BUILD_AAB_PATH: build/app/outputs/bundle/${{ inputs.flavor }}Release/app-${{ inputs.flavor }}-release.aab
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-android:
|
||||||
name: Build .apk
|
name: Build ${{ inputs.binary-type == 'apk' && '.apk' || '.aab' }}
|
||||||
runs-on: macos-11
|
runs-on: macos-11
|
||||||
timeout-minutes: 15
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
@ -40,57 +76,43 @@ jobs:
|
||||||
- name: Override iap package with stub
|
- name: Override iap package with stub
|
||||||
if: ${{ !inputs.include-iap }}
|
if: ${{ !inputs.include-iap }}
|
||||||
run: bash ./.github/scripts/stub_iap.sh
|
run: bash ./.github/scripts/stub_iap.sh
|
||||||
|
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: "zulu"
|
|
||||||
java-version: "11"
|
|
||||||
|
|
||||||
- name: Restore Android keystore .jsk and .properties files
|
|
||||||
env:
|
|
||||||
KEYSTORE: ${{ secrets.KEYSTORE }}
|
|
||||||
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}
|
|
||||||
run: |
|
|
||||||
KEYSTORE_PATH=$RUNNER_TEMP/keystore.jks
|
|
||||||
echo -n "$KEYSTORE" | base64 --decode --output $KEYSTORE_PATH
|
|
||||||
cp $KEYSTORE_PATH ./android/app
|
|
||||||
KEYSTORE_PROPERTIES_PATH=$RUNNER_TEMP/key.properties
|
|
||||||
echo -n "$KEYSTORE_PROPERTIES" | base64 --decode --output $KEYSTORE_PROPERTIES_PATH
|
|
||||||
cp $KEYSTORE_PROPERTIES_PATH ./android
|
|
||||||
|
|
||||||
- name: Restore android/app/google-services.json
|
|
||||||
env:
|
|
||||||
GOOGLE_SERVICES_JSON_ANDROID: ${{ secrets.GOOGLE_SERVICES_JSON_ANDROID }}
|
|
||||||
run: |
|
|
||||||
GOOGLE_SERVICES_JSON_ANDROID_PATH=$RUNNER_TEMP/google-services.json
|
|
||||||
echo -n "$GOOGLE_SERVICES_JSON_ANDROID" | base64 --decode --output $GOOGLE_SERVICES_JSON_ANDROID_PATH
|
|
||||||
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
|
|
||||||
|
|
||||||
- name: Restore firebase_options.dart
|
|
||||||
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart"
|
|
||||||
|
|
||||||
- name: Restore constants.dart
|
|
||||||
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart"
|
|
||||||
|
|
||||||
- name: Install Flutter
|
- name: Install Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
channel: "stable"
|
channel: "stable"
|
||||||
flutter-version: '3.10.0'
|
flutter-version: "3.10.0"
|
||||||
|
|
||||||
|
- uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: "zulu"
|
||||||
|
java-version: "11"
|
||||||
|
|
||||||
|
- name: Restore Android keystore .jsk and .properties files
|
||||||
|
run: |
|
||||||
|
bash .github/scripts/restore_from_base64.sh "${{ secrets.KEYSTORE_PROPERTIES }}" "$RUNNER_TEMP/android/app/key.properties"
|
||||||
|
bash .github/scripts/restore_from_base64.sh "${{ secrets.KEYSTORE }}" "$RUNNER_TEMP/android/keystore.jks"
|
||||||
|
|
||||||
|
- name: Restore secrets
|
||||||
|
run: |
|
||||||
|
bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart"
|
||||||
|
bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart"
|
||||||
|
bash .github/scripts/restore_from_base64.sh "${{ secrets.GOOGLE_SERVICES_JSON_ANDROID }}" "android/app/google-services.json"
|
||||||
|
|
||||||
|
- name: Increment build number & replace version number
|
||||||
|
run: bash ./.github/scripts/increment_build_number.sh ${{ github.event.inputs.version }}
|
||||||
|
|
||||||
- name: Prepare flutter project
|
- name: Prepare flutter project
|
||||||
run: |
|
run: |
|
||||||
flutter --version
|
flutter --version
|
||||||
flutter pub get
|
flutter pub get
|
||||||
flutter pub run intl_utils:generate
|
flutter pub run intl_utils:generate
|
||||||
|
|
||||||
- name: Build .apk
|
- name: Build ${{ inputs.binary-type }}
|
||||||
env:
|
run: flutter build ${{ inputs.binary-type }} $BUILD_ARGS
|
||||||
FLAVOR: ${{ github.event.inputs.flavor }}
|
|
||||||
run: flutter build apk --release --flavor $FLAVOR -t lib/main_$FLAVOR.dart
|
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload ${{ inputs.binary-type }} to artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: m3_lightmeter_${{ github.event.inputs.flavor }}_apk
|
name: m3_lightmeter_${{ inputs.binary-type }}
|
||||||
path: build/app/outputs/flutter-apk/app-${{ github.event.inputs.flavor }}-release.apk
|
path: ${{ inputs.binary-type == 'apk' && env.BUILD_APK_PATH || env.BUILD_AAB_PATH }}
|
||||||
|
|
123
.github/workflows/create_release.yml
vendored
123
.github/workflows/create_release.yml
vendored
|
@ -22,121 +22,35 @@ on:
|
||||||
description: "Release notes"
|
description: "Release notes"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
github-release:
|
|
||||||
type: boolean
|
|
||||||
description: Create Github release
|
|
||||||
default: true
|
|
||||||
google-play-release:
|
|
||||||
type: boolean
|
|
||||||
description: Create Google Play release
|
|
||||||
default: true
|
|
||||||
include-iap:
|
include-iap:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Include IAP package
|
description: Include IAP package
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
env:
|
|
||||||
BUILD_ARGS: --release --flavor prod -t lib/main_prod.dart
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run-integration-tests:
|
run-integration-tests:
|
||||||
name: Run integration tests
|
name: Run integration tests
|
||||||
uses: ./.github/workflows/run_integration_tests.yml
|
uses: ./.github/workflows/run_integration_tests.yml
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
build:
|
build-android:
|
||||||
name: Build .apk & .aab
|
name: Build Android (${{ matrix.binary-type }})
|
||||||
needs: [run-integration-tests]
|
needs: [run-integration-tests]
|
||||||
if: ${{ inputs.github-release || inputs.google-play-release }}
|
|
||||||
runs-on: macos-11
|
runs-on: macos-11
|
||||||
timeout-minutes: 30
|
strategy:
|
||||||
|
matrix:
|
||||||
|
binary-type: [apk, appbundle]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: ./.github/workflows/build_android.yml
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
binary-type: ${{ matrix.binary-type }}
|
||||||
|
flavor: prod
|
||||||
- name: Connect private iap package
|
include-iap: ${{ inputs.include-iap }}
|
||||||
uses: webfactory/ssh-agent@v0.8.0
|
version: ${{ inputs.version }}
|
||||||
if: ${{ inputs.include-iap }}
|
|
||||||
with:
|
|
||||||
ssh-private-key: ${{ secrets.M3_LIGHTMETER_IAP_KEY }}
|
|
||||||
|
|
||||||
- name: Override iap package with stub
|
|
||||||
if: ${{ !inputs.include-iap }}
|
|
||||||
run: bash ./.github/scripts/stub_iap.sh
|
|
||||||
|
|
||||||
- uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: "zulu"
|
|
||||||
java-version: "11"
|
|
||||||
|
|
||||||
- name: Restore Android keystore .jsk and .properties files
|
|
||||||
env:
|
|
||||||
KEYSTORE: ${{ secrets.KEYSTORE }}
|
|
||||||
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}
|
|
||||||
run: |
|
|
||||||
KEYSTORE_PATH=$RUNNER_TEMP/keystore.jks
|
|
||||||
echo -n "$KEYSTORE" | base64 --decode --output $KEYSTORE_PATH
|
|
||||||
cp $KEYSTORE_PATH ./android/app
|
|
||||||
KEYSTORE_PROPERTIES_PATH=$RUNNER_TEMP/key.properties
|
|
||||||
echo -n "$KEYSTORE_PROPERTIES" | base64 --decode --output $KEYSTORE_PROPERTIES_PATH
|
|
||||||
cp $KEYSTORE_PROPERTIES_PATH ./android
|
|
||||||
|
|
||||||
- name: Restore android/app/google-services.json
|
|
||||||
env:
|
|
||||||
GOOGLE_SERVICES_JSON_ANDROID: ${{ secrets.GOOGLE_SERVICES_JSON_ANDROID }}
|
|
||||||
run: |
|
|
||||||
GOOGLE_SERVICES_JSON_ANDROID_PATH=$RUNNER_TEMP/google-services.json
|
|
||||||
echo -n "$GOOGLE_SERVICES_JSON_ANDROID" | base64 --decode --output $GOOGLE_SERVICES_JSON_ANDROID_PATH
|
|
||||||
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
|
|
||||||
|
|
||||||
- name: Restore firebase_options.dart
|
|
||||||
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart"
|
|
||||||
|
|
||||||
- name: Restore constants.dart
|
|
||||||
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart"
|
|
||||||
|
|
||||||
# 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: bash ./.github/scripts/increment_build_number.sh ${{ github.event.inputs.version }}
|
|
||||||
|
|
||||||
- name: Install Flutter
|
|
||||||
uses: subosito/flutter-action@v2
|
|
||||||
with:
|
|
||||||
channel: "stable"
|
|
||||||
flutter-version: "3.10.0"
|
|
||||||
|
|
||||||
- name: Prepare flutter project
|
|
||||||
run: |
|
|
||||||
flutter --version
|
|
||||||
flutter pub get
|
|
||||||
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
|
|
||||||
path: build/app/outputs/bundle/prodRelease/app-prod-release.aab
|
|
||||||
|
|
||||||
generate-release-notes:
|
generate-release-notes:
|
||||||
name: Generate release notes
|
name: Generate release notes
|
||||||
|
needs: [build-android]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Generate release notes
|
- name: Generate release notes
|
||||||
|
@ -152,8 +66,7 @@ jobs:
|
||||||
|
|
||||||
update-version-in-repo:
|
update-version-in-repo:
|
||||||
name: Update repo version
|
name: Update repo version
|
||||||
if: ${{ inputs.github-release }}
|
needs: [build-android]
|
||||||
needs: [build]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@ -179,8 +92,7 @@ jobs:
|
||||||
|
|
||||||
create-github-release:
|
create-github-release:
|
||||||
name: Create Github release
|
name: Create Github release
|
||||||
if: ${{ inputs.github-release }}
|
needs: [build-android, generate-release-notes, update-version-in-repo]
|
||||||
needs: [build, generate-release-notes, update-version-in-repo]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
@ -212,8 +124,7 @@ jobs:
|
||||||
|
|
||||||
create-google-play-release:
|
create-google-play-release:
|
||||||
name: Create Google Play release
|
name: Create Google Play release
|
||||||
if: ${{ inputs.google-play-release }}
|
needs: [build-android, generate-release-notes]
|
||||||
needs: [build, generate-release-notes]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@ -223,7 +134,7 @@ jobs:
|
||||||
- name: Download app bundle
|
- name: Download app bundle
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: m3_lightmeter_bundle
|
name: m3_lightmeter_appbundle
|
||||||
|
|
||||||
- name: Extract & zip merged_native_libs
|
- name: Extract & zip merged_native_libs
|
||||||
run: |
|
run: |
|
||||||
|
@ -278,7 +189,7 @@ jobs:
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
uses: geekyeggo/delete-artifact@v2
|
uses: geekyeggo/delete-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: m3_lightmeter_bundle
|
name: m3_lightmeter_appbundle
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
name: Cleanup
|
name: Cleanup
|
||||||
|
|
Loading…
Reference in a new issue