Skip to content

Commit a9b84ec

Browse files
committed
chore: add release workflow
1 parent 5bc1b5d commit a9b84ec

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Changesets
2+
on:
3+
push:
4+
branches:
5+
- v-next
6+
7+
jobs:
8+
changesetcheck:
9+
name: Changeset Check
10+
runs-on: ubuntu-latest
11+
outputs:
12+
CHANGESETS: ${{ steps.changesetcheck.outputs.CHANGESETS }}
13+
steps:
14+
- name: checkout code repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- uses: pnpm/action-setup@v4
19+
with:
20+
version: 9
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: 22
24+
cache: "pnpm"
25+
- name: Install
26+
run: pnpm install --no-frozen-lockfile
27+
- name: Changeset Check
28+
id: changesetcheck
29+
run: |
30+
pnpm changeset status --output=changes.json
31+
32+
if grep "\"releases\": \[\]," changes.json; then
33+
echo "changesets=notfound" >> "$GITHUB_OUTPUT"
34+
else
35+
echo "changesets=found" >> "$GITHUB_OUTPUT"
36+
fi
37+
38+
release:
39+
name: Release
40+
runs-on: ubuntu-latest
41+
needs: changesetcheck
42+
permissions:
43+
contents: write
44+
id-token: write
45+
steps:
46+
- name: Stop on no changesets
47+
if: needs.changesetcheck.outputs.CHANGESETS == 'notfound'
48+
run: |
49+
echo "No changesets found. Exiting the workflow."
50+
exit 0
51+
52+
- name: checkout code repository
53+
uses: actions/checkout@v4
54+
if: needs.changesetcheck.outputs.CHANGESETS == 'found'
55+
with:
56+
fetch-depth: 0
57+
- uses: pnpm/action-setup@v4
58+
if: needs.changesetcheck.outputs.CHANGESETS == 'found'
59+
with:
60+
version: 9
61+
- uses: actions/setup-node@v4
62+
if: needs.changesetcheck.outputs.CHANGESETS == 'found'
63+
with:
64+
node-version: 22
65+
cache: "pnpm"
66+
- name: Install
67+
if: needs.changesetcheck.outputs.CHANGESETS == 'found'
68+
run: pnpm install --no-frozen-lockfile
69+
- name: Apply and commit changesets
70+
if: needs.changesetcheck.outputs.CHANGESETS == 'found'
71+
run: |
72+
echo "Changesets found. Starting release."
73+
pnpm changeset version
74+
git config --global user.name "Github Actions"
75+
git config --global user.email "[email protected]"
76+
git commit -a -m "chore: v-next version bump"
77+
git push
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
- name: Setup npmrc
81+
if: needs.changesetcheck.outputs.CHANGESETS == 'found'
82+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.VNEXT_NPM_TOKEN }}" > .npmrc
83+
- name: Publish
84+
if: needs.changesetcheck.outputs.CHANGESETS == 'found'
85+
run: pnpm publish -r --no-git-checks --tag next --access public --dry-run
86+
env:
87+
NPM_CONFIG_PROVENANCE: true
88+
- name: push tags
89+
if: needs.changesetcheck.outputs.CHANGESETS == 'found'
90+
run: git push --follow-tags
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)