Skip to content

Commit f49bdd2

Browse files
committed
enhance export surface
1 parent 746bc8e commit f49bdd2

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
registry-url: 'https://registry.npmjs.org/'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Build
26+
run: npm run build
27+
28+
- name: Determine npm tag
29+
id: tag
30+
run: |
31+
# Extract tag name without "refs/tags/"
32+
TAG_REF=${GITHUB_REF#refs/tags/}
33+
echo "Detected Git tag: $TAG_REF"
34+
35+
# Determine npm tag
36+
if [[ "$TAG_REF" == *-* ]]; then
37+
# prerelease (contains a hyphen)
38+
NPM_TAG=$(echo "$TAG_REF" | sed -E 's/^v[0-9]+\.[0-9]+\.[0-9]+-([a-zA-Z0-9]+).*/\1/')
39+
else
40+
NPM_TAG="latest"
41+
fi
42+
echo "npm publish will use tag: $NPM_TAG"
43+
echo "tag=$NPM_TAG" >> $GITHUB_OUTPUT
44+
45+
- name: Publish to npm
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
run: npm publish --tag ${{ steps.tag.outputs.tag }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.*
2+
3+
!/.github
24
!/.gitignore
35
node_modules

0 commit comments

Comments
 (0)