88permissions :
99 contents : write
1010
11+ # Runner strategy:
12+ # - Linux + Android + mipsel: self-hosted (mhrv-hetzner-*, Hetzner
13+ # 8-core / 31 GB Ubuntu 24.04 box with
14+ # Rust, Android SDK+NDK, Docker, all
15+ # cross-compile toolchains pre-installed).
16+ # Two runners registered for parallelism.
17+ # - macOS arm64 + amd64, Windows: GitHub-hosted (we don't self-host those
18+ # OSes; the free minutes on a public repo
19+ # are plenty for those two platforms).
20+ #
21+ # Why self-hosted: GH-hosted 2-core runners were spending ~13 min cold per
22+ # release; on the Hetzner box a cold linux-amd64 build is 1m9s, and warm
23+ # builds with Swatinem/rust-cache are sub-minute. Keeps the toolchain warm,
24+ # and more importantly keeps target/ warm via the rust-cache action.
25+
1126jobs :
1227 build :
1328 strategy :
1429 fail-fast : false
1530 matrix :
1631 include :
17- # Pin to Ubuntu 22.04 (GLIBC 2.35) so the glibc builds run on any
18- # distro that's ≥ Ubuntu 22.04 / Debian 12 / Mint 21 / Fedora 36.
19- # ubuntu-latest points at 24.04 (GLIBC 2.39) which bakes in a
20- # too-new GLIBC symbol requirement and rejects loading on older
21- # distros. For users behind tight internet who literally can't
22- # dist-upgrade, this matters.
32+ # Pin to Ubuntu 22.04 GLIBC target (GLIBC 2.35) so the glibc builds
33+ # load on any distro ≥ Ubuntu 22.04 / Debian 12 / Mint 21 / Fedora 36.
34+ # On self-hosted this is a Rust-side choice (cargo target triple),
35+ # not an OS-of-the-runner choice — the runner itself is Ubuntu 24.04
36+ # (GLIBC 2.39), but we link against the 2.35-era glibc via the
37+ # x86_64-unknown-linux-gnu target triple which pins to the oldest
38+ # GLIBC symbol version rustc is willing to emit. Users behind tight
39+ # internet who can't dist-upgrade keep working.
2340 - target : x86_64-unknown-linux-gnu
24- os : ubuntu-22.04
41+ os : [self-hosted, linux, x64, mhrv-build]
2542 name : mhrv-rs-linux-amd64
2643 - target : aarch64-unknown-linux-gnu
27- os : ubuntu-22.04
44+ os : [self-hosted, linux, x64, mhrv-build]
2845 name : mhrv-rs-linux-arm64
2946 - target : arm-unknown-linux-gnueabihf
30- os : ubuntu-22.04
47+ os : [self-hosted, linux, x64, mhrv-build]
3148 name : mhrv-rs-raspbian-armhf
3249 - target : x86_64-apple-darwin
3350 os : macos-latest
@@ -39,10 +56,10 @@ jobs:
3956 os : windows-latest
4057 name : mhrv-rs-windows-amd64
4158 - target : x86_64-unknown-linux-musl
42- os : ubuntu-latest
59+ os : [self-hosted, linux, x64, mhrv-build]
4360 name : mhrv-rs-linux-musl-amd64
4461 - target : aarch64-unknown-linux-musl
45- os : ubuntu-latest
62+ os : [self-hosted, linux, x64, mhrv-build]
4663 name : mhrv-rs-linux-musl-arm64
4764 # OpenWRT MT7621 (soft-float mipsel 32-bit). Dozens of cheap
4865 # home routers run this chipset and they *specifically* need
5370 # `continue-on-error: true` so a regression here doesn't block
5471 # the rest of the release. Issue #26.
5572 - target : mipsel-unknown-linux-musl
56- os : ubuntu-latest
73+ os : [self-hosted, linux, x64, mhrv-build]
5774 name : mhrv-rs-openwrt-mipsel-softfloat
5875 mipsel_softfloat : true
5976
@@ -74,16 +91,42 @@ jobs:
7491 # errors out with "error: component 'rust-std' for target
7592 # 'mipsel-unknown-linux-musl' is unavailable for download", which
7693 # fails the job before the docker step ever runs.
94+ #
95+ # On self-hosted this action is mostly a no-op: rustup is already
96+ # installed and the standard target triples are pre-added. It
97+ # still verifies the target is present and is cheap enough to keep
98+ # as a safety net.
7799 - uses : dtolnay/rust-toolchain@stable
78100 if : matrix.mipsel_softfloat != true
79101 with :
80102 targets : ${{ matrix.target }}
81103
104+ # Cache target/ + cargo registry across runs — this is the big
105+ # self-hosted speedup. Without it, actions/checkout@v4's default
106+ # `git clean -ffdx` wipes target/ between runs and every build is
107+ # cold. With it, warm builds are sub-minute even for the full
108+ # release profile.
109+ #
110+ # cache-bin: false is MANDATORY on our self-hosted runners. With
111+ # the default (true), rust-cache aggressively prunes $CARGO_HOME/bin
112+ # of binaries it didn't install via `cargo install`, including the
113+ # `rustup` binary that cargo/rustc/etc. are symlinked to. The next
114+ # job then hits "command not found" or a broken-symlink TOML parse
115+ # error from a stale cargo. We want target/ + registry caching, NOT
116+ # bin pruning. rustup is pre-installed on the runners anyway.
117+ - uses : Swatinem/rust-cache@v2
118+ if : matrix.mipsel_softfloat != true
119+ with :
120+ key : ${{ matrix.target }}
121+ cache-bin : " false"
122+
82123 # eframe needs a few system libs on Linux for window management, keyboard,
83- # and OpenGL/X11/Wayland. We install them on the Ubuntu runners regardless
84- # of arch so both CLI-only and UI builds succeed.
124+ # and OpenGL/X11/Wayland. Gated to GitHub-hosted runners only — the
125+ # self-hosted runners pre-install all of these once at setup time, and
126+ # letting multiple parallel matrix jobs race on `sudo apt-get install`
127+ # fights over /var/lib/apt/lists/lock and fails them all.
85128 - name : Install Linux eframe system deps
86- if : runner.os == 'Linux'
129+ if : runner.os == 'Linux' && runner.environment == 'github-hosted'
87130 run : |
88131 sudo apt-get update
89132 sudo apt-get install -y \
@@ -93,16 +136,21 @@ jobs:
93136 libx11-dev \
94137 libgl1-mesa-dev libglib2.0-dev libgtk-3-dev
95138
139+ # Cross-compile toolchains. Same story as above — gated to hosted
140+ # runners; self-hosted has gcc-aarch64-linux-gnu + gcc-arm-linux-gnueabihf
141+ # pre-installed, and the linker entries live in
142+ # /home/ghrunner/cargo-{01,02}/config.toml (seeded once at runner
143+ # setup time, picked up via CARGO_HOME env).
96144 - name : Install aarch64 cross-compile toolchain (Linux only)
97- if : matrix.target == 'aarch64-unknown-linux-gnu'
145+ if : matrix.target == 'aarch64-unknown-linux-gnu' && runner.environment == 'github-hosted'
98146 run : |
99147 sudo apt-get update
100148 sudo apt-get install -y gcc-aarch64-linux-gnu
101149 echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
102150 echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
103151
104152 - name : Install armhf cross-compile toolchain (Linux only)
105- if : matrix.target == 'arm-unknown-linux-gnueabihf'
153+ if : matrix.target == 'arm-unknown-linux-gnueabihf' && runner.environment == 'github-hosted'
106154 run : |
107155 sudo apt-get update
108156 sudo apt-get install -y gcc-arm-linux-gnueabihf
@@ -279,38 +327,48 @@ jobs:
279327 # x86_64, x86) via cargo-ndk and drops the .so files into the Gradle
280328 # project's jniLibs/ tree, which then packages them into a single
281329 # universal APK. Users pick it once, no per-ABI split.
330+ #
331+ # Runs on self-hosted. The runner has Android SDK + NDK r26c + cargo-ndk
332+ # pre-installed under /opt/android-sdk; the env block below points Gradle
333+ # at those paths so we don't re-download ~1 GB of SDK per release.
282334 android :
283- runs-on : ubuntu-22.04
335+ runs-on : [self-hosted, linux, x64, mhrv-build]
336+ env :
337+ ANDROID_SDK_ROOT : /opt/android-sdk
338+ ANDROID_HOME : /opt/android-sdk
339+ ANDROID_NDK_HOME : /opt/android-sdk/ndk/26.2.11394342
340+ ANDROID_NDK_ROOT : /opt/android-sdk/ndk/26.2.11394342
341+ JAVA_HOME : /usr/lib/jvm/java-17-openjdk-amd64
284342 steps :
285343 - uses : actions/checkout@v4
286344
287- - name : Set up JDK 17
288- uses : actions/setup-java@v4
289- with :
290- distribution : temurin
291- java-version : 17
292-
293- - name : Set up Android SDK
294- uses : android-actions/setup-android@v3
295- with :
296- cmdline-tools-version : 11076708
297-
298- - name : Install NDK
299- run : |
300- yes | sdkmanager --install "ndk;26.1.10909125" >/dev/null
301- echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125" >> "$GITHUB_ENV"
302-
345+ # Rust toolchain: idempotent on self-hosted (targets already present),
346+ # kept here so the workflow still works if we ever run it on a GH-hosted
347+ # fallback.
303348 - uses : dtolnay/rust-toolchain@stable
304349 with :
305350 targets : aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android
306351
307- - name : Install cargo-ndk
308- run : cargo install cargo-ndk --locked
352+ # Cache cargo + target/ across Android release builds. Four cargo-ndk
353+ # release builds back-to-back with LTO is where the cold cost comes
354+ # from; rust-cache brings warm runs down to ~3–4 min from ~9 min cold.
355+ # cache-bin: false — see the rationale on the matrix build job above.
356+ # On top of that, `cargo-ndk` lives in /usr/local/bin/ on our runners
357+ # (not $CARGO_HOME/bin), specifically so rust-cache's default bin
358+ # pruning can't delete it.
359+ - uses : Swatinem/rust-cache@v2
360+ with :
361+ key : android-universal
362+ cache-bin : " false"
363+ # cargo-ndk writes into `target/<android-triple>/release/`, all
364+ # four of which we want to cache.
365+ workspaces : |
366+ . -> target
309367
310368 # `./gradlew :app:assembleRelease` triggers cargoBuildRelease first
311369 # which invokes cargo-ndk with all four targets, then Gradle packages
312- # the APK (release buildType signed with the debug keystore — see
313- # android/app/build.gradle.kts comment explaining why).
370+ # the APK (release buildType signed with the committed release.jks —
371+ # see android/app/build.gradle.kts comment explaining why).
314372 - name : Build release APK
315373 working-directory : android
316374 run : |
@@ -339,6 +397,11 @@ jobs:
339397 path : dist/*.apk
340398 if-no-files-found : error
341399
400+ # release + telegram: lightweight aggregation jobs kept on GH-hosted
401+ # ubuntu-latest. They only download artifacts and call APIs — no build
402+ # tooling needed, no benefit from moving to self-hosted, and keeping them
403+ # off the self-hosted runners avoids contention with Linux build jobs from
404+ # the next tag if two releases overlap.
342405 release :
343406 needs : [build, android]
344407 runs-on : ubuntu-latest
@@ -402,6 +465,7 @@ jobs:
402465 env :
403466 BOT_TOKEN : ${{ secrets.TELEGRAM_BOT_TOKEN }}
404467 CHAT_ID : ${{ secrets.TELEGRAM_CHAT_ID }}
468+ INCLUDE_CHANGELOG : ${{ vars.TELEGRAM_INCLUDE_CHANGELOG }}
405469 # Python over curl/bash so we don't have to fight curl's -F
406470 # value-interpretation rules. curl treats `-F "caption=<..."`
407471 # as "read the caption from file named ..." when the value
@@ -424,8 +488,18 @@ jobs:
424488 exit 1
425489 fi
426490
491+ # --with-changelog is opt-in. Default post is just the APK
492+ # plus a short caption with the SHA-256, repo URL, and release
493+ # URL — no long body. To include the Persian/English bullets
494+ # for a specific tag, set the repo variable
495+ # TELEGRAM_INCLUDE_CHANGELOG=true before pushing that tag.
496+ INCLUDE_CHANGELOG_FLAG=""
497+ if [ "${INCLUDE_CHANGELOG:-}" = "true" ]; then
498+ INCLUDE_CHANGELOG_FLAG="--with-changelog"
499+ fi
427500 python3 .github/scripts/telegram_release_notify.py \
428501 --apk "$APK" \
429502 --version "$VER" \
430503 --repo "$GITHUB_REPOSITORY" \
431- --changelog "docs/changelog/v${VER}.md"
504+ --changelog "docs/changelog/v${VER}.md" \
505+ $INCLUDE_CHANGELOG_FLAG
0 commit comments