-
Notifications
You must be signed in to change notification settings - Fork 13
103 lines (99 loc) · 2.89 KB
/
Copy pathrelease.yml
File metadata and controls
103 lines (99 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Recreated from
# https://github.com/tree-sitter/workflows/blob/0ddf14c2d6cb042a24f9b9bd9c2912f811aac862/.github/workflows/package-npm.yml
# This is a reusable and reference workflow for parsers
name: Build package
on:
workflow_call:
inputs:
directory:
description: The working directory of the package, useful for monorepos
default: .
type: string
dry-run:
description: Dry run (no publish)
type: boolean
default: false
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-latest
- 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
node-version: ">= 21"
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install
- name: Build x64 binary
run: |
pnpm source
pnpm build
working-directory: ${{inputs.directory}}
- name: Test binary
run: pnpm test
working-directory: ${{inputs.directory}}
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
path: ${{inputs.directory}}/**/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
node-version: ">= 21"
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install
- name: Download binaries
uses: actions/download-artifact@v4
with:
path: ${{inputs.directory}}/prebuilds
pattern: prebuild-*
# merge-multiple: true
- name: Move sources
run: pnpm source
working-directory: ${{inputs.directory}}
- name: Check binaries
run: tree
working-directory: ${{inputs.directory}}
- name: Publish Dry Run
run: pnpm publish --dry-run
if: ${{ inputs.dry-run }}
working-directory: ${{inputs.directory}}
- name: Publish to npm
run: pnpm publish
if: ${{ !inputs.dry-run }}
env:
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
working-directory: ${{inputs.directory}}