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.
This commit is contained in:
parent
e6e2a158a8
commit
601eb35c4b
2 changed files with 82 additions and 43 deletions
|
|
@ -7,6 +7,10 @@ name: android-release
|
||||||
# toolchain runs in a sibling debian: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.
|
||||||
#
|
#
|
||||||
|
# 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
|
# 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 —
|
# 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.
|
# then join it (core owns tag creation). Never move or delete a tag.
|
||||||
|
|
@ -67,6 +71,11 @@ jobs:
|
||||||
android:
|
android:
|
||||||
runs-on: docker-amd64
|
runs-on: docker-amd64
|
||||||
timeout-minutes: 90
|
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:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
|
|
@ -348,31 +357,75 @@ jobs:
|
||||||
docker images "$ANDROID_IMAGE" --format '{{.Repository}}:{{.Tag}} {{.Size}}' || true
|
docker images "$ANDROID_IMAGE" --format '{{.Repository}}:{{.Tag}} {{.Size}}' || true
|
||||||
docker system df || 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)
|
- name: Publish (create-or-join)
|
||||||
id: publish
|
|
||||||
if: steps.version.outputs.dry_run != 'true'
|
|
||||||
env:
|
env:
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||||
EVENT_SHA: ${{ github.sha }}
|
EVENT_SHA: ${{ github.sha }}
|
||||||
TAG: ${{ steps.version.outputs.tag }}
|
TAG: ${{ needs.android.outputs.tag }}
|
||||||
VERSION: ${{ steps.version.outputs.version }}
|
VERSION: ${{ needs.android.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "${GITHUB_WORKSPACE}"
|
|
||||||
: "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is missing}"
|
: "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is missing}"
|
||||||
apk="dist/onionwire-$VERSION-android-$ONIONWIRE_ANDROID_ABI.apk"
|
echo "publish host=$(hostname) arch=$(uname -m) tag=$TAG version=$VERSION"
|
||||||
aar="dist/onionwire-sdk-$VERSION.aar"
|
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
|
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")
|
bytes=$(wc -c < "$f")
|
||||||
|
echo "on disk: $f $bytes bytes"
|
||||||
[ "$bytes" -gt 0 ] || { echo "refusing to publish empty $f" >&2; exit 1; }
|
[ "$bytes" -gt 0 ] || { echo "refusing to publish empty $f" >&2; exit 1; }
|
||||||
|
file "$f" || true
|
||||||
done
|
done
|
||||||
|
|
||||||
tag_exists=0
|
tag_exists=0
|
||||||
i=0
|
i=0
|
||||||
while [ "$i" -lt 6 ]; do
|
while [ "$i" -lt 6 ]; do
|
||||||
code=$(curl -sS --http1.1 -o /tmp/tag.json -w '%{http_code}' \
|
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)
|
"$REPO_API/tags/$TAG" || true)
|
||||||
if [ "$code" = "200" ]; then
|
if [ "$code" = "200" ]; then
|
||||||
tag_exists=1
|
tag_exists=1
|
||||||
|
|
@ -384,39 +437,18 @@ jobs:
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
|
|
||||||
created_tag=false
|
|
||||||
if [ "$tag_exists" = "1" ]; then
|
if [ "$tag_exists" = "1" ]; then
|
||||||
unset TARGET_COMMITISH || true
|
unset TARGET_COMMITISH || true
|
||||||
else
|
else
|
||||||
export TARGET_COMMITISH="$EVENT_SHA"
|
export TARGET_COMMITISH="$EVENT_SHA"
|
||||||
created_tag=true
|
|
||||||
echo "creating tag $TAG at $TARGET_COMMITISH"
|
echo "creating tag $TAG at $TARGET_COMMITISH"
|
||||||
fi
|
fi
|
||||||
echo "created_tag=$created_tag" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}"
|
echo "publishing $TAG from $REPO_API"
|
||||||
PUB_C=onionwire-android-publish-${{ github.run_id }}
|
.ci-tools/scripts/publish-release.sh \
|
||||||
docker rm -f "$PUB_C" >/dev/null 2>&1 || true
|
"$TAG" "OnionWire $TAG" \
|
||||||
docker create --name "$PUB_C" -i \
|
.ci-tools/scripts/release-body.md \
|
||||||
-e FORGEJO_TOKEN \
|
"dist/$apk" \
|
||||||
-e REPO_API \
|
"dist/$apk.sha256" \
|
||||||
-e TARGET_COMMITISH="${TARGET_COMMITISH:-}" \
|
"dist/$aar" \
|
||||||
-e TAG \
|
"dist/$aar.sha256"
|
||||||
-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"
|
|
||||||
|
|
|
||||||
19
README.md
19
README.md
|
|
@ -245,19 +245,26 @@ peer and a Linux peer that exchange invites interoperate — one protocol, not t
|
||||||
- **APK** — `onionwire-<version>-android-arm64-v8a.apk`. Kotlin + Jetpack
|
- **APK** — `onionwire-<version>-android-arm64-v8a.apk`. Kotlin + Jetpack
|
||||||
Compose + Material 3 messenger that depends on the SDK and nothing else.
|
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
|
It is not a WebView, and `src/tui.rs` is untouched. The APK build itself is
|
||||||
the Android SDK/NDK — the Pi runner is aarch64 Linux and cannot produce an APK:
|
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
|
```bash
|
||||||
# one-time: sdkmanager platform 36 / build-tools 36.0.0 / ndk 28.2.13676358,
|
# one-time: sdkmanager platform 36 / build-tools 36.0.0 / ndk 28.2.13676358,
|
||||||
# rustup target add aarch64-linux-android, cargo install cargo-ndk
|
# rustup target add aarch64-linux-android, cargo install cargo-ndk
|
||||||
scripts/build-android-local.sh # -> dist/, with .sha256 files
|
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
|
Every asset has a matching `.sha256` so `sha256sum -c` works. CI signs with the
|
||||||
**debug-signed** and is for sideloading, not for Play. Full build notes, the
|
repo-owned release keystore. A local run without those env vars still
|
||||||
`minSdk 26` rationale, the 16 KB page-size check and the signing story are in
|
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).
|
[`android/README.md`](android/README.md).
|
||||||
|
|
||||||
## Releases (maintainers)
|
## Releases (maintainers)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue