@@ -3,35 +3,67 @@ name: Publish
33on :
44 workflow_call :
55
6+ concurrency :
7+ group : publish
8+ cancel-in-progress : false
9+
610jobs :
711 publish :
812 runs-on : ubuntu-latest
13+ environment : npm
14+
15+ permissions :
16+ contents : write
17+ id-token : write
18+
919 steps :
1020 - name : Checkout code
1121 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
22+ with :
23+ fetch-depth : 0
24+
1225 - name : Setup node
1326 uses : actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
1427 with :
1528 node-version : 24
1629 cache : npm
17- cache-dependency-path : " patches/*.patch"
30+ cache-dependency-path : " patches/*.patch, package-lock.json "
1831 registry-url : " https://registry.npmjs.org"
32+
1933 - name : Install dependencies
2034 run : npm ci --ignore-scripts && npm run patch-package
21- - name : Creating .npmrc
35+
36+ - name : Version packages with changeset
37+ id : version
2238 run : |
23- cat << EOF > "$HOME/.npmrc"
24- //registry.npmjs.org/:_authToken=$NPM_TOKEN
25- EOF
26- env :
27- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
28- - name : Release
29- id : changesets
30- uses : changesets/action@v1
39+ git config user.name "github-actions[bot]"
40+ git config user.email "github-actions[bot]@users.noreply.github.com"
41+ npx changeset version
42+ if [ -n "$(git status --porcelain)" ]; then
43+ git add .
44+ git commit -m "[ci] release"
45+ git push
46+ echo "has_changes=true" >> $GITHUB_OUTPUT
47+ VERSION=$(node -p "require('./package.json').version")
48+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
49+ else
50+ echo "has_changes=false" >> $GITHUB_OUTPUT
51+ fi
52+
53+ - name : Build package
54+ if : steps.version.outputs.has_changes == 'true'
55+ run : npm run build
56+
57+ - name : Publish to npm
58+ if : steps.version.outputs.has_changes == 'true'
59+ run : npm publish --provenance --access public
60+
61+ - name : Create GitHub Release
62+ if : steps.version.outputs.has_changes == 'true'
63+ uses : softprops/action-gh-release@v2
3164 with :
32- version : npm run changeset:version
33- publish : npm run changeset:publish
34- commit : " [ci] release"
35- title : " [ci] release"
65+ tag_name : v${{ steps.version.outputs.version }}
66+ name : v${{ steps.version.outputs.version }}
67+ generate_release_notes : true
3668 env :
3769 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments