This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
289 lines (248 loc) · 8.34 KB
/
create-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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# Build binaries for macOS and Linux, publish Node.js packages, create release
name: build-publish-release
on:
push:
tags:
- 'v*.*.*'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: Lastin/setup-rome@v0.5
with:
version: 11.0.0
- run: rome ci .
build-macos:
needs: [lint]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Setup
uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Package
run: |
npm ci
npm run build
npm run package:macos
- name: Create tarball
run: |
mv bin/macos/baselime baselime
tar -cvzf baselime-darwin-x64-"$RELEASE_VERSION".tar.gz baselime
- name: Upload tarball artifact
uses: actions/upload-artifact@v2
with:
name: bin-macos
path: baselime-darwin-x64-${{ env.RELEASE_VERSION }}.tar.gz
build-linux:
needs: [lint]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Setup
uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Package
run: |
npm ci
npm run build
npm run package:linux
- name: Create tarball
run: |
mv bin/linux/baselime baselime
tar -cvzf baselime-linux-x64-"$RELEASE_VERSION".tar.gz baselime
- name: Upload tarball artifact
uses: actions/upload-artifact@v2
with:
name: bin-linux
path: baselime-linux-x64-${{ env.RELEASE_VERSION }}.tar.gz
publish-node-packages:
needs: [lint]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup
uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Build and publish to npm registry
continue-on-error: true
run: |
npm ci
npm run build
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com'
scope: "@baselime"
- run: echo "registry=https://npm.pkg.github.com/@baselime" >> .npmrc
- name: Publish to GitHub registry
continue-on-error: true
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create-release:
needs: [build-macos, build-linux, publish-node-packages]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set current date
run: |
echo "RELEASE_DATE=$(date +"%d %B %Y")" >> $GITHUB_ENV
- name: Download macos tarball
uses: actions/download-artifact@v2
with:
name: bin-macos
- name: Download linux tarball
uses: actions/download-artifact@v2
with:
name: bin-linux
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_level: none
version: ${{ steps.tag_name.outputs.current_version }}
path: ./CHANGELOG.md
- name: Compute checksums
run: |
echo "## ${{ env.RELEASE_VERSION }} (${{ env.RELEASE_DATE }})" >> checksums.md
echo "${{ steps.changelog_reader.outputs.changes }}" >> checksums.md
echo "" >> checksums.md
echo "" >> checksums.md
sha256sum baselime-darwin-x64-${{ env.RELEASE_VERSION }}.tar.gz >> checksums.md
sha256sum baselime-linux-x64-${{ env.RELEASE_VERSION }}.tar.gz >> checksums.md
- name: Release
uses: softprops/action-gh-release@v1
with:
prerelease: false
body_path: checksums.md
files: |
LICENSE
baselime-darwin-x64-${{ env.RELEASE_VERSION }}.tar.gz
baselime-linux-x64-${{ env.RELEASE_VERSION }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
homebrew-release:
needs: [create-release]
runs-on: ubuntu-latest
steps:
- name: Extract version
id: extract-version
run: |
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
- uses: mislav/bump-homebrew-formula-action@v2
if: "!contains(github.ref, '-')" # skip prereleases
with:
formula-name: baselime
formula-path: Formula/baselime.rb
homebrew-tap: Baselime/homebrew-tap
base-branch: master
download-url: https://github.com/baselime/cli/releases/download/${{ steps.extract-version.outputs.tag-name }}/baselime-darwin-x64-${{ steps.extract-version.outputs.tag-name }}.tar.gz
commit-message: |
v{{version}}
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
publish-docker-image:
needs: [create-release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPOSITORY }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
push: true
- name: Update dockerhub readme
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: baselime/baselime
notify-community:
needs: [publish-docker-image, homebrew-release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
- name: Post to the community Slack channel
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: 'C04KT9JNRHS'
payload: |
{
"text": "[Release] Baselime CLI v${{ steps.tag_name.outputs.current_version }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*[Release] Baselime CLI v${{ steps.tag_name.outputs.current_version }}*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Update using:\n```Linux/MacOS: sudo baselime upgrade\nHomebrew: brew upgrade baselime\nnpm: npm i -g @ baselime/cli```"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://github.com/Baselime/cli/releases/tag/v${{ steps.tag_name.outputs.current_version }}|https://github.com/Baselime/cli/releases/tag/v${{ steps.tag_name.outputs.current_version }}>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}