Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build binaries on publish for Linux and macOS #44

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build-test
name: Build and test

on:
push:
Expand All @@ -12,18 +12,20 @@ jobs:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
- name: Install pnpm
run: |
corepack enable
corepack prepare pnpm@latest --activate

- name: Install Node.js
uses: actions/setup-node@v3
with:
version: 8
node-version: 16
cache: pnpm

- run: pnpm install
- run: pnpm run build
- run: pnpm run ci

109 changes: 109 additions & 0 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build release binaries

on:
release:
types: ['created']
pull_request:
types: [synchronize]

jobs:
build-binaries:
name: Build binaries for ${{matrix.target}}
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-14
target: aarch64-apple-darwin
- runner: macos-13
target: x86_64-apple-darwin
# - runner: ubuntu-latest
# target: x86_64-pc-windows-gnu
steps:
- name: Checkout
uses: actions/checkout@v4

- 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/[email protected]
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++
Comment on lines +82 to +84
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect but I can fix it once I enable windows builds

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
id: 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}}
cd generated
tar cvfz c2pa-node_${{matrix.target}}-${{ github.event.release.tag_name }}.tar.gz c2pa.node
echo "archive=c2pa-node_${{matrix.target}}-${{ github.event.release.tag_name }}.tar.gz" >> "$GITHUB_OUTPUT"

- name: Upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: generated/${{ steps.build-library.outputs.archive }}
asset_name: ${{ steps.build-library.outputs.archive }}
asset_content_type: application/tar+gzip
Loading
Loading