-
Notifications
You must be signed in to change notification settings - Fork 9
189 lines (161 loc) · 5.42 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Release
on:
push:
branches:
- dev
- main
permissions:
contents: write # Grants write permissions to push commits
jobs:
changeset-rc-version:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.6
- name: Install dependencies
run: pnpm install
# Check if lasereyes package has changed
- name: Check if lasereyes package changed
id: lasereyes-changes
run: |
if git diff --name-only HEAD^1 HEAD | grep -q "packages/lasereyes/"; then
echo "Lasereyes package changed."
echo "::set-output name=changed::true"
else
echo "Lasereyes package did not change."
echo "::set-output name=changed::false"
fi
# Check if already in pre-release mode, and exit if necessary
- name: Exit pre-release mode if active
if: steps.lasereyes-changes.outputs.changed == 'true'
run: |
if [ -f ".changeset/pre.json" ]; then
echo "Exiting pre-release mode"
pnpm dlx @changesets/cli pre exit
else
echo "Not in pre-release mode"
fi
# Enter pre-release mode and version bump for lasereyes package
- name: Run Changesets pre-release mode for RC
if: steps.lasereyes-changes.outputs.changed == 'true'
run: |
pnpm dlx @changesets/cli pre enter rc # Enter RC mode
pnpm dlx @changesets/cli version # Bump RC version for lasereyes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Commit version bumps and changelog
- name: Commit version bumps and changelog
if: steps.lasereyes-changes.outputs.changed == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "RC version bump for lasereyes"
git push origin dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-rc-release:
runs-on: ubuntu-latest
needs: changeset-rc-version
if: needs.changeset-rc-version.outputs.changed == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.6
- name: Install dependencies
run: pnpm install
# Publish only the lasereyes RC version to npm
- name: Publish RC to npm
run: pnpm publish --tag rc --access public --filter "lasereyes"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
changeset-stable-version:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: publish-rc-release
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.6
- name: Install dependencies
run: pnpm install
# Exit pre-release mode
- name: Exit RC mode
run: pnpm dlx @changesets/cli pre exit
# Run Changesets version to bump versions and generate changelogs for stable release
- name: Run Changesets version
run: pnpm dlx @changesets/cli version
# Commit the stable version bump and changelog
- name: Commit version bumps and changelog
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Stable version bump"
git push origin main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-stable-release:
runs-on: ubuntu-latest
needs: changeset-stable-version
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.6
- name: Install dependencies
run: pnpm install
# Publish the stable version of lasereyes to npm
- name: Publish stable release to npm
run: pnpm publish --access public --filter "lasereyes"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Create a GitHub Release with the summarized release notes
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ github.sha }}
release_name: "Stable Release ${{ github.sha }}"
body_path: releases/main_summary_notes_$(date +'%Y-%m-%d').md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}