-
Notifications
You must be signed in to change notification settings - Fork 0
223 lines (194 loc) · 7.3 KB
/
release.yml
File metadata and controls
223 lines (194 loc) · 7.3 KB
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: Release
on:
workflow_dispatch:
inputs:
bump:
description: "patch: bug fixes (0.1.0→0.1.1) | minor: new features (0.1.0→0.2.0) | major: breaking changes (0.1.0→1.0.0)"
type: choice
default: "patch"
options:
- patch
- minor
- major
release_core:
description: "Release @mondaycom/hatcha-core"
type: boolean
default: true
release_server:
description: "Release @mondaycom/hatcha-server"
type: boolean
default: true
release_react:
description: "Release @mondaycom/hatcha-react"
type: boolean
default: true
permissions:
contents: write
id-token: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: pnpm
registry-url: "https://registry.npmjs.org"
- run: pnpm install --frozen-lockfile
- name: Validate selection
env:
RELEASE_CORE: ${{ inputs.release_core }}
RELEASE_SERVER: ${{ inputs.release_server }}
RELEASE_REACT: ${{ inputs.release_react }}
run: |
if [[ "$RELEASE_CORE" != "true" && \
"$RELEASE_SERVER" != "true" && \
"$RELEASE_REACT" != "true" ]]; then
echo "::error::No packages selected for release"
exit 1
fi
if [[ "$RELEASE_CORE" != "true" ]]; then
if [[ "$RELEASE_SERVER" == "true" || "$RELEASE_REACT" == "true" ]]; then
echo "::error::Cannot release server/react without core. Core must be included to ensure dependency versions are correct."
exit 1
fi
fi
- name: Bump versions
id: versions
env:
BUMP: ${{ inputs.bump }}
RELEASE_CORE: ${{ inputs.release_core }}
RELEASE_SERVER: ${{ inputs.release_server }}
RELEASE_REACT: ${{ inputs.release_react }}
run: |
if [[ "$RELEASE_CORE" == "true" ]]; then
cd packages/core
NEW_VERSION=$(npm version "$BUMP" --no-git-tag-version)
echo "core_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
echo "Core bumped to ${NEW_VERSION}"
cd ../..
fi
if [[ "$RELEASE_SERVER" == "true" ]]; then
cd packages/server
NEW_VERSION=$(npm version "$BUMP" --no-git-tag-version)
echo "server_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
echo "Server bumped to ${NEW_VERSION}"
cd ../..
fi
if [[ "$RELEASE_REACT" == "true" ]]; then
cd packages/react
NEW_VERSION=$(npm version "$BUMP" --no-git-tag-version)
echo "react_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
echo "React bumped to ${NEW_VERSION}"
cd ../..
fi
- name: Update lockfile
run: pnpm install --no-frozen-lockfile
- name: Build
run: pnpm build
- name: Test
run: pnpm test
- name: Typecheck
run: pnpm typecheck
- name: Publish core
if: inputs.release_core
run: pnpm --filter @mondaycom/hatcha-core publish --no-git-checks --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish server
if: inputs.release_server
run: pnpm --filter @mondaycom/hatcha-server publish --no-git-checks --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish react
if: inputs.release_react
run: pnpm --filter @mondaycom/hatcha-react publish --no-git-checks --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Commit and tag
env:
CORE_VERSION: ${{ steps.versions.outputs.core_version }}
SERVER_VERSION: ${{ steps.versions.outputs.server_version }}
REACT_VERSION: ${{ steps.versions.outputs.react_version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add packages/*/package.json pnpm-lock.yaml
MSG="release [skip ci]:"
TAGS=()
if [[ -n "$CORE_VERSION" ]]; then
MSG="${MSG} core@${CORE_VERSION}"
TAGS+=("@mondaycom/hatcha-core@${CORE_VERSION}")
fi
if [[ -n "$SERVER_VERSION" ]]; then
MSG="${MSG} server@${SERVER_VERSION}"
TAGS+=("@mondaycom/hatcha-server@${SERVER_VERSION}")
fi
if [[ -n "$REACT_VERSION" ]]; then
MSG="${MSG} react@${REACT_VERSION}"
TAGS+=("@mondaycom/hatcha-react@${REACT_VERSION}")
fi
git commit -m "${MSG}"
for TAG in "${TAGS[@]}"; do
git tag "${TAG}"
done
git push origin HEAD --tags --atomic
- name: Create GitHub Releases
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CORE_VERSION: ${{ steps.versions.outputs.core_version }}
SERVER_VERSION: ${{ steps.versions.outputs.server_version }}
REACT_VERSION: ${{ steps.versions.outputs.react_version }}
run: |
LAST_TAG=""
if [[ -n "$CORE_VERSION" ]]; then
LAST_TAG="@mondaycom/hatcha-core@${CORE_VERSION}"
gh release create "$LAST_TAG" \
--title "hatcha-core ${CORE_VERSION}" \
--generate-notes \
--latest=false
fi
if [[ -n "$SERVER_VERSION" ]]; then
LAST_TAG="@mondaycom/hatcha-server@${SERVER_VERSION}"
gh release create "$LAST_TAG" \
--title "hatcha-server ${SERVER_VERSION}" \
--generate-notes \
--latest=false
fi
if [[ -n "$REACT_VERSION" ]]; then
LAST_TAG="@mondaycom/hatcha-react@${REACT_VERSION}"
gh release create "$LAST_TAG" \
--title "hatcha-react ${REACT_VERSION}" \
--generate-notes \
--latest=false
fi
# Mark the last release as "Latest"
if [[ -n "$LAST_TAG" ]]; then
gh release edit "$LAST_TAG" --latest
fi
- name: Summary
env:
CORE_VERSION: ${{ steps.versions.outputs.core_version }}
SERVER_VERSION: ${{ steps.versions.outputs.server_version }}
REACT_VERSION: ${{ steps.versions.outputs.react_version }}
run: |
echo "## Release Summary" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Package | Version |" >> "$GITHUB_STEP_SUMMARY"
echo "|---------|---------|" >> "$GITHUB_STEP_SUMMARY"
if [[ -n "$CORE_VERSION" ]]; then
echo "| @mondaycom/hatcha-core | ${CORE_VERSION} |" >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$SERVER_VERSION" ]]; then
echo "| @mondaycom/hatcha-server | ${SERVER_VERSION} |" >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$REACT_VERSION" ]]; then
echo "| @mondaycom/hatcha-react | ${REACT_VERSION} |" >> "$GITHUB_STEP_SUMMARY"
fi