Build package (npm) #9
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: | |
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: prebuilds-${{runner.os}} | |
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: Download binaries | |
uses: actions/download-artifact@v4 | |
with: | |
path: prebuilds | |
pattern: prebuilds-* | |
merge-multiple: true | |
- name: Check binaries | |
run: tree prebuilds | |
# - name: Publish to npm | |
# run: npm publish | |
# env: | |
# NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} |