Skip to content

ci: add unit-test workflow for Android NDK builds #1

ci: add unit-test workflow for Android NDK builds

ci: add unit-test workflow for Android NDK builds #1

Workflow file for this run

name: Unit Test (Android NDK)
on:
workflow_dispatch:
push:
branches:
- unit-test
jobs:
test-android-build:
name: Build Android (${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: android-aarch64
goarch: arm64
- arch: android-x86_64
goarch: amd64
- arch: android-armv7
goarch: arm
goarm: "7"
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Install NDK
run: |
NDK_VERSION="25.2.9519653"
cd /tmp
wget -q https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux.zip
unzip -q android-ndk-${NDK_VERSION}-linux.zip
ANDROID_NDK_HOME=/tmp/android-ndk-${NDK_VERSION}
TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
echo "TOOLCHAIN=$TOOLCHAIN" >> $GITHUB_ENV
if [ "${{ matrix.goarch }}" = "arm64" ]; then
echo "CC=$TOOLCHAIN/bin/aarch64-linux-android21-clang" >> $GITHUB_ENV
elif [ "${{ matrix.goarch }}" = "amd64" ]; then
echo "CC=$TOOLCHAIN/bin/x86_64-linux-android21-clang" >> $GITHUB_ENV
elif [ "${{ matrix.goarch }}" = "arm" ]; then
echo "CC=$TOOLCHAIN/bin/armv7a-linux-androideabi21-clang" >> $GITHUB_ENV
fi
- name: Build Android Binary
env:
GOOS: android
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm || '' }}
CGO_ENABLED: 1
run: |
go build -ldflags="-s -w" -o ${{ matrix.arch }} ./cmd/autolinux
file ${{ matrix.arch }}