Repository navigation
105 lines (84 loc) · 2.94 KB
/
Copy pathpublish.yml
File metadata and controls
105 lines (84 loc) · 2.94 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
104
105
name: Publish to npm
on:
release:
types: [published]
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
cache: 'npm'
- name: Validate version
run: |
# Extract version from package.json
PACKAGE_VERSION=$(node -p "require('./package.json').version")
# Extract version from GitHub release tag (remove 'v' prefix if present)
RELEASE_VERSION=${GITHUB_REF_NAME#v}
echo "Package version: $PACKAGE_VERSION"
echo "Release version: $RELEASE_VERSION"
if [ "$PACKAGE_VERSION" != "$RELEASE_VERSION" ]; then
echo "❌ Error: package.json version ($PACKAGE_VERSION) does not match release tag ($RELEASE_VERSION)"
echo "Please ensure package.json version is updated before creating a release"
exit 1
fi
echo "✅ Version validation passed"
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Run type checking
run: npm run type-check
- name: Check formatting
run: npm run format:check
- name: Build library
run: npm run build
- name: Build widget
run: npm run build:widget
- name: Pack npm artifact
run: |
mkdir -p "$RUNNER_TEMP/npm-package"
npm pack --ignore-scripts --pack-destination "$RUNNER_TEMP/npm-package"
- name: Upload npm artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: npm-package
path: ${{ runner.temp }}/npm-package/*.tgz
if-no-files-found: error
retention-days: 1
publish:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
id-token: write
steps:
# Keep package code and caches out of the job with publishing authority.
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false
- name: Download npm artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: npm-package
path: .release
- name: Publish npm artifact
run: |
tarballs=(.release/*.tgz)
if [[ ${#tarballs[@]} -ne 1 || ! -f "${tarballs[0]}" ]]; then
echo "::error::Expected exactly one npm package tarball."
exit 1
fi
npm publish "${tarballs[0]}" --access public --ignore-scripts