Skip to content

Build prebuilds

Build prebuilds #8

Workflow file for this run

name: Build prebuilds
on:
workflow_dispatch: {}
jobs:
build-linux:
name: Build Linux prebuilds
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install system deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential curl git autoconf automake libtool pkg-config python3
- name: Build libjpeg
run: |
curl -fsSL http://www.ijg.org/files/jpegsrc.v9d.tar.gz -o jpegsrc.v9d.tar.gz
tar xzf jpegsrc.v9d.tar.gz
cd jpeg-9d
./configure --with-pic --prefix=/usr/local
make -j"$(nproc)"
sudo make install
cd ..
- name: Build LibRaw
run: |
curl -fsSL https://www.libraw.org/data/LibRaw-0.21.2.tar.gz -o LibRaw-0.21.2.tar.gz
tar xzf LibRaw-0.21.2.tar.gz
cd LibRaw-0.21.2
./configure --with-pic --disable-openmp --prefix=/usr/local
make -j"$(nproc)"
sudo make install
cd ..
- name: Install npm deps
run: npm ci
- name: Build project
run: npm run build
- name: Run prebuildify
run: npx prebuildify --napi
- name: Upload Linux prebuilds
uses: actions/upload-artifact@v4
with:
name: prebuilds-linux
path: prebuilds
build-macos:
name: Build macOS prebuilds
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install Homebrew deps
run: |
brew update
# Install bottles for jpeg and libraw to avoid building from source on macOS runners
brew install jpeg libraw pkg-config python3
- name: Export Homebrew environment
run: |
BREW_PREFIX=$(brew --prefix)
echo "PKG_CONFIG_PATH=${BREW_PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "PATH=${BREW_PREFIX}/bin:$PATH" >> $GITHUB_ENV
echo "LDFLAGS=-L${BREW_PREFIX}/lib $LDFLAGS" >> $GITHUB_ENV
echo "CPPFLAGS=-I${BREW_PREFIX}/include $CPPFLAGS" >> $GITHUB_ENV
- name: Install npm deps
run: npm ci
- name: Build project
run: npm run build
- name: Run prebuildify
run: npx prebuildify --napi
- name: Upload macOS prebuilds
uses: actions/upload-artifact@v4
with:
name: prebuilds-macos
path: prebuilds
publish-release:
name: Create draft release with prebuilds
runs-on: ubuntu-latest
needs: [build-linux, build-macos]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux prebuilds artifact
uses: actions/download-artifact@v4
with:
name: prebuilds-linux
path: artifacts/linux
- name: Download macOS prebuilds artifact
uses: actions/download-artifact@v4
with:
name: prebuilds-macos
path: artifacts/macos
- name: Prepare release assets
run: |
mkdir -p release-assets
if [ -d artifacts/linux ]; then
cd artifacts/linux || exit 0
zip -r ../../release-assets/prebuilds-linux-${{ github.run_id }}.zip . || true
cd ../..
fi
if [ -d artifacts/macos ]; then
cd artifacts/macos || exit 0
zip -r ../../release-assets/prebuilds-macos-${{ github.run_id }}.zip . || true
cd ../..
fi
- name: Create draft release
id: create_release
uses: actions/create-release@v1
with:
tag_name: prebuild-${{ github.run_id }}
release_name: "prebuild-${{ github.run_id }}"
body: |
Automated prebuilds for run ${{ github.run_id }}.
- Commit: ${{ github.sha }}
- Workflow: ${{ github.workflow }}
draft: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload prebuild assets to release
uses: softprops/action-gh-release@v1
with:
files: release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}