File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 2828 run : npm run lint
2929 - name : Test
3030 run : npm run test
31+ - name : Verify dual module compatibility
32+ run : |
33+ node -e "require('./dist/index.js')" # Test CJS
34+ node --input-type=module -e "import * as mod from './dist/index.mjs'; console.log(typeof mod)" # Test ESM
Original file line number Diff line number Diff line change 1+ name : Publish Package to NPM
2+
3+ on :
4+ release :
5+ types : [created]
6+
7+ jobs :
8+ build-and-publish :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ - uses : actions/checkout@v4
13+
14+ - name : Use Node.js
15+ uses : actions/setup-node@v4
16+ with :
17+ node-version : ' 20.x'
18+ registry-url : ' https://registry.npmjs.org'
19+ cache : ' npm'
20+
21+ - name : Install dependencies
22+ run : npm ci
23+
24+ - name : Verify package version matches release tag
25+ run : |
26+ PKG_VERSION=$(node -p "require('./package.json').version")
27+ GITHUB_REF_NAME=${GITHUB_REF#refs/tags/}
28+ GITHUB_TAG=${GITHUB_REF_NAME#v}
29+ echo "Package version: $PKG_VERSION"
30+ echo "GitHub tag (without v): $GITHUB_TAG"
31+ if [ "$PKG_VERSION" != "$GITHUB_TAG" ] && [ "$PKG_VERSION" != "${GITHUB_TAG#v}" ]; then
32+ echo "⚠️ WARNING: GitHub release tag ($GITHUB_REF_NAME) doesn't match package.json version ($PKG_VERSION)"
33+ echo "The package will be published with the version from package.json: $PKG_VERSION"
34+ fi
35+
36+ - name : Build
37+ run : npm run build
38+
39+ - name : Test
40+ run : npm test
41+
42+ - name : Verify dual module compatibility
43+ run : |
44+ node -e "require('./dist/index.js')" # Test CJS
45+ node --input-type=module -e "import * as mod from './dist/index.mjs'; console.log(typeof mod)" # Test ESM
46+
47+ - name : Publish to NPM
48+ run : npm publish
49+ env :
50+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
You can’t perform that action at this time.
0 commit comments