-
-
Notifications
You must be signed in to change notification settings - Fork 203
490 lines (481 loc) · 17.8 KB
/
cd.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
jobs:
generate-changelog:
name: Generate changelog
runs-on: ubuntu-22.04
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@main
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --no-exec --github-repo ${{ github.repository }}
publish-binaries:
name: Publish binaries
needs: generate-changelog
runs-on: ${{ matrix.build.os }}
strategy:
fail-fast: false
matrix:
build:
- {
NAME: linux-x64-glibc,
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-gnu,
NPM_PUBLISH: true,
PYPI_PUBLISH: true,
}
- {
NAME: linux-x64-musl,
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-musl,
NPM_PUBLISH: false,
PYPI_PUBLISH: true,
}
- {
NAME: linux-x86-glibc,
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: i686-unknown-linux-gnu,
NPM_PUBLISH: false,
PYPI_PUBLISH: false,
}
- {
NAME: linux-x86-musl,
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: i686-unknown-linux-musl,
NPM_PUBLISH: false,
PYPI_PUBLISH: true,
}
- {
NAME: linux-arm64-glibc,
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-gnu,
NPM_PUBLISH: true,
PYPI_PUBLISH: true,
}
- {
NAME: linux-arm64-musl,
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-musl,
NPM_PUBLISH: false,
PYPI_PUBLISH: true,
}
- {
NAME: win32-x64-mingw,
OS: windows-2022,
TOOLCHAIN: stable,
TARGET: x86_64-pc-windows-gnu,
NPM_PUBLISH: false,
PYPI_PUBLISH: false,
}
- {
NAME: win32-x64-msvc,
OS: windows-2022,
TOOLCHAIN: stable,
TARGET: x86_64-pc-windows-msvc,
NPM_PUBLISH: true,
PYPI_PUBLISH: true,
}
- {
NAME: win32-x86-msvc,
OS: windows-2022,
TOOLCHAIN: stable,
TARGET: i686-pc-windows-msvc,
NPM_PUBLISH: false,
PYPI_PUBLISH: true,
}
- {
NAME: win32-arm64-msvc,
OS: windows-2022,
TOOLCHAIN: stable,
TARGET: aarch64-pc-windows-msvc,
NPM_PUBLISH: true,
PYPI_PUBLISH: false,
}
- {
NAME: darwin-x64,
OS: macos-14,
TOOLCHAIN: stable,
TARGET: x86_64-apple-darwin,
NPM_PUBLISH: true,
PYPI_PUBLISH: true,
}
- {
NAME: darwin-arm64,
OS: macos-14,
TOOLCHAIN: stable,
TARGET: aarch64-apple-darwin,
NPM_PUBLISH: true,
PYPI_PUBLISH: true,
}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install dependencies
shell: bash
run: |
if [[ "${{ matrix.build.NAME }}" = *"-musl" ]]; then
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
--allow-unauthenticated musl-tools
fi
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.build.TOOLCHAIN }}
target: ${{ matrix.build.TARGET }}
override: true
- name: Build (linux/macos)
if: matrix.build.OS != 'windows-2022'
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --locked --target ${{ matrix.build.TARGET }}
- name: Build (windows)
if: matrix.build.OS == 'windows-2022'
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target ${{ matrix.build.TARGET }} # --no-default-features
- name: Prepare release assets
shell: bash
run: |
mkdir -p release/{man,completions}
cp {LICENSE-MIT,LICENSE-APACHE,README.md,CHANGELOG.md} release/
OUT_DIR=release/completions/ cargo run --release --bin git-cliff-completions
OUT_DIR=release/man/ cargo run --release --bin git-cliff-mangen
for bin in 'git-cliff' 'git-cliff-completions' 'git-cliff-mangen'; do
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
bin="${bin}.exe"
fi
cp "target/${{ matrix.build.TARGET }}/release/${bin}" release/
done
mv release/ git-cliff-${{ env.RELEASE_VERSION }}/
- name: Create release artifacts
shell: bash
run: |
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
7z a -tzip "git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.zip" \
git-cliff-${{ env.RELEASE_VERSION }}/
else
tar -czvf git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
git-cliff-${{ env.RELEASE_VERSION }}/
shasum -a 512 git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
> git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz.sha512
fi
- name: Sign the release
if: matrix.build.OS == 'ubuntu-22.04' || matrix.build.OS == 'macos-14'
run: |
echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --import private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --detach-sign \
git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz
- name: Publish to GitHub
if: ${{ !contains(github.ref, '-') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
release_name: "Release v${{ env.RELEASE_VERSION }}"
body: "${{ needs.generate-changelog.outputs.release_body }}"
- name: Publish to GitHub (pre-release)
if: ${{ contains(github.ref, '-') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
release_name: "Pre-release v${{ env.RELEASE_VERSION }}"
prerelease: true
- name: Install node
if: matrix.build.NPM_PUBLISH == true
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Publish to NPM
if: matrix.build.NPM_PUBLISH == true
shell: bash
run: |
cd npm
bin="git-cliff"
node_os=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f1)
export node_os
node_arch=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f2)
export node_arch
export version="${{ env.RELEASE_VERSION }}"
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
export node_pkg="${bin}-windows-${node_arch}"
else
export node_pkg="${bin}-${node_os}-${node_arch}"
fi
mkdir -p "${node_pkg}/bin"
envsubst < package.json.tmpl > "${node_pkg}/package.json"
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
bin="${bin}.exe"
fi
cp "../target/${{ matrix.build.TARGET }}/release/${bin}" "${node_pkg}/bin"
cp ../README.md "${node_pkg}"
cd "${node_pkg}"
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build Python wheels (linux)
if: matrix.build.PYPI_PUBLISH == true && startsWith(matrix.build.NAME, 'linux')
uses: PyO3/maturin-action@v1
with:
working-directory: pypi
target: ${{ matrix.build.TARGET }}
args: --release --sdist --out wheels
sccache: "true"
# https://github.com/PyO3/maturin-action/issues/245
manylinux: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-gnu' && '2_28' || 'auto' }}
- name: Build Python wheels (macos & windows)
if: |
matrix.build.PYPI_PUBLISH == true &&
(startsWith(matrix.build.OS, 'macos') || startsWith(matrix.build.OS, 'windows'))
uses: PyO3/maturin-action@v1
with:
working-directory: pypi
target: ${{ matrix.build.TARGET }}
args: --release --sdist --out wheels
sccache: "true"
- name: Build Python wheels (musl)
if: matrix.build.PYPI_PUBLISH == true && endsWith(matrix.build.OS, 'musl')
uses: PyO3/maturin-action@v1
with:
working-directory: pypi
target: ${{ matrix.build.TARGET }}
args: --release --sdist --out wheels
sccache: "true"
manylinux: musllinux_1_2
- name: Upload Python wheels
uses: actions/upload-artifact@v4
with:
name: "wheels-${{ matrix.build.TARGET }}"
working-directory: pypi
path: pypi/wheels
publish-npm:
name: Publish the base package to NPM
needs: publish-binaries
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Publish the package
shell: bash
working-directory: npm/git-cliff
run: |
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.npmjs.org"
yarn install
yarn build
cp ../../README.md .
cp ../../CHANGELOG.md .
if [ ${{ contains(github.ref, '-') }} = "true" ]; then
yarn npm publish --tag rc
else
yarn npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
YARN_ENABLE_IMMUTABLE_INSTALLS: false
publish-pypi:
name: Publish PyPI package
runs-on: ubuntu-22.04
needs: publish-binaries
steps:
- uses: actions/download-artifact@v4
with:
path: pypi/wheels
pattern: wheels-*
merge-multiple: true
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ vars.USE_TESTPYPI == 'true' && secrets.TESTPYPI_API_TOKEN || secrets.PYPI_API_TOKEN }}
MATURIN_REPOSITORY: ${{ vars.USE_TESTPYPI == 'true' && 'testpypi' || 'pypi' }}
with:
command: upload
args: --skip-existing pypi/wheels/*
publish-deb:
name: Publish Debian package
needs: generate-changelog
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build Debian package
run: |
# https://github.com/kornelski/cargo-deb/pull/62
sed "/readme = (.*)/d" -E -i git-cliff/Cargo.toml
cargo build --release --locked -p git-cliff
mkdir man/
OUT_DIR=man cargo run --bin git-cliff-mangen
mkdir completions
OUT_DIR=completions cargo run --bin git-cliff-completions
cargo-deb --deb-revision="" --strip -p git-cliff -v -o git-cliff-${{ env.RELEASE_VERSION }}.deb
- name: Sign the package
run: |
echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --import private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --detach-sign \
git-cliff-${{ env.RELEASE_VERSION }}.deb
- name: Upload the release
if: ${{ !contains(github.ref, '-') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: git-cliff-${{ env.RELEASE_VERSION }}.deb
tag: ${{ github.ref }}
release_name: "Release v${{ env.RELEASE_VERSION }}"
body: "${{ needs.generate-changelog.outputs.release_body }}"
- name: Upload the pre-release
if: ${{ contains(github.ref, '-') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: git-cliff-${{ env.RELEASE_VERSION }}.deb
tag: ${{ github.ref }}
release_name: "Pre-release v${{ env.RELEASE_VERSION }}"
prerelease: true
publish-rpm:
name: Publish RPM package
needs: generate-changelog
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
- name: Install cargo-generate-rpm
run: cargo install cargo-generate-rpm
- name: Build RPM package
run: |
cargo build --release --locked -p git-cliff
mkdir man/
OUT_DIR=man cargo run --bin git-cliff-mangen
mkdir completions
OUT_DIR=completions cargo run --bin git-cliff-completions
cargo generate-rpm -p git-cliff -o git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm
- name: Sign the package
run: |
echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --import private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --detach-sign \
git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm
- name: Upload the release
if: ${{ !contains(github.ref, '-') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm
tag: ${{ github.ref }}
release_name: "Release v${{ env.RELEASE_VERSION }}"
body: "${{ needs.generate-changelog.outputs.release_body }}"
- name: Upload the pre-release
if: ${{ contains(github.ref, '-') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: git-cliff-${{ env.RELEASE_VERSION }}.x86_64.rpm
tag: ${{ github.ref }}
release_name: "Pre-release v${{ env.RELEASE_VERSION }}"
prerelease: true
publish-crates-io:
name: Publish on crates.io
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set the release version
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
- name: Prepare for the crates.io release
run: |
mkdir git-cliff-core/config/
cp config/cliff.toml git-cliff-core/config/
sed -i 's|"../config/"|"config/"|' git-cliff-core/src/embed.rs
mkdir git-cliff-core/examples/
cp -r examples git-cliff-core
sed -i 's|"../examples/"|"examples/"|' git-cliff-core/src/embed.rs
- name: Publish the library
run: |
cargo publish --allow-dirty --manifest-path git-cliff-core/Cargo.toml \
--locked --token ${{ secrets.CARGO_TOKEN }}
- name: Wait for library to update
shell: bash
run: |
crate_status="https://raw.githubusercontent.com/rust-lang/crates.io-index/master/gi/t-/git-cliff-core"
until curl -s "$crate_status" | grep -q '"vers":"${{ env.RELEASE_VERSION }}"'; do sleep 5; done;
- name: Publish the binary
run: |
cargo publish --allow-dirty --manifest-path git-cliff/Cargo.toml \
--locked --token ${{ secrets.CARGO_TOKEN }}
publish-homebrew:
name: Publish Homebrew formula
if: ${{ !contains(github.ref, '-') }}
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Bump formula
uses: mislav/bump-homebrew-formula-action@v3
with:
formula-name: git-cliff
formula-path: Formula/g/git-cliff.rb
env:
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_COMMITTER_TOKEN }}