Skip to content

Commit 860183b

Browse files
feat: make release workflow reusable
fix #13
1 parent 09dc605 commit 860183b

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

.github/workflows/release.yml

+18-11
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ name: Build package
77
on:
88
workflow_call:
99
inputs:
10-
package-name:
11-
description: The name of the package
12-
default: ${{github.event.repository.name}}
10+
directory:
11+
description: The working directory of the package, useful for monorepos
12+
default: .
1313
type: string
1414
secrets:
1515
NODE_AUTH_TOKEN:
@@ -42,16 +42,19 @@ jobs:
4242
run: pnpm install
4343
- name: Build x64 binary
4444
run: |
45-
pnpm -r source
46-
pnpm -r build
45+
pnpm source
46+
pnpm build
47+
working-directory: ${{inputs.directory}}
4748
- name: Test binary
48-
run: pnpm -r test
49+
run: pnpm test
50+
working-directory: ${{inputs.directory}}
4951
- name: Upload binaries
5052
uses: actions/upload-artifact@v4
5153
with:
52-
path: packages/${{inputs.package-name}}/**/parser.so
54+
path: ./**/parser.so
5355
name: prebuild-${{runner.os}}-${{runner.arch}}
5456
retention-days: 2
57+
working-directory: ${{inputs.directory}}
5558

5659
package:
5760
name: Publish NodeJS package
@@ -74,15 +77,19 @@ jobs:
7477
- name: Download binaries
7578
uses: actions/download-artifact@v4
7679
with:
77-
path: packages/${{inputs.package-name}}/prebuilds
80+
path: prebuilds
7881
pattern: prebuild-*
7982
# merge-multiple: true
83+
working-directory: ${{inputs.directory}}
8084
- name: Move sources
81-
run: pnpm -r source
85+
run: pnpm source
86+
working-directory: ${{inputs.directory}}
8287
- name: Check binaries
83-
run: tree packages/${{inputs.package-name}}
88+
run: tree
89+
working-directory: ${{inputs.directory}}
8490
- name: Publish to npm
8591
# TODO: add dry-run as a workflow input
86-
run: pnpm -r publish --dry-run
92+
run: pnpm publish --dry-run
8793
env:
8894
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
95+
working-directory: ${{inputs.directory}}

.github/workflows/trigger.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ on:
1010
description: The name of the package
1111
type: string
1212
dry-run:
13-
description: Whether to run the workflow without publishing
13+
description: Dry run (no publish)
1414
type: boolean
1515
default: false
1616

1717
jobs:
1818
npm-publish:
1919
uses: ast-grep/langs/.github/workflows/release.yml@main
2020
with:
21-
package-name: ${{inputs.package-name}}
21+
directory: packages/${{inputs.package-name}}
2222
secrets:
2323
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}

0 commit comments

Comments
 (0)