Building a preview version apk file #69
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: build-preview-android | |
run-name: Building a preview version apk file | |
permissions: | |
contents: write | |
packages: write | |
deployments: write | |
issues: write | |
pull-requests: write | |
repository-projects: write | |
security-events: write | |
statuses: write | |
on: | |
push: | |
branches: | |
- 'build-**' | |
- '!build-prerelease' | |
- '!build-release' | |
jobs: | |
check_changes: | |
outputs: | |
run_build: ${{ steps.verify-changed-files.outputs.any_changed }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Verify Changed files | |
uses: tj-actions/changed-files@v42 | |
id: verify-changed-files | |
with: | |
files: | | |
.github/workflows/build-preview.yml | |
pubspec.yaml | |
pubspec.lock | |
l10n.yaml | |
lib/** | |
android/** | |
build: | |
needs: check_changes | |
if: contains(toJSON(github.event.head_commit.message), 'Merge pull request ') == false && needs.check_changes.outputs.run_build == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-java@v2 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: 'stable' | |
cache: true | |
cache-key: 'flutter-:os:-:channel:-:version:' # optional, change this to force refresh cache | |
architecture: x64 | |
- name: Create the Keystore | |
env: | |
KEYSTORE_B64: ${{ secrets.KEYSTORE_B64 }} | |
run: | | |
# import keystore from secrets | |
echo $KEYSTORE_B64 | base64 -d > $RUNNER_TEMP/keystore.jks | |
- name: Create key.properties | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASS }} | |
KEY_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASS }} | |
run: | | |
echo -e "storePassword=$KEYSTORE_PASSWORD\nkeyPassword=$KEY_PASSWORD\nkeyAlias=$KEY_ALIAS\nstoreFile=$RUNNER_TEMP/keystore.jks" > android/key.properties | |
- uses: paulhatch/[email protected] | |
id: semver | |
with: | |
# The prefix to use to identify tags | |
tag_prefix: "v" | |
# A string which, if present in a git commit, indicates that a change represents a | |
# major (breaking) change, supports regular expressions wrapped with '/' | |
major_pattern: "(MAJOR)" | |
# A string which indicates the flags used by the `major_pattern` regular expression. Supported flags: idgs | |
major_regexp_flags: "" | |
# Same as above except indicating a minor change, supports regular expressions wrapped with '/' | |
minor_pattern: "(MINOR)" | |
# A string which indicates the flags used by the `minor_pattern` regular expression. Supported flags: idgs | |
minor_regexp_flags: "" | |
# A string to determine the format of the version output | |
version_format: "${major}.${minor}.${patch}+${increment}" | |
bump_each_commit: false | |
- run: flutter pub get | |
- run: flutter gen-l10n | |
- run: flutter build apk --build-name ${{ steps.semver.outputs.version }} --dart-define=BVS="Preview ${{ steps.semver.outputs.version }} ${{ github.ref_name }} GitHub" | |
- run: cp "build/app/outputs/apk/release/app-release.apk" "EduPage2-v${{ steps.semver.outputs.version }}.apk" | |
- uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: "v${{ steps.semver.outputs.version }}-${{ github.ref_name }}" | |
prerelease: true | |
title: "EduPage2 Preview v${{ steps.semver.outputs.version }} ${{ github.ref_name }}" | |
files: | | |
EduPage2-v${{ steps.semver.outputs.version }}.apk |