Build package #1
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
# 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: null | |
workflow_call: | |
inputs: | |
package-name: | |
description: The name of the package | |
default: ${{github.event.repository.name}} | |
type: string | |
environment-name: | |
description: The name of the environment | |
default: npm | |
type: string | |
node-version: | |
description: The NodeJS version | |
default: ${{vars.NODE_VERSION || '20'}} | |
type: string | |
ubuntu-version: | |
description: The version of the Ubuntu runner image | |
default: ${{vars.UBUNTU_VERSION || '20.04'}} | |
type: string | |
generate: | |
description: Generate the parser artifacts | |
default: false | |
type: boolean | |
secrets: | |
NODE_AUTH_TOKEN: | |
description: An authentication token for npm | |
required: true | |
jobs: | |
build_node: | |
name: Build NodeJS binaries on ${{matrix.os}} | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: | |
- "ubuntu-${{inputs.ubuntu-version}}" | |
- windows-latest | |
- macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- 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/**/parser.so | |
name: parsers-${{runner.os}} | |
retention-days: 2 | |
# package: | |
# name: Publish NodeJS package | |
# needs: [build_wasm, build_node] | |
# runs-on: ubuntu-${{inputs.ubuntu-version}} | |
# environment: | |
# name: ${{inputs.environment-name}} | |
# url: https://www.npmjs.com/package/${{inputs.package-name}} | |
# steps: | |
# - name: Checkout repository | |
# uses: actions/checkout@v4 | |
# - name: Set up NodeJS | |
# uses: actions/setup-node@v4 | |
# with: | |
# cache: npm | |
# node-version: ${{inputs.node-version}} | |
# registry-url: https://registry.npmjs.org/ | |
# - name: Download binaries | |
# uses: actions/download-artifact@v4 | |
# with: | |
# path: prebuilds | |
# pattern: prebuilds-* | |
# merge-multiple: true | |
# - name: Check binaries | |
# run: tree prebuilds | |
# - name: Move Wasm binaries to root | |
# continue-on-error: true | |
# run: mv -v prebuilds/*.wasm . | |
# - name: Publish to npm | |
# run: npm publish | |
# env: | |
# NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} |