Publish Release #47
Workflow file for this run
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: Publish Release | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
env: | |
FLUTTER_VERSION: 3.24.0 | |
JAVA_VERSION: 17 | |
# https://github.com/android-actions/setup-android?tab=readme-ov-file#sdk-version-selection | |
CMDLINE_TOOLS_VERSION: 10406996 # 11.0 | |
# Pin build path for reproducible builds. | |
BUILD_PATH: /tmp/build | |
PUB_CACHE: /tmp/.pub-cache | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
path: repository | |
- name: Move to /tmp directory | |
run: mv repository "$BUILD_PATH" | |
- name: Disable rustup auto-self-update | |
run: rustup set auto-self-update disable | |
- name: Setup rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
with: | |
cmdline-tools-version: ${{ env.CMDLINE_TOOLS_VERSION }} | |
# Workaround: https://github.com/android-actions/setup-android/issues/461 | |
- name: Access Android SDK build-tools | |
run: echo "$ANDROID_HOME/build-tools"/*/ | awk -F' ' '{ print $1 }' >> $GITHUB_PATH | |
# Maybe use flutter-version-file, see: https://github.com/subosito/flutter-action | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
cache: true | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
- name: Disable Flutter analytics | |
run: flutter config --no-analytics | |
# Cache the directory | |
- name: Cache directory | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.BUILD_PATH }}/flutter/build | |
# Define a key for the cache, commonly includes the hash of dependencies | |
key: ${{ runner.os }}-flutter-build-${{ hashFiles('**/pubspec.yaml', '**/Cargo.toml') }} | |
# Define a restore key if an exact match is not found | |
restore-keys: | | |
${{ runner.os }}-flutter-build- | |
- name: Build APKs | |
working-directory: ${{ env.BUILD_PATH }} | |
run: | | |
# Remove non-reproducable part of path strings. | |
SEP=$(echo -e "\x1f") | |
export CARGO_ENCODED_RUSTFLAGS="--remap-path-prefix=${HOME}/.cargo=/cargo/" | |
if [ ! -z "$CARGO_HOME" ]; then | |
export CARGO_ENCODED_RUSTFLAGS="$CARGO_ENCODED_RUSTFLAGS${SEP}--remap-path-prefix=${CARGO_HOME}=/cargo/" | |
fi | |
export SOURCE_DATE_EPOCH=1 | |
export ZERO_AR_DATE=1 | |
cd flutter | |
flutter build apk --release --split-per-abi | |
flutter build apk --release | |
- name: Archive mappings | |
working-directory: ${{ env.BUILD_PATH }} | |
run: | | |
mv flutter/build/app/outputs/mapping/{release,mapping} | |
tar -czvf mapping.tar.gz --directory=flutter/build/app/outputs/mapping mapping | |
- name: Sign APKs | |
working-directory: ${{ env.BUILD_PATH }} | |
env: | |
KEYSTORE: ${{ secrets.KEYSTORE }} | |
KEYALIAS: ${{ secrets.KEYALIAS }} | |
KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }} | |
KEYPASS: ${{ secrets.KEYPASS }} | |
run: | | |
echo "$KEYSTORE" | base64 -d - > keystore.p12 | |
for name in armeabi-v7a-release arm64-v8a-release x86_64-release release; do | |
apksigner sign \ | |
--ks ./keystore.p12 \ | |
--ks-key-alias "$KEYALIAS" \ | |
--ks-pass env:KEYSTORE_PASS \ | |
--key-pass env:KEYPASS \ | |
--v1-signing-enabled true \ | |
--v2-signing-enabled true \ | |
--v3-signing-enabled true \ | |
--out "${name}.apk" \ | |
"flutter/build/app/outputs/flutter-apk/app-${name}.apk" | |
done | |
rm keystore.p12 | |
- name: Upload Arifact armeabi-v7a | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: "${{ env.BUILD_PATH }}/armeabi-v7a-release.apk" | |
asset_name: stride-armeabi-v7a.apk | |
override: true | |
tag: ${{ github.ref }} | |
- name: Upload Arifact arm64-v8a | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: "${{ env.BUILD_PATH }}/arm64-v8a-release.apk" | |
asset_name: stride-arm64-v8a.apk | |
override: true | |
tag: ${{ github.ref }} | |
- name: Upload Arifact x86_64 | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: "${{ env.BUILD_PATH }}/x86_64-release.apk" | |
asset_name: stride-x86_64.apk | |
override: true | |
tag: ${{ github.ref }} | |
- name: Upload Arifact Universal | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: "${{ env.BUILD_PATH }}/release.apk" | |
asset_name: stride.apk | |
override: true | |
tag: ${{ github.ref }} | |
- name: Upload Arifact Mapping | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: "${{ env.BUILD_PATH }}/mapping.tar.gz" | |
asset_name: mapping.tar.gz | |
override: true | |
tag: ${{ github.ref }} |