Build binaries on publish for Linux and macOS #125
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-test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
# build-test: | |
# name: Build and test | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Install pnpm | |
# run: | | |
# corepack enable | |
# corepack prepare pnpm@latest --activate | |
# - name: Install Node.js | |
# uses: actions/setup-node@v3 | |
# with: | |
# node-version: 16 | |
# cache: pnpm | |
# - run: pnpm install | |
# - run: pnpm run build | |
# - run: pnpm run ci | |
build-binaries: | |
name: Build binaries for ${{matrix.target}} | |
# needs: build-test | |
runs-on: ${{matrix.runner}} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# - runner: ubuntu-latest | |
# target: aarch64-unknown-linux-gnu | |
# - runner: ubuntu-latest | |
# target: x86_64-unknown-linux-gnu | |
# - runner: macos-latest | |
# target: aarch64-apple-darwin | |
# - runner: macos-latest | |
# target: x86_64-apple-darwin | |
- runner: ubuntu-latest | |
target: x86_64-pc-windows-gnu | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get short SHA | |
id: sha | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Install system deps (aarch64-unknown-linux-gnu) | |
if: ${{matrix.target == 'aarch64-unknown-linux-gnu'}} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross | |
- name: Install system deps (x86_64-pc-windows-gnu) | |
if: ${{matrix.target == 'x86_64-pc-windows-gnu'}} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libz-mingw-w64-dev g++-mingw-w64-x86-64 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@1.70.0 | |
with: | |
components: llvm-tools-preview | |
target: ${{matrix.target}} | |
- name: Install pnpm | |
run: | | |
corepack enable | |
corepack prepare pnpm@latest --activate | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- name: Cache Rust dependencies | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: ${{matrix.target}} | |
- name: Build library for aarch64-unknown-linux-gnu | |
if: ${{matrix.target == 'aarch64-unknown-linux-gnu'}} | |
env: | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc | |
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++ | |
run: | | |
mkdir -p generated/${{matrix.target}} | |
pnpm run build:rust --target=${{matrix.target}} | |
mv generated/c2pa.node generated/${{matrix.target}}/c2pa.node | |
- name: Build library for x86_64-pc-windows-gnu | |
if: ${{matrix.target == 'x86_64-pc-windows-gnu'}} | |
env: | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: x86_64-w64-mingw32-gcc | |
CC_aarch64_unknown_linux_gnu: x86_64-w64-mingw32-gcc | |
CXX_aarch64_unknown_linux_gnu: x86_64-w64-mingw32-g++ | |
run: | | |
mkdir -p generated/${{matrix.target}} | |
pnpm run build:rust --target=${{matrix.target}} | |
mv generated/c2pa.node generated/${{matrix.target}}/c2pa.node | |
- name: Build library | |
if: ${{!contains(fromJSON('["aarch64-unknown-linux-gnu", "x86_64-pc-windows-gnu"]'), matrix.target)}} | |
run: | | |
mkdir -p generated/${{matrix.target}} | |
pnpm run build:rust --target=${{matrix.target}} | |
mv generated/c2pa.node generated/${{matrix.target}}/c2pa.node | |
- name: Add built files to archive | |
uses: actions/upload-artifact@v3 | |
with: | |
name: c2pa-node_${{matrix.target}}-${{ steps.sha.outputs.sha_short }} | |
path: | | |
generated/${{matrix.target}}/c2pa.node | |
retention-days: 7 |