-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (49 loc) · 1.76 KB
/
publish-trusted.yml
File metadata and controls
58 lines (49 loc) · 1.76 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
name: Publish Package (Trusted Publishing)
on:
push:
tags:
- 'v*'
permissions:
id-token: write # Required for OIDC trusted publishing
contents: read
jobs:
publish:
name: Publish to npm with Trusted Publishing
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup environment
uses: ./.github/actions/setup
with:
node-version: '22.x'
# Ensure npm 11.5.1 or later is installed for trusted publishing support
- name: Update npm to latest version
run: npm install -g npm@latest
- name: Build package
run: pnpm run build
env:
WAHA_URL: 'skip' # Skip fetching during publish, use committed types
- name: Verify build artifacts
run: |
if [ ! -f "dist/index.esm.js" ]; then
echo "ERROR: Build artifacts missing - dist/index.esm.js not found"
exit 1
fi
echo "✓ Build artifacts verified"
ls -la dist/
# Publish using OIDC authentication (no NPM_TOKEN needed)
# Prereleases are published with extracted tag (e.g., v1.0.0-dev.1 → --tag dev)
- name: Publish to npm
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
if [[ "$VERSION" == *"-"* ]]; then
# Extract tag name: 1.0.0-dev.1 → dev, 1.0.0-beta.2 → beta
PRERELEASE="${VERSION#*-}" # dev.1 or beta.2
TAG="${PRERELEASE%%.*}" # dev or beta
echo "Publishing prerelease version $VERSION with --tag $TAG"
npm publish --access public --no-git-checks --tag "$TAG"
else
echo "Publishing stable version $VERSION"
npm publish --access public --no-git-checks
fi