Build and Publish libpq-query π #2
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 libpq-query π | |
on: | |
workflow_dispatch: | |
jobs: | |
build-artifacts: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, macos-latest, ubuntu-latest] | |
steps: | |
- name: Checkout Repository π₯ | |
uses: actions/checkout@v4 | |
- name: Setup Node.js π | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'yarn' | |
- name: Install and Build π¦ | |
run: | | |
yarn | |
yarn binary:build | |
- name: Save Artifacts For Supabase CDN π | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-supabase-artifact-${{ matrix.os }} | |
path: './build/stage/libpg-query-node/' | |
- name: Save Artifacts For NPM π | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-npm-artifact-${{ matrix.os }} | |
path: | | |
${{ matrix.os == 'macos-latest' && './libpg_query/osx/libpg_query.a' || | |
matrix.os == 'ubuntu-latest' && './libpg_query/linux/libpg_query.a' || | |
matrix.os == 'windows-latest' && './libpg_query/windows/pg_query.lib' }} | |
build-wasm: | |
needs: build-artifacts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository π₯ | |
uses: actions/checkout@v4 | |
- name: Setup Node.js π | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'yarn' | |
- name: Install and Build π | |
run: | | |
yarn | |
- name: Install Emscripten βπ» | |
run: | | |
sudo apt-get update | |
sudo apt-get install cmake python3 python3-pip | |
git clone --branch 3.1.59 --depth 1 https://github.com/emscripten-core/emsdk.git | |
cd emsdk | |
./emsdk install 3.1.59 | |
./emsdk activate 3.1.59 | |
source ./emsdk_env.sh | |
- name: Build with Emscripten π | |
run: | | |
source ./emsdk/emsdk_env.sh | |
emmake make | |
emmake make build | |
- name: Archive production artifacts π | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wasm-artifacts | |
path: wasm | |
prepare-and-publish: | |
needs: build-wasm | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository π₯ | |
uses: actions/checkout@v4 | |
- name: Get Artifacts π | |
uses: actions/download-artifact@v4 | |
with: | |
path: downloaded-artifacts | |
- name: Prepare artifacts π¦ | |
run: | | |
cp ./downloaded-artifacts/build-npm-artifact-windows-latest/pg_query.lib ./libpg_query/windows/queryparser.lib | |
cp ./downloaded-artifacts/build-npm-artifact-ubuntu-latest/libpg_query.a ./libpg_query/linux/libpg_query.a | |
cp ./downloaded-artifacts/build-npm-artifact-macos-latest/libpg_query.a ./libpg_query/osx/libpg_query.a | |
find ./downloaded-artifacts/ | |
# rm -rf ./downloaded-artifacts | |
# find ./libpg_query | |
# - name: Publish to NPM π | |
# run: | | |
# # Assuming you've set up your package.json and .npmrc correctly | |
# npm publish | |
# env: |