Skip to content

Commit 2584f07

Browse files
committed
Simplify release workflow
1 parent 98fa7e7 commit 2584f07

4 files changed

Lines changed: 62 additions & 95 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ env:
1010
# https://github.com/android-actions/setup-android?tab=readme-ov-file#sdk-version-selection
1111
CMDLINE_TOOLS_VERSION: 10406996 # 11.0
1212

13-
# Pin build path for reproducible builds.
14-
BUILD_PATH: /tmp/build
15-
PUB_CACHE: /tmp/.pub-cache
16-
1713
permissions:
1814
contents: write
1915

@@ -26,18 +22,10 @@ jobs:
2622
steps:
2723
- name: Checkout 🛎️
2824
uses: actions/checkout@v4
29-
with:
30-
path: repository
31-
32-
- name: Move to /tmp directory
33-
run: mv repository "$BUILD_PATH"
3425

3526
- name: Disable rustup auto-self-update
3627
run: rustup set auto-self-update disable
3728

38-
- name: Setup rust cache
39-
uses: Swatinem/rust-cache@v2
40-
4129
- name: Setup JDK
4230
uses: actions/setup-java@v4
4331
with:
@@ -53,42 +41,19 @@ jobs:
5341
- name: Access Android SDK build-tools
5442
run: echo "$ANDROID_HOME/build-tools"/*/ | awk -F' ' '{ print $1 }' >> $GITHUB_PATH
5543

56-
# Cache the directory
57-
- name: Cache directory
58-
uses: actions/cache@v3
59-
with:
60-
path: ${{ env.BUILD_PATH }}/app/build
61-
# Define a key for the cache, commonly includes the hash of dependencies
62-
key: ${{ runner.os }}-app-build-${{ hashFiles('**/pubspec.yaml') }}
63-
# Define a restore key if an exact match is not found
64-
restore-keys: |
65-
${{ runner.os }}-app-build-
66-
6744
- name: Build APKs
68-
working-directory: ${{ env.BUILD_PATH }}
6945
run: |
70-
# Remove non-reproducable part of path strings.
71-
SEP=$(echo -e "\x1f")
72-
export CARGO_ENCODED_RUSTFLAGS="--remap-path-prefix=${HOME}/.cargo=/cargo/"
73-
if [ ! -z "$CARGO_HOME" ]; then
74-
export CARGO_ENCODED_RUSTFLAGS="$CARGO_ENCODED_RUSTFLAGS${SEP}--remap-path-prefix=${CARGO_HOME}=/cargo/"
75-
fi
76-
77-
export SOURCE_DATE_EPOCH=1
78-
export ZERO_AR_DATE=1
79-
80-
cd app
81-
./flutter build apk --release --split-per-abi
82-
./flutter build apk --release
46+
# Use the same build dir, this speeds up the build process
47+
export REUSE_BUILD=1
48+
./scripts/reproducible apk --release --split-per-abi
49+
./scripts/reproducible apk --release
8350
8451
- name: Archive mappings
85-
working-directory: ${{ env.BUILD_PATH }}
8652
run: |
87-
mv app/build/app/outputs/mapping/{release,mapping}
88-
tar -czvf mapping.tar.gz --directory=app/build/app/outputs/mapping mapping
53+
mv app/build/reproducible/mapping/{release,mapping}
54+
tar -czvf mapping.tar.gz --directory=app/build/reproducible/mapping mapping
8955
9056
- name: Sign APKs
91-
working-directory: ${{ env.BUILD_PATH }}
9257
env:
9358
KEYSTORE: ${{ secrets.KEYSTORE }}
9459
KEYALIAS: ${{ secrets.KEYALIAS }}
@@ -105,52 +70,47 @@ jobs:
10570
--v1-signing-enabled true \
10671
--v2-signing-enabled true \
10772
--v3-signing-enabled true \
108-
--out "${name}.apk" \
109-
"app/build/app/outputs/flutter-apk/app-${name}.apk"
73+
--out "app-${name}.apk" \
74+
"app/build/reproducible/flutter-apk/app-${name}.apk"
11075
done
11176
rm keystore.p12
11277
11378
- name: Upload Arifact armeabi-v7a
11479
uses: svenstaro/upload-release-action@v2
11580
with:
11681
repo_token: ${{ secrets.GITHUB_TOKEN }}
117-
file: "${{ env.BUILD_PATH }}/armeabi-v7a-release.apk"
82+
file: "app-armeabi-v7a-release.apk"
11883
asset_name: stride-armeabi-v7a.apk
119-
override: true
12084
tag: ${{ github.ref }}
12185

12286
- name: Upload Arifact arm64-v8a
12387
uses: svenstaro/upload-release-action@v2
12488
with:
12589
repo_token: ${{ secrets.GITHUB_TOKEN }}
126-
file: "${{ env.BUILD_PATH }}/arm64-v8a-release.apk"
90+
file: "app-arm64-v8a-release.apk"
12791
asset_name: stride-arm64-v8a.apk
128-
override: true
12992
tag: ${{ github.ref }}
13093

13194
- name: Upload Arifact x86_64
13295
uses: svenstaro/upload-release-action@v2
13396
with:
13497
repo_token: ${{ secrets.GITHUB_TOKEN }}
135-
file: "${{ env.BUILD_PATH }}/x86_64-release.apk"
98+
file: "app-x86_64-release.apk"
13699
asset_name: stride-x86_64.apk
137-
override: true
138100
tag: ${{ github.ref }}
139101

140102
- name: Upload Arifact Universal
141103
uses: svenstaro/upload-release-action@v2
142104
with:
143105
repo_token: ${{ secrets.GITHUB_TOKEN }}
144-
file: "${{ env.BUILD_PATH }}/release.apk"
106+
file: "app-release.apk"
145107
asset_name: stride.apk
146-
override: true
147108
tag: ${{ github.ref }}
148109

149110
- name: Upload Arifact Mapping
150111
uses: svenstaro/upload-release-action@v2
151112
with:
152113
repo_token: ${{ secrets.GITHUB_TOKEN }}
153-
file: "${{ env.BUILD_PATH }}/mapping.tar.gz"
114+
file: "mapping.tar.gz"
154115
asset_name: mapping.tar.gz
155-
override: true
156116
tag: ${{ github.ref }}

app/flutter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VERSION=3.24.0
55
APP_DIR="$( cd "$( dirname "$0" )" && pwd )"
66
FLUTTER_DIR="$APP_DIR/.flutter"
77

8+
cd "$APP_DIR"
9+
810
if [ -e "$FLUTTER_DIR" ]; then
911
exec "$FLUTTER_DIR"/bin/flutter $@
1012
fi

app/scripts/reproducible

Lines changed: 0 additions & 42 deletions
This file was deleted.

scripts/reproducible

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
SCRIPTS_DIR="$( cd "$( dirname "$0" )" && pwd )"
6+
PROJECT_DIR="$SCRIPTS_DIR/.."
7+
8+
APPLICATION_ID="org.stridetasks.stride"
9+
BUILD_DIR="/tmp/$APPLICATION_ID"
10+
11+
cd "$PROJECT_DIR"
12+
13+
# Remove non-reproducable part of path strings.
14+
SEP=$(echo -e "\x1f")
15+
export CARGO_ENCODED_RUSTFLAGS="--remap-path-prefix=${HOME}/.cargo=/cargo/"
16+
if [ ! -z "$CARGO_HOME" ]; then
17+
export CARGO_ENCODED_RUSTFLAGS="$CARGO_ENCODED_RUSTFLAGS${SEP}--remap-path-prefix=${CARGO_HOME}=/cargo/"
18+
fi
19+
20+
export SOURCE_DATE_EPOCH=1
21+
export ZERO_AR_DATE=1
22+
23+
set -xe
24+
25+
# In CI reuse the same build folder, since we are building the same commit
26+
# this should be fine.
27+
if [ -z "$REUSE_BUILD" ]; then
28+
rm -rf "$BUILD_DIR"
29+
else
30+
echo "INFO: Reusing existing build directory $BUILD_DIR"
31+
fi
32+
33+
if [ ! -e "$BUILD_DIR" ]; then
34+
COMMIT="$(git rev-parse HEAD)"
35+
ORIGIN="$(git remote get-url origin)"
36+
git clone --filter=blob:none --reference-if-able "$PROJECT_DIR" "$ORIGIN" "$BUILD_DIR"
37+
git -C "$BUILD_DIR" reset --hard "$COMMIT"
38+
fi
39+
40+
cd "$BUILD_DIR"
41+
42+
./scripts/rustup-setup
43+
./app/flutter build $@
44+
45+
rm -rf "$PROJECT_DIR"/app/reproducible/apks
46+
mkdir -p "$PROJECT_DIR"/app/build/reproducible
47+
cp -r app/build/app/outputs/* "$PROJECT_DIR"/app/build/reproducible

0 commit comments

Comments
 (0)