@@ -2,36 +2,73 @@ name: Publish
22
33on :
44 workflow_call :
5+ push :
6+ branches :
7+ - chore/use-explicit-publishing
8+
9+ concurrency :
10+ group : publish
11+ cancel-in-progress : false
512
613jobs :
714 publish :
815 runs-on : ubuntu-latest
16+ environment : npm
17+
18+ permissions :
19+ contents : write
20+ id-token : write
21+
922 steps :
1023 - name : Checkout code
1124 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
25+ with :
26+ fetch-depth : 0
27+
1228 - name : Setup node
1329 uses : actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
1430 with :
1531 node-version : 24
1632 cache : npm
17- cache-dependency-path : " patches/*.patch"
33+ cache-dependency-path : |
34+ package-lock.json
35+ patches/*.patch
1836 registry-url : " https://registry.npmjs.org"
37+
1938 - name : Install dependencies
2039 run : npm ci --ignore-scripts && npm run patch-package
21- - name : Creating .npmrc
40+
41+ - name : Version packages with changeset
42+ id : version
2243 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
44+ git config user.name "github-actions[bot]"
45+ git config user.email "github-actions[bot]@users.noreply.github.com"
46+ npx changeset version
47+ if [ -n "$(git status --porcelain)" ]; then
48+ git add .
49+ git commit -m "[ci] release"
50+ git push
51+ echo "has_changes=true" >> $GITHUB_OUTPUT
52+ VERSION=$(node -p "require('./package.json').version")
53+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
54+ else
55+ echo "has_changes=false" >> $GITHUB_OUTPUT
56+ fi
57+
58+ - name : Build package
59+ if : steps.version.outputs.has_changes == 'true'
60+ run : npm run build
61+
62+ - name : Publish to npm
63+ if : steps.version.outputs.has_changes == 'true'
64+ run : npm publish --provenance --access public
65+
66+ - name : Create GitHub Release
67+ if : steps.version.outputs.has_changes == 'true'
68+ uses : softprops/action-gh-release@v2
3169 with :
32- version : npm run changeset:version
33- publish : npm run changeset:publish
34- commit : " [ci] release"
35- title : " [ci] release"
70+ tag_name : v${{ steps.version.outputs.version }}
71+ name : v${{ steps.version.outputs.version }}
72+ generate_release_notes : true
3673 env :
3774 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments