Upload to build server in publish workflow for nym-vpn-core #50
This file contains 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-nym-vpn-core-android | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- ".github/workflows/build-nym-vpn-core-android.yml" | |
workflow_call: | |
outputs: | |
RUST_VERSION: | |
value: ${{ jobs.build-android.outputs.RUST_VERSION }} | |
env: | |
CARGO_TERM_COLOR: always | |
CARGO_TARGET: release | |
WG_GO_LIB_PATH: ${{ github.workspace }}/build/lib/aarch64-linux-android | |
WG_GO_LIB_NAME: wireguard-go_aarch64-linux-android | |
UPLOAD_DIR_ANDROID: android_artifacts | |
jobs: | |
build-wireguard-go-android: | |
uses: ./.github/workflows/build-wireguard-go-android.yml | |
build-android: | |
needs: build-wireguard-go-android | |
runs-on: ubuntu-22.04 | |
outputs: | |
UPLOAD_DIR_ANDROID: ${{ env.UPLOAD_DIR_ANDROID }} | |
RUST_VERSION: ${{ steps.rust-version.outputs.rustc }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update && sudo apt-get install -y libdbus-1-dev libmnl-dev libnftnl-dev protobuf-compiler | |
- name: Install rust toolchain | |
uses: brndnmtthws/rust-action-rustup@v1 | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
- name: Add android target | |
run: | | |
rustup target install aarch64-linux-android | |
- name: Setup NDK | |
uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: r25c | |
add-to-path: false | |
- name: Set env | |
shell: bash | |
run: | | |
echo "ANDROID_NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}" >> $GITHUB_ENV | |
echo "NDK_TOOLCHAIN_DIR=${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_ENV | |
- name: Install cargo deps | |
run: | | |
cargo install --locked cargo-ndk cargo-license | |
- name: Get workspace version | |
id: workspace-version | |
uses: nicolaiunrein/cargo-get@master | |
with: | |
subcommand: workspace.package.version --entry nym-vpn-core | |
- name: Install cargo-edit | |
run: cargo install --locked cargo-edit | |
- name: Append timestamp if it's a dev version | |
run: ./scripts/append-timestamp-to-version.sh nym-vpn-core/Cargo.toml ${{ steps.workspace-version.outputs.output }} | |
- name: Download wireguard-go artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.WG_GO_LIB_NAME }} | |
path: ${{ env.WG_GO_LIB_PATH }} | |
- name: Build nym-vpn-core for android | |
working-directory: nym-vpn-core/crates/nym-vpn-lib | |
env: | |
RUSTFLAGS: "-L ${{ env.WG_GO_LIB_PATH }}" | |
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
run: | | |
cargo ndk -t arm64-v8a -o ../target/aarch64-linux-android/release build --${{ env.CARGO_TARGET }} | |
ls -la ../target/aarch64-linux-android/release/ || true | |
- name: Get rust version used for build | |
id: rust-version | |
run: | | |
echo "rustc=$(rustc -V)" >> $GITHUB_OUTPUT | |
- name: Move things around to prepare for upload | |
env: | |
SRC_BINARY: nym-vpn-core/target/aarch64-linux-android/${{ env.CARGO_TARGET }}/ | |
run: | | |
mkdir ${{ env.UPLOAD_DIR_ANDROID }} | |
cp -vpr ${{ env.SRC_BINARY }}/libnym_vpn_lib.so ${{ env.UPLOAD_DIR_ANDROID }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.UPLOAD_DIR_ANDROID }} | |
path: ${{ env.UPLOAD_DIR_ANDROID }} | |
retention-days: 1 |