-
Notifications
You must be signed in to change notification settings - Fork 7
148 lines (123 loc) · 4.17 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
name: Release
on:
push:
branches:
- dev
- main
jobs:
detect-changes-and-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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
- name: Check if lasereyes package changed
id: check_changes
run: |
git diff --quiet HEAD^ HEAD -- packages/lasereyes || echo "changed=true" >> $GITHUB_ENV
# Automatically add a changeset if changes are detected
- name: Add Changeset if lasereyes package changed
if: env.changed == 'true'
run: |
pnpm dlx changeset add --empty --force --commit \
--message "chore: auto-bump lasereyes version"
# Enter pre-release mode for RC if on dev
- name: Run Changesets pre-release mode for RC
if: github.ref == 'refs/heads/dev' && env.changed == 'true'
run: |
pnpm dlx @changesets/cli pre enter rc
pnpm dlx @changesets/cli version
# Commit version bump
- name: Commit version bumps and changelog
if: github.ref == 'refs/heads/dev' && env.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: detect-changes-and-version
if: github.ref == 'refs/heads/dev' && env.changed == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: pnpm install
- name: Publish RC to npm
run: pnpm publish --tag rc --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
changeset-stable-version:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && env.changed == 'true'
needs: publish-rc-release
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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
- name: Exit pre-release mode
run: pnpm dlx @changesets/cli pre exit
- name: Run Changesets version for stable
run: pnpm dlx @changesets/cli version
- name: Commit version bumps and changelog for stable
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 for lasereyes"
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' && env.changed == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: pnpm install
- name: Publish stable release to npm
run: pnpm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- 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 }}