44 push :
55 branches :
66 - main
7- pull_request :
8- branches :
9- - main
7+
8+ concurrency : ${{ github.workflow }}-${{ github.ref }}
109
1110permissions :
1211 contents : write
13- pull-requests : read
12+ pull-requests : write
1413 id-token : write
1514
1615jobs :
@@ -32,14 +31,14 @@ jobs:
3231 - name : Install dependencies
3332 run : bun install
3433
35- - name : Build project
34+ - name : Build workspace
3635 run : bun run build
3736
3837 - name : Run tests
3938 run : bun run test
4039
41- publish :
42- name : Publish to NPM
40+ release :
41+ name : Changesets Release
4342 runs-on : ubuntu-latest
4443 needs : test
4544 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
@@ -60,97 +59,23 @@ jobs:
6059 uses : actions/setup-node@v4
6160 with :
6261 node-version : lts/*
63- registry-url : ' https://registry.npmjs.org'
64-
65- - name : Get current version
66- id : current_version
67- run : |
68- VERSION=$(node -p "require('./package.json').version")
69- echo "version=$VERSION" >> $GITHUB_OUTPUT
70- echo "Current version: $VERSION"
71-
72- - name : Detect prerelease tag
73- id : prerelease_tag
74- run : |
75- VERSION="${{ steps.current_version.outputs.version }}"
76-
77- # Check if version contains a prerelease identifier (e.g., -alpha, -beta, -rc)
78- if [[ "$VERSION" =~ -([a-zA-Z]+)\. ]]; then
79- TAG="${BASH_REMATCH[1]}"
80- echo "tag=$TAG" >> $GITHUB_OUTPUT
81- echo "is_prerelease=true" >> $GITHUB_OUTPUT
82- echo "📦 Detected prerelease version: $VERSION → dist-tag: $TAG"
83- else
84- echo "tag=latest" >> $GITHUB_OUTPUT
85- echo "is_prerelease=false" >> $GITHUB_OUTPUT
86- echo "📦 Stable version: $VERSION → dist-tag: latest"
87- fi
88-
89- - name : Check if version is published
90- id : check_published
91- run : |
92- PACKAGE_NAME=$(node -p "require('./package.json').name")
93- VERSION="${{ steps.current_version.outputs.version }}"
94-
95- if npm view "$PACKAGE_NAME@$VERSION" version 2>/dev/null; then
96- echo "published=true" >> $GITHUB_OUTPUT
97- echo "📦 Version $VERSION is already published to npm"
98- else
99- echo "published=false" >> $GITHUB_OUTPUT
100- echo "✨ Version $VERSION is not published yet"
101- fi
62+ registry-url : " https://registry.npmjs.org"
10263
10364 - name : Install dependencies
104- if : steps.check_published.outputs.published == 'false'
10565 run : bun install
10666
107- - name : Build package
108- if : steps.check_published.outputs.published == 'false'
109- run : bun run prepack
110-
111- - name : Publish to NPM
112- if : steps.check_published.outputs.published == 'false'
113- run : npm publish --provenance --access public --tag ${{ steps.prerelease_tag.outputs.tag }}
114- env :
115- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
116-
117- - name : Skip publishing
118- if : steps.check_published.outputs.published == 'true'
119- run : |
120- echo "⏭️ Skipping npm publish - version ${{ steps.current_version.outputs.version }} already published"
121-
122- outputs :
123- version : ${{ steps.current_version.outputs.version }}
124- should_release : ${{ steps.check_published.outputs.published == 'false' }}
67+ - name : Build publishable packages
68+ run : bunx turbo run build --filter={./packages/*}
12569
126- release :
127- name : Create GitHub Release
128- runs-on : ubuntu-latest
129- needs : publish
130- if : needs.publish.outputs.should_release == 'true'
131-
132- steps :
133- - name : Checkout code
134- uses : actions/checkout@v4
135- with :
136- fetch-depth : 0
137- fetch-tags : true
138-
139- - name : Setup Node.js
140- uses : actions/setup-node@v4
70+ - name : Create Release Pull Request or Publish
71+ uses : changesets/action@v1
14172 with :
142- node-version : lts/*
143-
144- - name : Create and push tag
145- run : |
146- git config user.name "github-actions[bot]"
147- git config user.email "github-actions[bot]@users.noreply.github.com"
148- git tag -a "v${{ needs.publish.outputs.version }}" -m "Release v${{ needs.publish.outputs.version }}"
149- git push origin "v${{ needs.publish.outputs.version }}"
150- env :
151- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
152-
153- - name : Generate changelog and create release
154- run : npx changelogithub
73+ version : bun run version
74+ publish : bunx changeset publish --access public
75+ commit : " chore: version packages"
76+ title : " chore: version packages"
77+ createGithubReleases : true
15578 env :
15679 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
81+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments