Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55eab832d0 |
7 changed files with 175 additions and 531 deletions
|
|
@ -1,16 +1,11 @@
|
||||||
name: android-release
|
name: android-release
|
||||||
|
|
||||||
# Build the Android APK + SDK AAR on docker-amd64 and attach them to the
|
# Build the Android APK + SDK AAR on the amd64 runner and attach them to the
|
||||||
# Forgejo release for the computed (or requested) tag.
|
# Forgejo release for the computed (or requested) tag. Standalone on push to
|
||||||
#
|
# main, dispatch, or as a reusable workflow.
|
||||||
# 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,
|
|
||||||
# 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. Never move an existing tag.
|
||||||
# tag and then fails, it deletes that tag so the next run retries the same
|
|
||||||
# version instead of skipping.
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -49,15 +44,10 @@ 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
|
# The dind pod is capped at 4Gi. Keep Gradle small or the job is 137.
|
||||||
|
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=-Xmx1024m -XX:MaxMetaspaceSize=384m -Dfile.encoding=UTF-8"
|
||||||
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
|
|
||||||
BUILD_CONTAINER: onionwire-android-${{ github.run_id }}
|
|
||||||
SDK_VOLUME: onionwire-android-sdk
|
|
||||||
CARGO_VOLUME: onionwire-android-cargo-registry
|
|
||||||
TARGET_VOLUME: onionwire-android-target
|
|
||||||
GRADLE_VOLUME: onionwire-android-gradle
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
android:
|
android:
|
||||||
|
|
@ -68,17 +58,16 @@ jobs:
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.inputs.tag || inputs.tag || github.sha }}
|
ref: ${{ inputs.tag || github.event.inputs.tag || github.sha }}
|
||||||
|
|
||||||
- name: Record runner resources
|
- name: Record runner resources
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "${GITHUB_WORKSPACE}"
|
cd "${GITHUB_WORKSPACE}"
|
||||||
echo "workspace=$GITHUB_WORKSPACE hostname=$(hostname) arch=$(uname -m)"
|
echo "workspace=$GITHUB_WORKSPACE hostname=$(hostname) arch=$(uname -m)"
|
||||||
nproc || true
|
nproc
|
||||||
free -h || true
|
free -h || true
|
||||||
df -h || true
|
df -h || true
|
||||||
ls -l /var/run/docker.sock || true
|
|
||||||
|
|
||||||
- name: Compute version
|
- name: Compute version
|
||||||
id: version
|
id: version
|
||||||
|
|
@ -129,6 +118,65 @@ jobs:
|
||||||
} >> "$GITHUB_OUTPUT"
|
} >> "$GITHUB_OUTPUT"
|
||||||
echo "version=$ver tag=$tag versionCode=$code dry_run=$dry_run"
|
echo "version=$ver tag=$tag versionCode=$code dry_run=$dry_run"
|
||||||
|
|
||||||
|
- name: Install JDK, Rust, Android SDK, cargo-ndk
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cd "${GITHUB_WORKSPACE}"
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
# T480 dind timed out on http://deb.debian.org:80 (Fastly). HTTPS works
|
||||||
|
# for Forgejo checkout; flip the debian mirrors before apt-get update.
|
||||||
|
if [ -f /etc/apt/sources.list ]; then
|
||||||
|
sed -i 's|http://deb.debian.org|https://deb.debian.org|g; s|http://security.debian.org|https://security.debian.org|g; s|http://deb.debian.org/debian-security|https://deb.debian.org/debian-security|g' /etc/apt/sources.list
|
||||||
|
fi
|
||||||
|
ls /etc/apt/sources.list.d 2>/dev/null || true
|
||||||
|
cat /etc/apt/sources.list || true
|
||||||
|
apt-get -o Acquire::Retries=3 -o Acquire::https::Timeout=60 -o Acquire::Check-Valid-Until=false update
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
openjdk-17-jdk-headless python3 python3-minimal unzip curl ca-certificates \
|
||||||
|
file build-essential pkg-config git
|
||||||
|
java -version
|
||||||
|
python3 --version
|
||||||
|
|
||||||
|
export ANDROID_HOME="${ANDROID_HOME:-$HOME/android-sdk}"
|
||||||
|
export ANDROID_SDK_ROOT="$ANDROID_HOME"
|
||||||
|
mkdir -p "$ANDROID_HOME/cmdline-tools"
|
||||||
|
curl -fsSL "$ANDROID_CMDLINE_TOOLS_URL" -o /tmp/cmdline-tools.zip
|
||||||
|
rm -rf /tmp/cmdline-tools
|
||||||
|
unzip -q /tmp/cmdline-tools.zip -d /tmp/cmdline-tools
|
||||||
|
mkdir -p "$ANDROID_HOME/cmdline-tools/latest"
|
||||||
|
cp -a /tmp/cmdline-tools/cmdline-tools/. "$ANDROID_HOME/cmdline-tools/latest/"
|
||||||
|
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_HOME" --licenses >/tmp/sdk-licenses.log || true
|
||||||
|
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_HOME" \
|
||||||
|
"platform-tools" "platforms;android-36" "build-tools;36.0.0" "ndk;28.2.13676358"
|
||||||
|
test -d "$ANDROID_HOME/ndk/28.2.13676358"
|
||||||
|
echo "ANDROID_HOME=$ANDROID_HOME"
|
||||||
|
du -sh "$ANDROID_HOME" "$ANDROID_HOME/ndk/28.2.13676358" || true
|
||||||
|
|
||||||
|
if [ ! -x "$HOME/.cargo/bin/rustup" ]; then
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN"
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source "$HOME/.cargo/env"
|
||||||
|
rustup toolchain install "$RUST_TOOLCHAIN"
|
||||||
|
rustup default "$RUST_TOOLCHAIN"
|
||||||
|
rustup target add aarch64-linux-android
|
||||||
|
rustc --version
|
||||||
|
cargo --version
|
||||||
|
cargo install cargo-ndk --locked
|
||||||
|
cargo ndk --version
|
||||||
|
|
||||||
|
echo "ANDROID_HOME=$ANDROID_HOME" >> "$GITHUB_ENV"
|
||||||
|
echo "ANDROID_SDK_ROOT=$ANDROID_HOME" >> "$GITHUB_ENV"
|
||||||
|
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/28.2.13676358" >> "$GITHUB_ENV"
|
||||||
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||||
|
echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> "$GITHUB_PATH"
|
||||||
|
echo "$ANDROID_HOME/platform-tools" >> "$GITHUB_PATH"
|
||||||
|
echo "$ANDROID_HOME/build-tools/36.0.0" >> "$GITHUB_PATH"
|
||||||
|
echo "=== resources after SDK install ==="
|
||||||
|
free -h || true
|
||||||
|
df -h || true
|
||||||
|
du -sh "$HOME/android-sdk" "$HOME/.cargo" 2>/dev/null || true
|
||||||
|
|
||||||
- name: Decode release keystore
|
- name: Decode release keystore
|
||||||
env:
|
env:
|
||||||
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
|
||||||
|
|
@ -151,147 +199,25 @@ jobs:
|
||||||
test -s "$ks"
|
test -s "$ks"
|
||||||
umask 077
|
umask 077
|
||||||
printf 'ANDROID_KEYSTORE_FILE=%s\nANDROID_KEYSTORE_PASSWORD=%s\nANDROID_KEY_ALIAS=%s\nANDROID_KEY_PASSWORD=%s\n' \
|
printf 'ANDROID_KEYSTORE_FILE=%s\nANDROID_KEYSTORE_PASSWORD=%s\nANDROID_KEY_ALIAS=%s\nANDROID_KEY_PASSWORD=%s\n' \
|
||||||
"/root/.android/onionwire-release.jks" "$ANDROID_KEYSTORE_PASSWORD" "$ANDROID_KEY_ALIAS" "$ANDROID_KEY_PASSWORD" > "$envf"
|
"$ks" "$ANDROID_KEYSTORE_PASSWORD" "$ANDROID_KEY_ALIAS" "$ANDROID_KEY_PASSWORD" > "$envf"
|
||||||
chmod 600 "$envf"
|
chmod 600 "$envf"
|
||||||
echo "keystore bytes=$(wc -c < "$ks") staged for the build container"
|
echo "keystore bytes=$(wc -c < "$ks") written under ~/.android (not logged)"
|
||||||
|
|
||||||
- name: Ensure docker CLI
|
- name: Build APK + AAR
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
if ! command -v docker >/dev/null 2>&1; then
|
|
||||||
echo "docker CLI missing in job image; fetching static client"
|
|
||||||
curl -fsSL "$DOCKER_STATIC_URL" -o /tmp/docker.tgz
|
|
||||||
tar -xzf /tmp/docker.tgz -C /tmp
|
|
||||||
install -m 755 /tmp/docker/docker /usr/local/bin/docker
|
|
||||||
fi
|
|
||||||
export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}"
|
|
||||||
docker version
|
|
||||||
docker info >/tmp/docker-info.txt
|
|
||||||
grep -E 'Server Version|Operating System|Total Memory|Name' /tmp/docker-info.txt || true
|
|
||||||
|
|
||||||
- name: Build APK + AAR in bookworm container
|
|
||||||
id: build
|
|
||||||
env:
|
|
||||||
VERSION: ${{ steps.version.outputs.version }}
|
|
||||||
VERSION_CODE: ${{ steps.version.outputs.version_code }}
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "${GITHUB_WORKSPACE}"
|
cd "${GITHUB_WORKSPACE}"
|
||||||
export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}"
|
|
||||||
start=$(date +%s)
|
|
||||||
cat > .ci-android-build.sh <<'INNER'
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
python3 unzip curl ca-certificates file build-essential pkg-config git
|
|
||||||
mkdir -p /root/.android
|
|
||||||
cp /src/.ci-android/onionwire-release.jks /root/.android/onionwire-release.jks
|
|
||||||
cp /src/.ci-android/onionwire-release.env /root/.android/onionwire-release.env
|
|
||||||
chmod 600 /root/.android/onionwire-release.jks /root/.android/onionwire-release.env
|
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
set -a
|
source "$HOME/.cargo/env" 2>/dev/null || true
|
||||||
source /root/.android/onionwire-release.env
|
export ANDROID_HOME="${ANDROID_HOME:?}"
|
||||||
set +a
|
export ANDROID_SDK_ROOT="$ANDROID_HOME"
|
||||||
if [ ! -x /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager ]; then
|
export ANDROID_NDK_HOME="${ANDROID_NDK_HOME:?}"
|
||||||
mkdir -p /opt/android-sdk/cmdline-tools
|
export ONIONWIRE_VERSION_CODE="${{ steps.version.outputs.version_code }}"
|
||||||
curl -fsSL "$ANDROID_CMDLINE_TOOLS_URL" -o /tmp/cmdline-tools.zip
|
export ONIONWIRE_REQUIRE_RELEASE_KEY=true
|
||||||
rm -rf /tmp/cmdline-tools
|
start=$(date +%s)
|
||||||
unzip -q /tmp/cmdline-tools.zip -d /tmp/cmdline-tools
|
scripts/build-android-local.sh "${{ steps.version.outputs.version }}"
|
||||||
mkdir -p /opt/android-sdk/cmdline-tools/latest
|
|
||||||
cp -a /tmp/cmdline-tools/cmdline-tools/. /opt/android-sdk/cmdline-tools/latest/
|
|
||||||
fi
|
|
||||||
yes | /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/opt/android-sdk --licenses >/tmp/sdk-licenses.log || true
|
|
||||||
/opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/opt/android-sdk \
|
|
||||||
"platform-tools" "platforms;android-36" "build-tools;36.0.0" "ndk;28.2.13676358"
|
|
||||||
test -d /opt/android-sdk/ndk/28.2.13676358
|
|
||||||
export ANDROID_HOME=/opt/android-sdk ANDROID_SDK_ROOT=/opt/android-sdk
|
|
||||||
export ANDROID_NDK_HOME=/opt/android-sdk/ndk/28.2.13676358
|
|
||||||
export PATH="$ANDROID_HOME/build-tools/36.0.0:$ANDROID_HOME/platform-tools:$PATH"
|
|
||||||
if [ ! -x /cargo/bin/rustup ]; then
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN" --no-modify-path --profile minimal
|
|
||||||
fi
|
|
||||||
export PATH="/cargo/bin:$PATH"
|
|
||||||
rustup toolchain install "$RUST_TOOLCHAIN"
|
|
||||||
rustup default "$RUST_TOOLCHAIN"
|
|
||||||
rustup target add aarch64-linux-android
|
|
||||||
command -v cargo-ndk >/dev/null || cargo install cargo-ndk --locked
|
|
||||||
echo "=== toolchain ==="
|
|
||||||
java -version
|
|
||||||
rustc --version
|
|
||||||
cargo ndk --version
|
|
||||||
du -sh /opt/android-sdk /cargo /cargo-target /gradle || true
|
|
||||||
scripts/build-android-local.sh "$ONIONWIRE_VERSION"
|
|
||||||
version="$ONIONWIRE_VERSION"
|
|
||||||
abi="${ONIONWIRE_ANDROID_ABI:-arm64-v8a}"
|
|
||||||
apk="dist/onionwire-$version-android-$abi.apk"
|
|
||||||
aar="dist/onionwire-sdk-$version.aar"
|
|
||||||
{
|
|
||||||
echo "=== file ==="
|
|
||||||
file "$apk" "$aar"
|
|
||||||
echo "=== unzip lib ==="
|
|
||||||
unzip -l "$apk" | grep -E 'lib/.+\.so|AndroidManifest.xml' || true
|
|
||||||
unzip -l "$apk" | grep "lib/$abi/libonionwire_sdk.so"
|
|
||||||
echo "=== sha256 ==="
|
|
||||||
( cd dist && sha256sum -c "onionwire-$version-android-$abi.apk.sha256" "onionwire-sdk-$version.aar.sha256" )
|
|
||||||
echo "=== apksigner ==="
|
|
||||||
apksigner verify --print-certs "$apk"
|
|
||||||
echo "=== aapt ==="
|
|
||||||
aapt dump badging "$apk" | head -n 20
|
|
||||||
echo "=== sizes ==="
|
|
||||||
wc -c "$apk" "$aar"
|
|
||||||
} | tee dist/ci-verify.log
|
|
||||||
INNER
|
|
||||||
chmod +x .ci-android-build.sh
|
|
||||||
docker volume create "$SDK_VOLUME" >/dev/null
|
|
||||||
docker volume create "$CARGO_VOLUME" >/dev/null
|
|
||||||
docker volume create "$TARGET_VOLUME" >/dev/null
|
|
||||||
docker volume create "$GRADLE_VOLUME" >/dev/null
|
|
||||||
docker rm -f "$BUILD_CONTAINER" >/dev/null 2>&1 || true
|
|
||||||
docker pull "$ANDROID_IMAGE"
|
|
||||||
docker create --name "$BUILD_CONTAINER" -i \
|
|
||||||
-e CARGO_TERM_COLOR=never \
|
|
||||||
-e CARGO_BUILD_JOBS="$CARGO_BUILD_JOBS" \
|
|
||||||
-e CARGO_HOME=/cargo \
|
|
||||||
-e CARGO_TARGET_DIR=/cargo-target \
|
|
||||||
-e GRADLE_USER_HOME=/gradle \
|
|
||||||
-e ANDROID_HOME=/opt/android-sdk \
|
|
||||||
-e ANDROID_SDK_ROOT=/opt/android-sdk \
|
|
||||||
-e ANDROID_NDK_HOME=/opt/android-sdk/ndk/28.2.13676358 \
|
|
||||||
-e ONIONWIRE_ANDROID_ABI="$ONIONWIRE_ANDROID_ABI" \
|
|
||||||
-e ONIONWIRE_REQUIRE_RELEASE_KEY=true \
|
|
||||||
-e ONIONWIRE_VERSION_CODE="$VERSION_CODE" \
|
|
||||||
-e ONIONWIRE_VERSION="$VERSION" \
|
|
||||||
-e RUST_TOOLCHAIN="$RUST_TOOLCHAIN" \
|
|
||||||
-e ANDROID_CMDLINE_TOOLS_URL="$ANDROID_CMDLINE_TOOLS_URL" \
|
|
||||||
-e GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=-Xmx1024m -XX:MaxMetaspaceSize=384m -Dfile.encoding=UTF-8" \
|
|
||||||
-v "$SDK_VOLUME":/opt/android-sdk \
|
|
||||||
-v "$CARGO_VOLUME":/cargo \
|
|
||||||
-v "$TARGET_VOLUME":/cargo-target \
|
|
||||||
-v "$GRADLE_VOLUME":/gradle \
|
|
||||||
-w /src \
|
|
||||||
"$ANDROID_IMAGE" \
|
|
||||||
bash -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src && bash /src/.ci-android-build.sh'
|
|
||||||
# Staging dir is included in the tar as .ci-android/ (gitignored paths).
|
|
||||||
mkdir -p .ci-android
|
|
||||||
cp "$HOME/.android/onionwire-release.jks" .ci-android/onionwire-release.jks
|
|
||||||
cp "$HOME/.android/onionwire-release.env" .ci-android/onionwire-release.env
|
|
||||||
tar czf - \
|
|
||||||
--exclude=./target --exclude=./.git --exclude=./.worktrees \
|
|
||||||
--exclude=./android/.gradle --exclude=./android/app/build \
|
|
||||||
--exclude=./android/sdk/build --exclude=./dist \
|
|
||||||
--exclude=./crates/onionwire-sdk/target \
|
|
||||||
. \
|
|
||||||
| docker start -a -i "$BUILD_CONTAINER"
|
|
||||||
mkdir -p dist
|
|
||||||
docker cp "$BUILD_CONTAINER:/src/dist/." dist/
|
|
||||||
end=$(date +%s)
|
end=$(date +%s)
|
||||||
echo "build_wall_clock_seconds=$((end - start))"
|
echo "build_wall_clock_seconds=$((end - start))"
|
||||||
echo "wall_clock_seconds=$((end - start))" >> "$GITHUB_OUTPUT"
|
|
||||||
docker rm -f "$BUILD_CONTAINER" >/dev/null || true
|
|
||||||
rm -rf .ci-android
|
|
||||||
ls -l dist/
|
|
||||||
|
|
||||||
- name: Verify artifacts
|
- name: Verify artifacts
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -308,18 +234,21 @@ jobs:
|
||||||
echo "apk_bytes=$apk_bytes aar_bytes=$aar_bytes"
|
echo "apk_bytes=$apk_bytes aar_bytes=$aar_bytes"
|
||||||
[ "$apk_bytes" -gt 0 ]
|
[ "$apk_bytes" -gt 0 ]
|
||||||
[ "$aar_bytes" -gt 0 ]
|
[ "$aar_bytes" -gt 0 ]
|
||||||
|
file "$apk" "$aar"
|
||||||
|
echo "=== unzip -l lib ==="
|
||||||
|
unzip -l "$apk" | grep -E 'lib/.+\.so|AndroidManifest.xml' || true
|
||||||
|
unzip -l "$apk" | grep "lib/$abi/libonionwire_sdk.so"
|
||||||
|
echo "=== sha256 ==="
|
||||||
( cd dist && sha256sum -c "onionwire-$version-android-$abi.apk.sha256" "onionwire-sdk-$version.aar.sha256" )
|
( cd dist && sha256sum -c "onionwire-$version-android-$abi.apk.sha256" "onionwire-sdk-$version.aar.sha256" )
|
||||||
echo "=== ci-verify.log (from bookworm build container) ==="
|
echo "=== apksigner ==="
|
||||||
cat dist/ci-verify.log
|
apksigner verify --print-certs "$apk"
|
||||||
|
echo "=== aapt dump badging ==="
|
||||||
|
aapt dump badging "$apk" | head -n 20
|
||||||
echo "=== resources after build ==="
|
echo "=== resources after build ==="
|
||||||
free -h || true
|
free -h || true
|
||||||
df -h || true
|
df -h || true
|
||||||
export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}"
|
|
||||||
docker images "$ANDROID_IMAGE" --format '{{.Repository}}:{{.Tag}} {{.Size}}' || true
|
|
||||||
docker system df || true
|
|
||||||
|
|
||||||
- name: Publish (create-or-join)
|
- name: Publish (create-or-join)
|
||||||
id: publish
|
|
||||||
if: steps.version.outputs.dry_run != 'true'
|
if: steps.version.outputs.dry_run != 'true'
|
||||||
env:
|
env:
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
|
@ -338,6 +267,8 @@ jobs:
|
||||||
[ "$bytes" -gt 0 ] || { echo "refusing to publish empty $f" >&2; exit 1; }
|
[ "$bytes" -gt 0 ] || { echo "refusing to publish empty $f" >&2; exit 1; }
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Give the core workflow ~60s to create the tag first. If it exists,
|
||||||
|
# join that release and never send target_commitish (would move it).
|
||||||
tag_exists=0
|
tag_exists=0
|
||||||
i=0
|
i=0
|
||||||
while [ "$i" -lt 6 ]; do
|
while [ "$i" -lt 6 ]; do
|
||||||
|
|
@ -354,60 +285,33 @@ 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}"
|
published=0
|
||||||
PUB_C=onionwire-android-publish-${{ github.run_id }}
|
attempt=1
|
||||||
docker rm -f "$PUB_C" >/dev/null 2>&1 || true
|
while [ "$attempt" -le 5 ]; do
|
||||||
docker create --name "$PUB_C" -i \
|
if scripts/publish-release.sh \
|
||||||
-e FORGEJO_TOKEN \
|
"$TAG" "OnionWire $TAG" \
|
||||||
-e REPO_API \
|
scripts/release-body.md \
|
||||||
-e TARGET_COMMITISH="${TARGET_COMMITISH:-}" \
|
"$apk" "$apk.sha256" "$aar" "$aar.sha256"; then
|
||||||
-e TAG \
|
published=1
|
||||||
-w /src \
|
break
|
||||||
"$ANDROID_IMAGE" \
|
fi
|
||||||
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'
|
echo "publish attempt $attempt failed; retry in 10s"
|
||||||
tar czf - \
|
unset TARGET_COMMITISH || true
|
||||||
--exclude=./target --exclude=./.git --exclude=./.worktrees \
|
attempt=$((attempt + 1))
|
||||||
--exclude=./android/.gradle --exclude=./android/app/build \
|
sleep 10
|
||||||
--exclude=./android/sdk/build \
|
done
|
||||||
--exclude=./crates/onionwire-sdk/target \
|
[ "$published" = "1" ] || { echo "publish failed after retries" >&2; exit 1; }
|
||||||
. \
|
|
||||||
| docker start -a -i "$PUB_C"
|
|
||||||
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: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
rm -rf "$HOME/.android/onionwire-release.jks" "$HOME/.android/onionwire-release.env" .ci-android
|
rm -f "$HOME/.android/onionwire-release.jks" "$HOME/.android/onionwire-release.env" "$HOME/onionwire-release.jks"
|
||||||
echo "keystore removed from runner"
|
echo "keystore removed from runner home"
|
||||||
|
|
|
||||||
|
|
@ -1,364 +1,111 @@
|
||||||
name: release
|
name: release
|
||||||
|
|
||||||
# Auto-tag and publish both Linux binaries when core paths land on main.
|
# Native aarch64 build on the Pi runner, published to the Forgejo release.
|
||||||
# Tag-push is intentionally NOT a trigger: this workflow creates the tag via
|
# x86_64 is NOT built here: there is no x86_64 runner on this instance — build
|
||||||
# the API, and a tag-push hook would start a second run of the same release.
|
# it on an x86_64 host with scripts/build-release-local.sh (same release, same
|
||||||
# Rebuild an existing tag (or dry-run a build) with workflow_dispatch.
|
# asset naming), or the release will carry aarch64 only.
|
||||||
# Version: latest v*.*.* tag → patch+1; zero tags → v0.1.0.
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
tags:
|
||||||
paths:
|
- "v*.*.*"
|
||||||
- "src/**"
|
|
||||||
- "crates/**"
|
|
||||||
- "Cargo.toml"
|
|
||||||
- "Cargo.lock"
|
|
||||||
- ".forgejo/workflows/release.yml"
|
|
||||||
- "scripts/build-release-local.sh"
|
|
||||||
- "scripts/release-body.md"
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: Existing tag to (re)build and publish (empty = next version)
|
description: Existing tag to (re)build and publish
|
||||||
required: false
|
required: true
|
||||||
type: string
|
|
||||||
dry_run:
|
|
||||||
description: Build and checksum without creating a tag or publishing (true/false)
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
default: "false"
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: onionwire-release
|
|
||||||
cancel-in-progress: false
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: never
|
CARGO_TERM_COLOR: never
|
||||||
|
TARGET: aarch64-unknown-linux-gnu
|
||||||
|
# Job steps run inside node:20-bullseye (the runner's docker label image) with
|
||||||
|
# the host docker socket mounted, so builds happen in a sibling rust container.
|
||||||
RUST_IMAGE: rust:1.91-bookworm
|
RUST_IMAGE: rust:1.91-bookworm
|
||||||
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
|
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
|
||||||
|
CARGO_TARGET_VOLUME: onionwire-target-aarch64
|
||||||
|
BUILD_CONTAINER: onionwire-release-build-${{ github.run_id }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
version:
|
aarch64:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
timeout-minutes: 10
|
timeout-minutes: 120
|
||||||
outputs:
|
|
||||||
tag: ${{ steps.plan.outputs.tag }}
|
|
||||||
sha: ${{ steps.plan.outputs.sha }}
|
|
||||||
dry_run: ${{ steps.plan.outputs.dry_run }}
|
|
||||||
created_tag: ${{ steps.plan.outputs.created_tag }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Plan version, create tag unless dry_run
|
- name: Checkout the source tag
|
||||||
id: plan
|
uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
|
with:
|
||||||
|
# A tag push builds that tag; a manual dispatch builds the tag the
|
||||||
|
# caller named (otherwise the binary version would not match the
|
||||||
|
# release it is attached to).
|
||||||
|
ref: ${{ github.event.inputs.tag || github.ref_name }}
|
||||||
|
|
||||||
|
- name: Checkout the CI tooling
|
||||||
|
uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
|
with:
|
||||||
|
# scripts/ and .forgejo/ only exist on the branch (older tags predate
|
||||||
|
# them), and the workflow itself is read from the dispatched ref — so
|
||||||
|
# fetch the same ref into .ci-tools and run the scripts from there.
|
||||||
|
ref: ${{ github.ref_name }}
|
||||||
|
path: .ci-tools
|
||||||
|
|
||||||
|
- name: Build ${{ env.TARGET }} in a rust container
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cd "${GITHUB_WORKSPACE}"
|
||||||
|
echo "workspace: $GITHUB_WORKSPACE"
|
||||||
|
docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null
|
||||||
|
docker volume create "$CARGO_TARGET_VOLUME" > /dev/null
|
||||||
|
docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true
|
||||||
|
# The workspace lives in a per-task volume the host daemon cannot
|
||||||
|
# resolve, so pipe the source tree in over stdin (tar) and pull the
|
||||||
|
# binary back out with docker cp.
|
||||||
|
docker create --name "$BUILD_CONTAINER" -i \
|
||||||
|
-e CARGO_TARGET_DIR=/target \
|
||||||
|
-e CARGO_BUILD_JOBS=2 \
|
||||||
|
-e CARGO_TERM_COLOR=never \
|
||||||
|
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||||
|
-v "$CARGO_TARGET_VOLUME":/target \
|
||||||
|
-w /src \
|
||||||
|
"$RUST_IMAGE" \
|
||||||
|
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
||||||
|
&& cargo build --release --locked \
|
||||||
|
&& strip /target/release/onionwire \
|
||||||
|
&& ls -l /target/release/onionwire'
|
||||||
|
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees \
|
||||||
|
--exclude=./.ci-tools . \
|
||||||
|
| docker start -a -i "$BUILD_CONTAINER"
|
||||||
|
mkdir -p dist
|
||||||
|
docker cp "$BUILD_CONTAINER:/target/release/onionwire" "dist/onionwire-$TARGET"
|
||||||
|
docker rm -f "$BUILD_CONTAINER" > /dev/null
|
||||||
|
|
||||||
|
- name: Pack and checksum
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
cd "${GITHUB_WORKSPACE}/dist"
|
||||||
|
file "onionwire-$TARGET"
|
||||||
|
sha256sum "onionwire-$TARGET" > "onionwire-$TARGET.sha256"
|
||||||
|
sha256sum -c "onionwire-$TARGET.sha256"
|
||||||
|
ls -l
|
||||||
|
|
||||||
|
- name: Publish to the Forgejo release
|
||||||
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_NAME: ${{ github.event_name }}
|
EVENT_NAME: ${{ github.event_name }}
|
||||||
EVENT_SHA: ${{ github.sha }}
|
EVENT_SHA: ${{ github.sha }}
|
||||||
|
REF: ${{ github.ref_name }}
|
||||||
INPUT_TAG: ${{ github.event.inputs.tag }}
|
INPUT_TAG: ${{ github.event.inputs.tag }}
|
||||||
INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
: "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is not set}"
|
|
||||||
FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n')
|
|
||||||
dry_run=false
|
|
||||||
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
|
|
||||||
case "${INPUT_DRY_RUN:-false}" in
|
|
||||||
true|True|TRUE|1|yes|YES) dry_run=true ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
echo "event=$EVENT_NAME sha=$EVENT_SHA input_tag=${INPUT_TAG-} input_dry_run=${INPUT_DRY_RUN-} dry_run=$dry_run"
|
|
||||||
|
|
||||||
api_curl() {
|
|
||||||
curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \
|
|
||||||
--connect-timeout 20 --max-time 60 \
|
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
input_tag="${INPUT_TAG:-}"
|
|
||||||
if [ -n "$input_tag" ]; then
|
|
||||||
code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \
|
|
||||||
"$REPO_API/tags/$input_tag")
|
|
||||||
if [ "$code" != "200" ]; then
|
|
||||||
echo "dispatch tag $input_tag not found (HTTP $code)" >&2
|
|
||||||
cat /tmp/tag.json >&2 || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sha=$(python3 -c "import json; print(json.load(open('/tmp/tag.json'))['commit']['sha'])")
|
|
||||||
tag="$input_tag"
|
|
||||||
created=false
|
|
||||||
echo "re-publish existing tag $tag at $sha (dry_run=$dry_run)"
|
|
||||||
else
|
|
||||||
api_curl "$REPO_API/tags?limit=50" -o /tmp/tags.json
|
|
||||||
tag=$(python3 -c "import json,re; tags=json.load(open('/tmp/tags.json')); assert isinstance(tags, list), tags; semver=[]; [semver.append((int(m[1]), int(m[2]), int(m[3]))) for t in tags for m in [re.fullmatch(r'v([0-9]+)\.([0-9]+)\.([0-9]+)', t.get('name') or '')] if m]; print('v0.1.0' if not semver else 'v%d.%d.%d' % (max(semver)[0], max(semver)[1], max(semver)[2] + 1))")
|
|
||||||
sha="$EVENT_SHA"
|
|
||||||
created=false
|
|
||||||
if [ "$dry_run" = "true" ]; then
|
|
||||||
echo "dry_run: would use $tag on $sha (no tag created)"
|
|
||||||
else
|
|
||||||
code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \
|
|
||||||
"$REPO_API/tags/$tag")
|
|
||||||
if [ "$code" = "200" ]; then
|
|
||||||
existing=$(python3 -c "import json; print(json.load(open('/tmp/tag.json'))['commit']['sha'])")
|
|
||||||
if [ "$existing" != "$sha" ]; then
|
|
||||||
echo "tag $tag exists on $existing, not moving from $sha" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "tag $tag already exists on $sha — joining"
|
|
||||||
elif [ "$code" = "404" ]; then
|
|
||||||
python3 -c "import json,sys; json.dump({'tag_name':sys.argv[1],'target':sys.argv[2],'message':'OnionWire '+sys.argv[1]}, sys.stdout)" \
|
|
||||||
"$tag" "$sha" > /tmp/tag-create.json
|
|
||||||
echo "tag-create payload $(wc -c < /tmp/tag-create.json) bytes"
|
|
||||||
create_code=$(api_curl -o /tmp/tag-created.json -w '%{http_code}' \
|
|
||||||
-X POST -H "Content-Type: application/json" \
|
|
||||||
--data-binary @/tmp/tag-create.json \
|
|
||||||
"$REPO_API/tags")
|
|
||||||
if [ "$create_code" = "201" ]; then
|
|
||||||
created=true
|
|
||||||
echo "created tag $tag on $sha"
|
|
||||||
elif [ "$create_code" = "409" ]; then
|
|
||||||
echo "tag $tag created concurrently — joining"
|
|
||||||
else
|
|
||||||
echo "creating tag $tag failed HTTP $create_code" >&2
|
|
||||||
cat /tmp/tag-created.json >&2 || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "GET tags/$tag failed HTTP $code" >&2
|
|
||||||
cat /tmp/tag.json >&2 || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "sha=$sha" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "dry_run=$dry_run" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "created_tag=$created" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "plan: tag=$tag sha=$sha dry_run=$dry_run created_tag=$created"
|
|
||||||
|
|
||||||
aarch64:
|
|
||||||
needs: version
|
|
||||||
runs-on: docker
|
|
||||||
timeout-minutes: 120
|
|
||||||
env:
|
|
||||||
TARGET: aarch64-unknown-linux-gnu
|
|
||||||
CARGO_TARGET_VOLUME: onionwire-target-aarch64
|
|
||||||
BUILD_CONTAINER: onionwire-release-${{ github.run_id }}-aarch64
|
|
||||||
steps:
|
|
||||||
- name: Checkout source
|
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ needs.version.outputs.sha }}
|
|
||||||
|
|
||||||
- name: Show runner arch
|
|
||||||
run: uname -m && echo "target=$TARGET"
|
|
||||||
|
|
||||||
- name: Build ${{ env.TARGET }} in a rust container
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "${GITHUB_WORKSPACE}"
|
cd "${GITHUB_WORKSPACE}"
|
||||||
echo "workspace: $GITHUB_WORKSPACE"
|
echo "pwd=$PWD workspace=$GITHUB_WORKSPACE"
|
||||||
docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null
|
ls -l dist/ 2>&1 || true
|
||||||
docker volume create "$CARGO_TARGET_VOLUME" > /dev/null
|
for f in dist/*; do printf 'on disk: %s %s bytes\n' "$f" "$(wc -c < "$f")"; done
|
||||||
docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true
|
tag="${INPUT_TAG:-$REF}"
|
||||||
docker create --name "$BUILD_CONTAINER" -i \
|
# Only a tag push may create the tag; a re-publish must not move it.
|
||||||
-e CARGO_TARGET_DIR=/target \
|
if [ "$EVENT_NAME" = "push" ]; then export TARGET_COMMITISH="$EVENT_SHA"; fi
|
||||||
-e CARGO_BUILD_JOBS=2 \
|
echo "publishing $tag from $REPO_API (event=$EVENT_NAME)"
|
||||||
-e CARGO_TERM_COLOR=never \
|
|
||||||
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
|
||||||
-v "$CARGO_TARGET_VOLUME":/target \
|
|
||||||
-w /src \
|
|
||||||
"$RUST_IMAGE" \
|
|
||||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
|
||||||
&& cargo build --release --locked \
|
|
||||||
&& strip /target/release/onionwire \
|
|
||||||
&& ls -l /target/release/onionwire'
|
|
||||||
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees \
|
|
||||||
--exclude=./.ci-tools . \
|
|
||||||
| docker start -a -i "$BUILD_CONTAINER"
|
|
||||||
mkdir -p dist
|
|
||||||
docker cp "$BUILD_CONTAINER:/target/release/onionwire" "dist/onionwire-$TARGET"
|
|
||||||
docker rm -f "$BUILD_CONTAINER" > /dev/null
|
|
||||||
|
|
||||||
- name: Pack and checksum
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
cd "${GITHUB_WORKSPACE}/dist"
|
|
||||||
bytes=$(wc -c < "onionwire-$TARGET")
|
|
||||||
if [ "$bytes" -eq 0 ]; then
|
|
||||||
echo "refusing empty binary onionwire-$TARGET" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
file "onionwire-$TARGET"
|
|
||||||
sha256sum "onionwire-$TARGET" > "onionwire-$TARGET.sha256"
|
|
||||||
sha256sum -c "onionwire-$TARGET.sha256"
|
|
||||||
ls -l
|
|
||||||
|
|
||||||
- name: Upload dist artifact
|
|
||||||
uses: https://code.forgejo.org/actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: onionwire-aarch64-unknown-linux-gnu
|
|
||||||
path: dist/
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
x86_64:
|
|
||||||
needs: version
|
|
||||||
runs-on: docker-amd64
|
|
||||||
timeout-minutes: 120
|
|
||||||
env:
|
|
||||||
TARGET: x86_64-unknown-linux-gnu
|
|
||||||
CARGO_TARGET_VOLUME: onionwire-target-x86_64
|
|
||||||
BUILD_CONTAINER: onionwire-release-${{ github.run_id }}-x86_64
|
|
||||||
steps:
|
|
||||||
- name: Checkout source
|
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ needs.version.outputs.sha }}
|
|
||||||
|
|
||||||
- name: Show runner arch
|
|
||||||
run: uname -m && echo "target=$TARGET"
|
|
||||||
|
|
||||||
- name: Build ${{ env.TARGET }} in a rust container
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
cd "${GITHUB_WORKSPACE}"
|
|
||||||
echo "workspace: $GITHUB_WORKSPACE"
|
|
||||||
docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null
|
|
||||||
docker volume create "$CARGO_TARGET_VOLUME" > /dev/null
|
|
||||||
docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true
|
|
||||||
docker create --name "$BUILD_CONTAINER" -i \
|
|
||||||
-e CARGO_TARGET_DIR=/target \
|
|
||||||
-e CARGO_BUILD_JOBS=2 \
|
|
||||||
-e CARGO_TERM_COLOR=never \
|
|
||||||
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
|
||||||
-v "$CARGO_TARGET_VOLUME":/target \
|
|
||||||
-w /src \
|
|
||||||
"$RUST_IMAGE" \
|
|
||||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
|
||||||
&& cargo build --release --locked \
|
|
||||||
&& strip /target/release/onionwire \
|
|
||||||
&& ls -l /target/release/onionwire'
|
|
||||||
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees \
|
|
||||||
--exclude=./.ci-tools . \
|
|
||||||
| docker start -a -i "$BUILD_CONTAINER"
|
|
||||||
mkdir -p dist
|
|
||||||
docker cp "$BUILD_CONTAINER:/target/release/onionwire" "dist/onionwire-$TARGET"
|
|
||||||
docker rm -f "$BUILD_CONTAINER" > /dev/null
|
|
||||||
|
|
||||||
- name: Pack and checksum
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
cd "${GITHUB_WORKSPACE}/dist"
|
|
||||||
bytes=$(wc -c < "onionwire-$TARGET")
|
|
||||||
if [ "$bytes" -eq 0 ]; then
|
|
||||||
echo "refusing empty binary onionwire-$TARGET" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
file "onionwire-$TARGET"
|
|
||||||
sha256sum "onionwire-$TARGET" > "onionwire-$TARGET.sha256"
|
|
||||||
sha256sum -c "onionwire-$TARGET.sha256"
|
|
||||||
ls -l
|
|
||||||
|
|
||||||
- name: Upload dist artifact
|
|
||||||
uses: https://code.forgejo.org/actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: onionwire-x86_64-unknown-linux-gnu
|
|
||||||
path: dist/
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
publish:
|
|
||||||
needs: [version, aarch64, x86_64]
|
|
||||||
if: needs.version.outputs.dry_run != 'true'
|
|
||||||
runs-on: docker-amd64
|
|
||||||
timeout-minutes: 20
|
|
||||||
steps:
|
|
||||||
- name: Checkout CI tooling
|
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
|
||||||
with:
|
|
||||||
path: .ci-tools
|
|
||||||
|
|
||||||
- name: Download both arch artifacts
|
|
||||||
uses: https://code.forgejo.org/actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
path: artifacts
|
|
||||||
|
|
||||||
- name: Publish both binaries to one release
|
|
||||||
env:
|
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
|
||||||
TAG: ${{ needs.version.outputs.tag }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
mkdir -p dist
|
|
||||||
find artifacts -type f -print
|
|
||||||
for target in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do
|
|
||||||
src=$(find artifacts -type f -name "onionwire-$target" -print -quit)
|
|
||||||
sum=$(find artifacts -type f -name "onionwire-$target.sha256" -print -quit)
|
|
||||||
if [ -z "$src" ] || [ -z "$sum" ]; then
|
|
||||||
echo "missing artifact for $target" >&2
|
|
||||||
find artifacts -type f >&2 || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
cp "$src" "dist/onionwire-$target"
|
|
||||||
cp "$sum" "dist/onionwire-$target.sha256"
|
|
||||||
done
|
|
||||||
missing=0
|
|
||||||
for f in \
|
|
||||||
dist/onionwire-aarch64-unknown-linux-gnu \
|
|
||||||
dist/onionwire-aarch64-unknown-linux-gnu.sha256 \
|
|
||||||
dist/onionwire-x86_64-unknown-linux-gnu \
|
|
||||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256
|
|
||||||
do
|
|
||||||
bytes=$(wc -c < "$f")
|
|
||||||
echo "on disk: $f $bytes bytes"
|
|
||||||
if [ "$bytes" -eq 0 ]; then
|
|
||||||
echo "refusing empty asset $f" >&2
|
|
||||||
missing=1
|
|
||||||
fi
|
|
||||||
file "$f" || true
|
|
||||||
done
|
|
||||||
if [ "$missing" -ne 0 ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "publishing $TAG from $REPO_API"
|
|
||||||
.ci-tools/scripts/publish-release.sh \
|
.ci-tools/scripts/publish-release.sh \
|
||||||
"$TAG" "OnionWire $TAG" \
|
"$tag" "OnionWire $tag" \
|
||||||
.ci-tools/scripts/release-body.md \
|
.ci-tools/scripts/release-body.md \
|
||||||
dist/onionwire-aarch64-unknown-linux-gnu \
|
"dist/onionwire-$TARGET" "dist/onionwire-$TARGET.sha256"
|
||||||
dist/onionwire-aarch64-unknown-linux-gnu.sha256 \
|
|
||||||
dist/onionwire-x86_64-unknown-linux-gnu \
|
|
||||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
needs: [version, aarch64, x86_64, publish]
|
|
||||||
if: ${{ always() && needs.version.outputs.created_tag == 'true' && (needs.aarch64.result != 'success' || needs.x86_64.result != 'success' || needs.publish.result != 'success') }}
|
|
||||||
runs-on: docker
|
|
||||||
timeout-minutes: 10
|
|
||||||
steps:
|
|
||||||
- name: Delete tag and incomplete release we created
|
|
||||||
env:
|
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
|
||||||
TAG: ${{ needs.version.outputs.tag }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
echo "fail-closed: removing tag $TAG created by this run"
|
|
||||||
code=$(curl -sS --http1.1 -o /tmp/rel.json -w '%{http_code}' \
|
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/releases/tags/$TAG")
|
|
||||||
if [ "$code" = "200" ]; then
|
|
||||||
rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])")
|
|
||||||
echo "deleting incomplete release id $rid"
|
|
||||||
curl -sS --http1.1 -X DELETE -H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/releases/$rid" -o /dev/null -w "DELETE release HTTP %{http_code}\n"
|
|
||||||
else
|
|
||||||
echo "no release for $TAG (HTTP $code)"
|
|
||||||
fi
|
|
||||||
curl -sS --http1.1 -X DELETE -H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/tags/$TAG" -o /dev/null -w "DELETE tag HTTP %{http_code}\n"
|
|
||||||
|
|
|
||||||
30
README.md
30
README.md
|
|
@ -25,7 +25,7 @@ Arti onion services are still **experimental**. If the hidden service cannot com
|
||||||
|
|
||||||
### Option A — download a release binary
|
### Option A — download a release binary
|
||||||
|
|
||||||
CI (`.forgejo/workflows/release.yml`) tags and publishes both Linux binaries on every `main` push that touches the core (`src/`, `crates/`, `Cargo.toml`, `Cargo.lock`, or the release workflow/scripts). aarch64 builds on the Pi runner; x86_64 builds on the amd64 runner. Both attach to the same [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases). `scripts/build-release-local.sh` remains the offline x86_64 fallback.
|
CI (`.forgejo/workflows/release.yml`, Forgejo Actions on the Pi runner) builds the **aarch64** binary on every `v*.*.*` tag and attaches it to the [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases). There is no x86_64 runner on this instance, so the **x86_64** asset is built and uploaded by `scripts/build-release-local.sh` on an x86_64 host — both land on the same release page.
|
||||||
|
|
||||||
**x86_64 (most PCs / VMs):**
|
**x86_64 (most PCs / VMs):**
|
||||||
|
|
||||||
|
|
@ -262,27 +262,29 @@ Every asset has a matching `.sha256` so `sha256sum -c` works. The APK is
|
||||||
|
|
||||||
## Releases (maintainers)
|
## Releases (maintainers)
|
||||||
|
|
||||||
A core change on `main` is enough. The release workflow computes the next
|
Tags trigger Forgejo Actions on the self-hosted Pi runner. The x86_64 asset has
|
||||||
`v*.*.*` tag (patch+1, or `v0.1.0` if there are no tags), creates it via the
|
no runner on this instance, so it is built locally and attached to the same
|
||||||
API, builds aarch64 on the Pi runner and x86_64 on the amd64 runner, and
|
release.
|
||||||
publishes all four assets (`onionwire-<target>` + `.sha256`) to one release.
|
|
||||||
Do not push tags by hand — a tag-push trigger would start a second run.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# optional: keep Cargo.toml in sync with the tag the workflow will mint
|
# 1. version in Cargo.toml must match the tag without the leading v
|
||||||
# (the workflow does not edit Cargo.toml)
|
cargo update --offline -p onionwire # keep Cargo.lock at the new version
|
||||||
|
git commit -am "chore: release vX.Y.Z" && git push origin main
|
||||||
|
|
||||||
# rebuild / re-publish an existing tag, or dry-run a build with no tag:
|
# 2. tag and push — the release workflow builds + publishes aarch64
|
||||||
# Actions → release → Run workflow → tag=vX.Y.Z and/or dry_run=true
|
git tag -a vX.Y.Z -m "OnionWire vX.Y.Z"
|
||||||
|
git push origin vX.Y.Z
|
||||||
|
|
||||||
# offline x86_64 fallback (idempotent — safe to re-run)
|
# 3. attach x86_64 from an x86_64 host (idempotent — safe to re-run)
|
||||||
FORGEJO_TOKEN=<pat> scripts/build-release-local.sh vX.Y.Z
|
FORGEJO_TOKEN=<pat> scripts/build-release-local.sh vX.Y.Z
|
||||||
```
|
```
|
||||||
|
|
||||||
Workflows (Forgejo Actions, `.forgejo/workflows/`):
|
Workflows (Forgejo Actions, `.forgejo/workflows/` — jobs run on the `docker`
|
||||||
|
label of the Pi runner and do their Rust work in a `rust:1.91-bookworm`
|
||||||
|
sibling container):
|
||||||
|
|
||||||
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` on `main` and PRs (ignored Tor-live tests are not run). Pi runner, `docker` label.
|
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` on `main` and PRs (ignored Tor-live tests are not run).
|
||||||
- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — on core paths to `main`: next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release. `workflow_dispatch` rebuilds a tag or `dry_run`s. Concurrency group `onionwire-release` (separate from CI).
|
- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — on `v*.*.*` tags: builds `aarch64-unknown-linux-gnu` natively, strips, sha256, publishes to the release. Also runnable via `workflow_dispatch` with a tag input to re-publish.
|
||||||
|
|
||||||
Scripts:
|
Scripts:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,9 +122,6 @@ deobfuscation, not before.
|
||||||
## CI
|
## CI
|
||||||
|
|
||||||
`.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
|
|
||||||
toolchain runs in a sibling `eclipse-temurin:17-jdk-bookworm` container
|
|
||||||
(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/**` (or the local build script / this
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Offline fallback: build the x86_64 release asset on this host and publish it
|
# Build the x86_64 release asset on this host and publish it to the Forgejo
|
||||||
# to the Forgejo release for <tag>. CI (.forgejo/workflows/release.yml) now
|
# release for <tag>. CI (.forgejo/workflows/release.yml) only covers aarch64 —
|
||||||
# builds both aarch64 (Pi runner) and x86_64 (amd64 runner). Use this script
|
# there is no x86_64 runner on the instance, so this is the x86_64 path.
|
||||||
# when you cannot wait for CI or the amd64 runner is down.
|
|
||||||
#
|
#
|
||||||
# Usage: FORGEJO_TOKEN=... scripts/build-release-local.sh v0.1.0
|
# Usage: FORGEJO_TOKEN=... scripts/build-release-local.sh v0.1.2
|
||||||
#
|
#
|
||||||
# Does not create or push the tag: the release workflow owns tagging. Idempotent
|
# Does not create or push the tag: tag and push first, then run this so the
|
||||||
# (same-named assets are replaced). Never moves an existing tag.
|
# release body/asset set matches a real tag. Idempotent (assets are replaced).
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
tag="${1:?usage: build-release-local.sh <tag>}"
|
tag="${1:?usage: build-release-local.sh <tag>}"
|
||||||
|
|
|
||||||
|
|
@ -100,13 +100,8 @@ for a in json.load(sys.stdin):
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||||
-F "attachment=@$f" -o /tmp/release-asset.json
|
-F "attachment=@$f" -o /tmp/release-asset.json
|
||||||
python3 -c "
|
python3 -c "
|
||||||
import json,sys
|
import json;d=json.load(open('/tmp/release-asset.json'))
|
||||||
d=json.load(open('/tmp/release-asset.json'))
|
print('publish: uploaded', d['name'], d['size'], 'bytes')"
|
||||||
name, size = d.get('name'), d.get('size')
|
|
||||||
print('publish: uploaded', name, size, 'bytes')
|
|
||||||
if not size:
|
|
||||||
sys.exit('publish: server stored 0-byte asset %s — refusing to continue' % (name,))
|
|
||||||
"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
api_curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \
|
api_curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
Prebuilt Linux binaries. No `tor` package required — Arti runs in-process.
|
Prebuilt Linux binaries. No `tor` package required — Arti runs in-process.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# aarch64 (Raspberry Pi, ARM servers)
|
# aarch64 (Raspberry Pi, ARM servers) — CI builds this one on the Pi runner
|
||||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu
|
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu
|
||||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu.sha256
|
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu.sha256
|
||||||
sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256
|
sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256
|
||||||
chmod +x onionwire-aarch64-unknown-linux-gnu
|
chmod +x onionwire-aarch64-unknown-linux-gnu
|
||||||
|
|
||||||
# x86_64 (most PCs / VMs)
|
# x86_64 (most PCs / VMs) — built locally with scripts/build-release-local.sh
|
||||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu
|
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu
|
||||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu.sha256
|
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||||
sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256
|
sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue