Skip to content

Commit 236eff0

Browse files
authored
ci: add misc npm publish workflow (#11764)
## Summary - Add a new workflow named `Publish misc packages`. - Support manual publishing of `@swc/types` and `@swc/helpers` via `workflow_dispatch`. - Add a branch guard so the workflow only runs from `main`. ## Details - Add an `npmTag` input with `latest` and `nightly` options. - Use a matrix strategy to publish both packages in parallel. - Keep trusted publish settings with `id-token: write`, `environment: publish`, and an npm upgrade step. - Publish with `yarn npm publish --access public --tag ... --tolerate-republish`.
1 parent 169c961 commit 236eff0

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "Publish misc packages"
2+
run-name: "Publish misc packages (${{ inputs.npmTag }})"
3+
4+
env:
5+
# https://github.com/actions/setup-node/issues/899#issuecomment-1819151595
6+
SKIP_YARN_COREPACK_CHECK: 1
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
on:
13+
workflow_dispatch:
14+
inputs:
15+
npmTag:
16+
description: "NPM dist-tag used for publishing"
17+
required: true
18+
type: choice
19+
default: latest
20+
options:
21+
- latest
22+
- nightly
23+
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
publish:
30+
name: "Publish ${{ matrix.package.name }}"
31+
runs-on: ubuntu-latest
32+
environment: publish
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
package:
37+
- name: "@swc/types"
38+
dir: "packages/types"
39+
- name: "@swc/helpers"
40+
dir: "packages/helpers"
41+
steps:
42+
- name: Ensure workflow runs from main
43+
shell: bash
44+
run: |
45+
if [[ "${GITHUB_REF}" != "refs/heads/main" ]]; then
46+
echo "This workflow can only run from refs/heads/main. Current ref: ${GITHUB_REF}"
47+
exit 1
48+
fi
49+
50+
- uses: actions/checkout@v5
51+
52+
- uses: ./.github/actions/setup-node
53+
54+
- name: Update npm to latest
55+
shell: bash
56+
run: npm install -g npm@latest
57+
58+
- name: Log package version
59+
shell: bash
60+
working-directory: ${{ matrix.package.dir }}
61+
run: |
62+
version="$(node -p "require('./package.json').version")"
63+
echo "Publishing ${{ matrix.package.name }}@${version} with npm tag '${{ inputs.npmTag }}'"
64+
65+
- name: Publish
66+
shell: bash
67+
working-directory: ${{ matrix.package.dir }}
68+
run: yarn npm publish --access public --tag "${{ inputs.npmTag }}" --tolerate-republish
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)