build-and-release-kopia-android #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build-and-release-kopia-android | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| kopia-version: | |
| description: 'Kopia version tag (e.g. v0.21.1)' | |
| required: true | |
| default: 'v0.21.1' | |
| permissions: | |
| contents: write # required for creating a GitHub Release | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22.x' | |
| # Install the Android NDK (r28c) and expose the path as output | |
| - id: ndk | |
| uses: nttld/setup-ndk@v1 | |
| with: | |
| ndk-version: r28c | |
| - name: Build Kopia (Android/arm64, CGO, netcgo) | |
| env: | |
| NDK: ${{ steps.ndk.outputs.ndk-path }} | |
| KOPIA_VERSION: ${{ github.event.inputs.kopia-version }} | |
| run: | | |
| set -e | |
| # ── Cross‑compiler paths ──────────────────────────────────────────── | |
| export CC="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" | |
| export CXX="$CC++" | |
| # ── Go cross‑compile env ──────────────────────────────────────────── | |
| export GOOS=android | |
| export GOARCH=arm64 | |
| export CGO_ENABLED=1 | |
| # Unset GOBIN so go install accepts cross‑install | |
| env -u GOBIN go install -tags netcgo github.com/kopia/kopia@${KOPIA_VERSION} | |
| BIN_DIR="$(go env GOPATH)/bin/${GOOS}_${GOARCH}" | |
| mkdir -p dist | |
| cp "$BIN_DIR/kopia" dist/kopia-android-arm64 | |
| ( cd dist && sha256sum kopia-android-arm64 > kopia-android-arm64.sha256 ) | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: kopia-android-artifact | |
| path: dist/ | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: kopia-android-artifact | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.inputs.kopia-version }} | |
| name: kopia-android-${{ github.event.inputs.kopia-version }} | |
| files: | | |
| kopia-android-arm64 | |
| kopia-android-arm64.sha256 | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |