Skip to content

Commit a47d5cd

Browse files
committed
chore: add release workflow
1 parent 28acf11 commit a47d5cd

File tree

1 file changed

+94
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)