diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17ff8f9..bfc23b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,7 @@ name: Release -# GitHub version of the release pipeline. The build half mirrors the Gitea one -# in .gitea/workflows/release.yml (static musl Linux via cargo-zigbuild, native -# macOS and Windows); only the publish half differs: it uses the current -# artifact actions (Node 24) and fills the release with `gh`. +# Desktop builds mirror .gitea/workflows/release.yml. GitHub also builds and +# signs the Android APK and attaches all platform packages to the tag with gh. # # Every job is gated on `github.server_url == 'https://github.com'`, so this file # runs only on GitHub. Gitea runs its own copy in .gitea/workflows (which pins @@ -276,9 +274,77 @@ jobs: tsunagi-setup-*.exe if-no-files-found: error + android: + name: Android ARM64 APK + if: ${{ github.server_url == 'https://github.com' }} + runs-on: ubuntu-24.04 + permissions: + contents: read + env: + NDK_VERSION: '30.0.16248370' + BUILD_TOOLS_VERSION: '36.0.0' + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: false + - uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: '21' + - uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-linux-android + - uses: Swatinem/rust-cache@v2 + with: + key: android-arm64-${{ env.NDK_VERSION }} + + - name: Install Android build tools + run: | + "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \ + 'platforms;android-35' "build-tools;$BUILD_TOOLS_VERSION" "ndk;$NDK_VERSION" + echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$NDK_VERSION" >> "$GITHUB_ENV" + cargo install --locked --version 4.1.2 cargo-ndk + + - name: Build the ARM64 release APK + run: | + android/gradlew -p android --no-daemon :app:assembleRelease \ + "-PtsunagiVersionName=${GITHUB_REF_NAME#v}" "-PtsunagiVersionCode=$GITHUB_RUN_NUMBER" + + - name: Sign the APK + id: sign + env: + ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} + ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} + run: | + set -euo pipefail + : "${ANDROID_KEYSTORE_BASE64:?Set the ANDROID_KEYSTORE_BASE64 Actions secret}" + : "${ANDROID_KEYSTORE_PASSWORD:?Set the ANDROID_KEYSTORE_PASSWORD Actions secret}" + umask 077 + keystore=$(mktemp "$RUNNER_TEMP/tsunagi-keystore.XXXXXXXX") + trap 'rm -f "$keystore"' EXIT + printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$keystore" + apk="$RUNNER_TEMP/tsunagi-android-${GITHUB_REF_NAME#v}-arm64-v8a.apk" + "$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION/apksigner" sign \ + --ks "$keystore" --ks-pass env:ANDROID_KEYSTORE_PASSWORD --key-pass env:ANDROID_KEYSTORE_PASSWORD \ + --v4-signing-enabled false --out "$apk" android/app/build/outputs/apk/release/app-release-unsigned.apk + echo "apk=$apk" >> "$GITHUB_OUTPUT" + + - name: Test the signed APK + env: + APK: ${{ steps.sign.outputs.apk }} + run: | + bash android/test-release-apk.sh "$APK" "${GITHUB_REF_NAME#v}" "$GITHUB_RUN_NUMBER" \ + "$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION" + + - uses: actions/upload-artifact@v7 + with: + name: tsunagi-android + path: ${{ steps.sign.outputs.apk }} + if-no-files-found: error + publish: name: Publish release - needs: build + needs: [build, android] if: ${{ github.server_url == 'https://github.com' }} runs-on: ubuntu-latest permissions: @@ -303,6 +369,9 @@ jobs: # download-artifact nests each artifact under its own directory, so # the archives are artifacts//. mapfile -t files < <(find artifacts -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name '*.deb' -o -name '*.pkg.tar.zst' -o -name 'tsunagi-setup-*.exe' \)) + apk="artifacts/tsunagi-android/tsunagi-android-${TAG#v}-arm64-v8a.apk" + [[ -s "$apk" ]] || { echo "::error::Missing release APK at $apk"; exit 1; } + files+=("$apk") printf 'asset: %s\n' "${files[@]}" prerelease=() diff --git a/README.md b/README.md index 478e92c..27bafde 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Grab a build from the [latest release](https://github.com/house-of-vanity/tsunag | Platform | How | | --------------------- | -------------------------------------------------------------------------------- | | **Windows** | Run `tsunagi-setup--x86_64.exe`. Installs the service, the tray and `tsng`. | +| **Android** | Open `tsunagi-android--arm64-v8a.apk` on an ARM64 phone running Android 8 or later. | | **macOS** | `brew tap house-of-vanity/tap && brew install --cask tsunagi-gui`
CLI only: `brew install tsunagi` | | **Debian / Ubuntu** | `sudo apt install ./tsunagi-gui__amd64.deb` (`tsunagi_…` for no tray) | | **Arch** | `sudo pacman -U tsunagi-gui--1-x86_64.pkg.tar.zst` | diff --git a/android/README.md b/android/README.md index 70c6478..91b702b 100644 --- a/android/README.md +++ b/android/README.md @@ -1,5 +1,9 @@ # Android client +Download `tsunagi-android--arm64-v8a.apk` from the project's GitHub release and open it on an ARM64 phone running Android 8 or later. If prompted, allow the app that opened the file to install it. Later releases can update the installed app and preserve the mesh identity. A prototype signed with a local debug key requires a fresh install to switch to the release signer. Uninstalling the prototype removes its local identity and saved networks. [GitHub Releases](https://github.com/house-of-vanity/tsunagi/releases) + +## Build from source + Open this directory in Android Studio. The debug prototype targets ARM64 devices running Android 8 or later with OpenGL ES 3. Install SDK Platform 35 and the NDK with the SDK Manager. Point `ANDROID_HOME` at your SDK and `ANDROID_NDK_HOME` at the installed NDK directory. The Gradle launcher needs a JDK, such as the one bundled with Android Studio. From the repository root, with Cargo and cargo-ndk on your PATH: @@ -21,3 +25,23 @@ Applications using Android’s system resolver can connect to `.&2 + exit 1 +fi +if grep -Fxq 'application-debuggable' <<< "$badging"; then + echo "The release APK enables Android debugging" >&2 + exit 1 +fi +if ! grep -Fxq "native-code: 'arm64-v8a'" <<< "$badging"; then + echo "Expected an arm64-v8a APK" >&2 + exit 1 +fi +library=$(mktemp) +trap 'rm -f "$library"' EXIT +unzip -p "$apk" lib/arm64-v8a/libtsunagi_android.so > "$library" +if [[ "$(LC_ALL=C file -b "$library")" != *"ARM aarch64"*", stripped"* ]]; then + echo "Expected a stripped ARM64 tsunagi native library" >&2 + exit 1 +fi +"$build_tools/zipalign" -c -P 16 4 "$apk" +"$build_tools/apksigner" verify --verbose --print-certs "$apk"