From 1f38ffd3ac94c291a8b46e9b2e61c01da9875fd2 Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Sat, 12 Sep 2026 09:53:42 -0400 Subject: [PATCH] ci(android): publish APK/AAR from the Pi runner Build stays on docker-amd64. Attach artifacts on the Pi so POST /releases does not 422 from amd64 dind. Join v0.1.0 when that release is missing the APK instead of minting patch+1. --- .forgejo/workflows/android-release.yml | 106 ++++++++++++++++--------- README.md | 19 +++-- 2 files changed, 82 insertions(+), 43 deletions(-) diff --git a/.forgejo/workflows/android-release.yml b/.forgejo/workflows/android-release.yml index 6de3ce7..ce98027 100644 --- a/.forgejo/workflows/android-release.yml +++ b/.forgejo/workflows/android-release.yml @@ -7,6 +7,10 @@ name: android-release # toolchain runs in a sibling debian:bookworm container, # the same stdin-tar + docker cp pattern as .forgejo/workflows/ci.yml. # +# Publish is a separate job on the Pi runner (`docker`). POST /releases from +# the amd64 dind egress returns 422 with an empty body (core run 116); +# core's publish job on the Pi (run 135) is the proven path. +# # First automated version with zero tags: v0.1.0. Afterwards, patch+1 from the # latest v*.*.* tag UNLESS that tag's release is missing the Android assets — # then join it (core owns tag creation). Never move or delete a tag. @@ -67,6 +71,11 @@ jobs: android: runs-on: docker-amd64 timeout-minutes: 90 + outputs: + version: ${{ steps.version.outputs.version }} + tag: ${{ steps.version.outputs.tag }} + version_code: ${{ steps.version.outputs.version_code }} + dry_run: ${{ steps.version.outputs.dry_run }} steps: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 @@ -348,31 +357,75 @@ jobs: docker images "$ANDROID_IMAGE" --format '{{.Repository}}:{{.Tag}} {{.Size}}' || true docker system df || true + - name: Upload dist artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: onionwire-android + path: dist/ + if-no-files-found: error + retention-days: 1 + + - name: Scrub keystore + if: always() + run: | + set -euo pipefail + rm -rf "$HOME/.android/onionwire-release.jks" "$HOME/.android/onionwire-release.env" .ci-android + echo "keystore removed from runner" + + publish: + needs: android + # Pi runner, not docker-amd64: POST /releases from amd64 dind returns 422 + # with an empty body (core run 116). This job only curls the Forgejo API. + if: needs.android.result == 'success' && needs.android.outputs.dry_run != 'true' + runs-on: docker + timeout-minutes: 20 + steps: + - name: Checkout CI tooling + uses: https://code.forgejo.org/actions/checkout@v4 + with: + path: .ci-tools + + - name: Download Android dist + uses: https://code.forgejo.org/actions/download-artifact@v3 + with: + path: artifacts + - name: Publish (create-or-join) - id: publish - if: steps.version.outputs.dry_run != 'true' env: FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} EVENT_SHA: ${{ github.sha }} - TAG: ${{ steps.version.outputs.tag }} - VERSION: ${{ steps.version.outputs.version }} + TAG: ${{ needs.android.outputs.tag }} + VERSION: ${{ needs.android.outputs.version }} run: | set -euo pipefail - cd "${GITHUB_WORKSPACE}" : "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is missing}" - apk="dist/onionwire-$VERSION-android-$ONIONWIRE_ANDROID_ABI.apk" - aar="dist/onionwire-sdk-$VERSION.aar" + echo "publish host=$(hostname) arch=$(uname -m) tag=$TAG version=$VERSION" + mkdir -p dist + abi="$ONIONWIRE_ANDROID_ABI" + apk="onionwire-$VERSION-android-$abi.apk" + aar="onionwire-sdk-$VERSION.aar" for f in "$apk" "$apk.sha256" "$aar" "$aar.sha256"; do + src=$(find artifacts -type f -name "$f" -print -quit) + if [ -z "$src" ]; then + echo "missing artifact $f" >&2 + find artifacts -type f >&2 || true + exit 1 + fi + cp "$src" "dist/$f" + done + for f in dist/"$apk" dist/"$apk".sha256 dist/"$aar" dist/"$aar".sha256; do bytes=$(wc -c < "$f") + echo "on disk: $f $bytes bytes" [ "$bytes" -gt 0 ] || { echo "refusing to publish empty $f" >&2; exit 1; } + file "$f" || true done tag_exists=0 i=0 while [ "$i" -lt 6 ]; do code=$(curl -sS --http1.1 -o /tmp/tag.json -w '%{http_code}' \ - -H "Authorization: Bearer $FORGEJO_TOKEN" \ + -H "Authorization: Bearer ${FORGEJO_TOKEN}" \ "$REPO_API/tags/$TAG" || true) if [ "$code" = "200" ]; then tag_exists=1 @@ -384,39 +437,18 @@ jobs: sleep 10 done - created_tag=false if [ "$tag_exists" = "1" ]; then unset TARGET_COMMITISH || true else export TARGET_COMMITISH="$EVENT_SHA" - created_tag=true echo "creating tag $TAG at $TARGET_COMMITISH" fi - echo "created_tag=$created_tag" >> "$GITHUB_OUTPUT" - export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}" - PUB_C=onionwire-android-publish-${{ github.run_id }} - docker rm -f "$PUB_C" >/dev/null 2>&1 || true - docker create --name "$PUB_C" -i \ - -e FORGEJO_TOKEN \ - -e REPO_API \ - -e TARGET_COMMITISH="${TARGET_COMMITISH:-}" \ - -e TAG \ - -w /src \ - "$ANDROID_IMAGE" \ - bash -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src && apt-get update && apt-get install -y --no-install-recommends python3 curl ca-certificates >/dev/null && scripts/publish-release.sh "$TAG" "OnionWire $TAG" scripts/release-body.md dist/onionwire-'"$VERSION"'-android-'"$ONIONWIRE_ANDROID_ABI"'.apk dist/onionwire-'"$VERSION"'-android-'"$ONIONWIRE_ANDROID_ABI"'.apk.sha256 dist/onionwire-sdk-'"$VERSION"'.aar dist/onionwire-sdk-'"$VERSION"'.aar.sha256' - tar czf - \ - --exclude=./target --exclude=./.git --exclude=./.worktrees \ - --exclude=./android/.gradle --exclude=./android/app/build \ - --exclude=./android/sdk/build \ - --exclude=./crates/onionwire-sdk/target \ - . \ - | docker start -a -i "$PUB_C" - docker rm -f "$PUB_C" >/dev/null || true - - - name: Scrub keystore - if: always() - run: | - set -euo pipefail - rm -rf "$HOME/.android/onionwire-release.jks" "$HOME/.android/onionwire-release.env" .ci-android - echo "keystore removed from runner" + echo "publishing $TAG from $REPO_API" + .ci-tools/scripts/publish-release.sh \ + "$TAG" "OnionWire $TAG" \ + .ci-tools/scripts/release-body.md \ + "dist/$apk" \ + "dist/$apk.sha256" \ + "dist/$aar" \ + "dist/$aar.sha256" diff --git a/README.md b/README.md index fc2f559..82aeb2c 100644 --- a/README.md +++ b/README.md @@ -245,19 +245,26 @@ peer and a Linux peer that exchange invites interoperate — one protocol, not t - **APK** — `onionwire--android-arm64-v8a.apk`. Kotlin + Jetpack Compose + Material 3 messenger that depends on the SDK and nothing else. -It is not a WebView, and `src/tui.rs` is untouched. Both are built on a host with -the Android SDK/NDK — the Pi runner is aarch64 Linux and cannot produce an APK: +It is not a WebView, and `src/tui.rs` is untouched. The APK build itself is +amd64-only — the Pi runner is aarch64 Linux and cannot produce an APK. +[`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) +builds on `docker-amd64`, then a second job on the Pi (`docker`) attaches the +APK + AAR (+ `.sha256`) to the same Forgejo tag as the Linux binaries. If that +tag's release already exists and is missing the APK, the workflow **joins** it +instead of minting patch+1. Publish does not run from amd64 dind: `POST /releases` +from that egress returns 422 with an empty body. ```bash # one-time: sdkmanager platform 36 / build-tools 36.0.0 / ndk 28.2.13676358, # rustup target add aarch64-linux-android, cargo install cargo-ndk scripts/build-android-local.sh # -> dist/, with .sha256 files -PUBLISH_TAG=v0.3.0 scripts/build-android-local.sh # + upload to that release +PUBLISH_TAG=v0.1.0 scripts/build-android-local.sh # + upload to that release ``` -Every asset has a matching `.sha256` so `sha256sum -c` works. The APK is -**debug-signed** and is for sideloading, not for Play. Full build notes, the -`minSdk 26` rationale, the 16 KB page-size check and the signing story are in +Every asset has a matching `.sha256` so `sha256sum -c` works. CI signs with the +repo-owned release keystore. A local run without those env vars still +debug-signs for sideload, not Play. Full build notes, the `minSdk 26` +rationale, the 16 KB page-size check and the signing story are in [`android/README.md`](android/README.md). ## Releases (maintainers)