fix(ci): Android APK build in debian:bookworm sibling container #30
3 changed files with 56 additions and 40 deletions
|
|
@ -4,19 +4,23 @@ name: android-release
|
||||||
# Forgejo release for the computed (or requested) tag.
|
# Forgejo release for the computed (or requested) tag.
|
||||||
#
|
#
|
||||||
# The runner job image is node:20-bullseye (EOL). Do not apt-get there.
|
# The runner job image is node:20-bullseye (EOL). Do not apt-get there.
|
||||||
# The toolchain runs in a sibling eclipse-temurin:17-jdk-bookworm container,
|
# toolchain runs in a sibling debian:bookworm container,
|
||||||
# the same stdin-tar + docker cp pattern as .forgejo/workflows/ci.yml.
|
# the same stdin-tar + docker cp pattern as .forgejo/workflows/ci.yml.
|
||||||
#
|
#
|
||||||
# First automated version with zero tags: v0.1.0. Afterwards, patch+1 from the
|
# First automated version with zero tags: v0.1.0. Afterwards, patch+1 from the
|
||||||
# latest v*.*.* tag. Never move an existing tag. If this workflow creates a
|
# latest v*.*.* tag UNLESS that tag's release is missing the Android assets —
|
||||||
# tag and then fails, it deletes that tag so the next run retries the same
|
# then join it (core owns tag creation). Never move or delete a tag.
|
||||||
# version instead of skipping.
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- "android/**"
|
- "android/app/**"
|
||||||
|
- "android/sdk/**"
|
||||||
|
- "android/*.gradle.kts"
|
||||||
|
- "android/gradle/**"
|
||||||
|
- "android/gradle.properties"
|
||||||
|
- "android/settings.gradle.kts"
|
||||||
- "scripts/build-android-local.sh"
|
- "scripts/build-android-local.sh"
|
||||||
- ".forgejo/workflows/android-release.yml"
|
- ".forgejo/workflows/android-release.yml"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
@ -41,7 +45,7 @@ on:
|
||||||
default: "false"
|
default: "false"
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: onionwire-android-release
|
group: onionwire-android-release-v2
|
||||||
cancel-in-progress: false
|
cancel-in-progress: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
@ -49,7 +53,7 @@ env:
|
||||||
CARGO_BUILD_JOBS: "1"
|
CARGO_BUILD_JOBS: "1"
|
||||||
ONIONWIRE_ANDROID_ABI: arm64-v8a
|
ONIONWIRE_ANDROID_ABI: arm64-v8a
|
||||||
ONIONWIRE_REQUIRE_RELEASE_KEY: "true"
|
ONIONWIRE_REQUIRE_RELEASE_KEY: "true"
|
||||||
ANDROID_IMAGE: eclipse-temurin:17-jdk-bookworm
|
ANDROID_IMAGE: debian:bookworm
|
||||||
ANDROID_CMDLINE_TOOLS_URL: https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
|
ANDROID_CMDLINE_TOOLS_URL: https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
|
||||||
RUST_TOOLCHAIN: "1.91"
|
RUST_TOOLCHAIN: "1.91"
|
||||||
DOCKER_STATIC_URL: https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz
|
DOCKER_STATIC_URL: https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz
|
||||||
|
|
@ -86,6 +90,8 @@ jobs:
|
||||||
INPUT_TAG: ${{ github.event.inputs.tag || inputs.tag }}
|
INPUT_TAG: ${{ github.event.inputs.tag || inputs.tag }}
|
||||||
INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }}
|
INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }}
|
||||||
CALL_DRY_RUN: ${{ inputs.dry_run }}
|
CALL_DRY_RUN: ${{ inputs.dry_run }}
|
||||||
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "${GITHUB_WORKSPACE}"
|
cd "${GITHUB_WORKSPACE}"
|
||||||
|
|
@ -102,13 +108,37 @@ jobs:
|
||||||
if [ -z "$latest" ]; then
|
if [ -z "$latest" ]; then
|
||||||
ver="0.1.0"
|
ver="0.1.0"
|
||||||
else
|
else
|
||||||
ver="${latest#v}"
|
# Core owns tag creation. If the latest tag's release is missing
|
||||||
major="${ver%%.*}"
|
# the Android APK, join that version instead of minting patch+1.
|
||||||
rest="${ver#*.}"
|
join=0
|
||||||
minor="${rest%%.*}"
|
if [ -n "${FORGEJO_TOKEN:-}" ]; then
|
||||||
patch="${rest#*.}"
|
http=$(curl -sS --http1.1 -o /tmp/latest-rel.json -w '%{http_code}' \
|
||||||
patch=$((patch + 1))
|
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||||
ver="${major}.${minor}.${patch}"
|
"$REPO_API/releases/tags/$latest" || true)
|
||||||
|
if [ "$http" != "200" ]; then
|
||||||
|
join=1
|
||||||
|
echo "latest tag $latest has no release (http $http); joining"
|
||||||
|
elif node -e 'const d=require("/tmp/latest-rel.json"); const n=(d.assets||[]).some(a=>/onionwire-.*-android-.*\\.apk$/.test(a.name)); process.exit(n?0:1)'; then
|
||||||
|
echo "latest tag $latest already has an Android APK; patch+1"
|
||||||
|
else
|
||||||
|
join=1
|
||||||
|
echo "latest tag $latest release is missing Android APK; joining"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "FORGEJO_TOKEN unset; cannot inspect release assets, joining $latest"
|
||||||
|
join=1
|
||||||
|
fi
|
||||||
|
if [ "$join" = "1" ]; then
|
||||||
|
ver="${latest#v}"
|
||||||
|
else
|
||||||
|
ver="${latest#v}"
|
||||||
|
major="${ver%%.*}"
|
||||||
|
rest="${ver#*.}"
|
||||||
|
minor="${rest%%.*}"
|
||||||
|
patch="${rest#*.}"
|
||||||
|
patch=$((patch + 1))
|
||||||
|
ver="${major}.${minor}.${patch}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || {
|
echo "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || {
|
||||||
|
|
@ -185,7 +215,7 @@ jobs:
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
python3 unzip curl ca-certificates file build-essential pkg-config git
|
openjdk-17-jdk-headless python3 unzip curl ca-certificates file build-essential pkg-config git
|
||||||
mkdir -p /root/.android
|
mkdir -p /root/.android
|
||||||
cp /src/.ci-android/onionwire-release.jks /root/.android/onionwire-release.jks
|
cp /src/.ci-android/onionwire-release.jks /root/.android/onionwire-release.jks
|
||||||
cp /src/.ci-android/onionwire-release.env /root/.android/onionwire-release.env
|
cp /src/.ci-android/onionwire-release.env /root/.android/onionwire-release.env
|
||||||
|
|
@ -238,7 +268,7 @@ jobs:
|
||||||
echo "=== apksigner ==="
|
echo "=== apksigner ==="
|
||||||
apksigner verify --print-certs "$apk"
|
apksigner verify --print-certs "$apk"
|
||||||
echo "=== aapt ==="
|
echo "=== aapt ==="
|
||||||
aapt dump badging "$apk" | head -n 20
|
aapt dump badging "$apk" | sed -n '1,20p' || true
|
||||||
echo "=== sizes ==="
|
echo "=== sizes ==="
|
||||||
wc -c "$apk" "$aar"
|
wc -c "$apk" "$aar"
|
||||||
} | tee dist/ci-verify.log
|
} | tee dist/ci-verify.log
|
||||||
|
|
@ -384,27 +414,6 @@ jobs:
|
||||||
| docker start -a -i "$PUB_C"
|
| docker start -a -i "$PUB_C"
|
||||||
docker rm -f "$PUB_C" >/dev/null || true
|
docker rm -f "$PUB_C" >/dev/null || true
|
||||||
|
|
||||||
- name: Drop dangling tag on failure
|
|
||||||
if: failure() && steps.version.outputs.dry_run != 'true' && steps.publish.outputs.created_tag == 'true'
|
|
||||||
env:
|
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
|
||||||
TAG: ${{ steps.version.outputs.tag }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
: "${FORGEJO_TOKEN:?}"
|
|
||||||
echo "build/publish failed after creating $TAG; deleting so the next run retries this version"
|
|
||||||
curl -sS --http1.1 -X DELETE \
|
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/git/tags/$TAG" || true
|
|
||||||
curl -sS --http1.1 -X DELETE \
|
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/tags/$TAG" || true
|
|
||||||
code=$(curl -sS --http1.1 -o /tmp/tag-after.json -w '%{http_code}' \
|
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/tags/$TAG" || true)
|
|
||||||
echo "GET tags/$TAG after delete -> $code"
|
|
||||||
|
|
||||||
- name: Scrub keystore
|
- name: Scrub keystore
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -123,9 +123,10 @@ deobfuscation, not before.
|
||||||
|
|
||||||
`.forgejo/workflows/android-release.yml` runs on `docker-amd64` (T480 dind).
|
`.forgejo/workflows/android-release.yml` runs on `docker-amd64` (T480 dind).
|
||||||
The job image is `node:20-bullseye` (EOL) — **do not apt-get there**. The
|
The job image is `node:20-bullseye` (EOL) — **do not apt-get there**. The
|
||||||
toolchain runs in a sibling `eclipse-temurin:17-jdk-bookworm` container
|
toolchain runs in a sibling `debian:bookworm` container
|
||||||
(stdin-tar + `docker cp`, same pattern as the Rust CI job).
|
(stdin-tar + `docker cp`, same pattern as the Rust CI job).
|
||||||
Any push to `main` that touches `android/**` (or the local build script / this
|
Any push to `main` that touches Android **sources or build config**
|
||||||
|
(`android/app/**`, `android/sdk/**`, Gradle files — not `android/README.md`)
|
||||||
workflow) builds `onionwire-<version>-android-arm64-v8a.apk` and
|
workflow) builds `onionwire-<version>-android-arm64-v8a.apk` and
|
||||||
`onionwire-sdk-<version>.aar`, verifies them, and attaches them to the Forgejo
|
`onionwire-sdk-<version>.aar`, verifies them, and attaches them to the Forgejo
|
||||||
release for that tag. Version is the latest `v*.*.*` tag plus patch, or
|
release for that tag. Version is the latest `v*.*.*` tag plus patch, or
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,12 @@ val onionwireAbis: List<String> = (findProperty("onionwire.abis") as String?)
|
||||||
val jniLibsDir = layout.buildDirectory.dir("rustJniLibs")
|
val jniLibsDir = layout.buildDirectory.dir("rustJniLibs")
|
||||||
val uniffiKotlinDir = layout.buildDirectory.dir("generated/uniffi")
|
val uniffiKotlinDir = layout.buildDirectory.dir("generated/uniffi")
|
||||||
|
|
||||||
|
// cargo honors CARGO_TARGET_DIR when set (CI sibling container). UniFFI's
|
||||||
|
// --library path must match, or bindgen dies with ENOENT after a green compile.
|
||||||
|
val cargoTargetDir: File = System.getenv("CARGO_TARGET_DIR")?.let(::File)
|
||||||
|
?: sdkCrateDir.resolve("target")
|
||||||
|
val hostCdylib: File = cargoTargetDir.resolve("release/libonionwire_sdk.so")
|
||||||
|
|
||||||
/** Host cdylib. UniFFI's `--library` mode dlopens it, so it must be host-arch. */
|
/** Host cdylib. UniFFI's `--library` mode dlopens it, so it must be host-arch. */
|
||||||
val cargoHostLib by tasks.registering(Exec::class) {
|
val cargoHostLib by tasks.registering(Exec::class) {
|
||||||
group = "onionwire"
|
group = "onionwire"
|
||||||
|
|
@ -76,7 +82,7 @@ val uniffiBindgen by tasks.registering(Exec::class) {
|
||||||
commandLine(
|
commandLine(
|
||||||
cargoExe, "run", "--release", "--bin", "uniffi-bindgen", "--",
|
cargoExe, "run", "--release", "--bin", "uniffi-bindgen", "--",
|
||||||
"generate",
|
"generate",
|
||||||
"--library", "target/release/libonionwire_sdk.so",
|
"--library", hostCdylib.absolutePath,
|
||||||
"--language", "kotlin",
|
"--language", "kotlin",
|
||||||
"--no-format",
|
"--no-format",
|
||||||
"--config", "uniffi.toml",
|
"--config", "uniffi.toml",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue