Skip to content

Build package

Build package #20

Workflow file for this run

# Recreated from
# https://github.com/tree-sitter/workflows/blob/0ddf14c2d6cb042a24f9b9bd9c2912f811aac862/.github/workflows/package-npm.yml
name: Build package (npm)
on:
# push:
# branches:
# - main
workflow_dispatch:
inputs:
package-name:
description: The name of the package
type: string
workflow_call:
inputs:
package-name:
description: The name of the package
default: ${{github.event.repository.name}}
type: string
secrets:
NODE_AUTH_TOKEN:
description: An authentication token for npm
required: true
jobs:
prebuild:
name: Build NodeJS binaries on ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os:
- "ubuntu-20.04"
- windows-latest
- macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
cache: pnpm
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install
- name: Build x64 binary
run: pnpm -r build
- name: Test binary
run: pnpm -r test
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
path: packages/${{inputs.package-name}}/**/parser.so
name: prebuild-${{runner.os}}-${{runner.arch}}
retention-days: 2
package:
name: Publish NodeJS package
needs: [prebuild]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
cache: pnpm
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install
- name: Download binaries
uses: actions/download-artifact@v4
with:
path: packages/${{inputs.package-name}}/prebuilds
pattern: prebuild-*
# merge-multiple: true
- name: Check binaries
run: tree packages/${{inputs.package-name}}
- name: Publish to npm
# TODO: add dry-run as a workflow input
run: pnpm -r publish --dry-run
env:
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}