-
-
Notifications
You must be signed in to change notification settings - Fork 3
305 lines (297 loc) · 10.4 KB
/
pipeline.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
on:
push:
branches:
- "*"
pull_request:
workflow_dispatch:
merge_group:
jobs:
docker-build:
uses: PurpleBooth/common-pipelines/.github/workflows/docker-build.yml@main
rust-check:
uses: PurpleBooth/common-pipelines/.github/workflows/rust-check.yml@main
with:
ubuntu_before_script: sudo apt-get install -y libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
specdown:
uses: PurpleBooth/common-pipelines/.github/workflows/specdown-check.yml@main
with:
ubuntu_before_script: sudo apt-get install -y libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
release:
if: github.ref == 'refs/heads/main'
needs:
- docker-build
- specdown
- rust-check
outputs:
current_version: ${{ steps.current_version.outputs.current_version }}
previous_version: ${{ steps.previous_version.outputs.previous_version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
fetch-depth: 0
- uses: taiki-e/install-action@cargo-binstall
- name: Get tags
run: git fetch --tags origin
- shell: bash
run: cargo binstall --no-confirm cargo-edit
- shell: bash
run: cargo binstall --no-confirm --locked cocogitto
- id: previous_version
run: |
echo "previous_version=$( cog get-version 2> /dev/null )" >> "$GITHUB_OUTPUT"
shell: bash
- name: Semver release
id: release
run: |
git config --global user.name "cog-bot"
git config --global user.email "[email protected]"
cog bump --auto
- id: current_version
run: |
echo "current_version=$( cog get-version 2> /dev/null )" >> "$GITHUB_OUTPUT"
shell: bash
cargo-publish:
if: needs.release.outputs.current_version != needs.release.outputs.previous_version
needs:
- release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout the repository
with:
ref: v${{ needs.release.outputs.current_version }}
- uses: actions-rs/[email protected]
with:
toolchain: stable
profile: default
- run: sudo apt-get install -y libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
- name: Publish mit-hook-test-helper to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd mit-hook-test-helper && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Publish mit-commit-message-lints to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd mit-commit-message-lints && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Publish mit-commit-msg to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd mit-commit-msg && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Publish mit-pre-commit to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd mit-pre-commit && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Publish mit-prepare-commit-msg to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd mit-prepare-commit-msg && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Publish git-mit to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd git-mit && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Publish git-mit-config to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd git-mit-config && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Publish git-mit-install to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd git-mit-install && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Publish git-mit-relates-to to Crates
uses: nick-invision/[email protected]
with:
timeout_minutes: 30
max_attempts: 10
command: |
cargo login "$CARGO_TOKEN"
( cd git-mit-relates-to && cargo publish )
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
build:
if: needs.release.outputs.current_version != needs.release.outputs.previous_version
needs:
- release
runs-on: ${{ matrix.os }}
steps:
- run: ${{ matrix.install }}
env:
DEBIAN_FRONTEND: noninteractive
- uses: actions/checkout@v4
with:
lfs: true
ref: v${{ needs.release.outputs.current_version }}
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
- uses: taiki-e/install-action@cargo-binstall
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.target }}
- run: cargo build --release --locked
- id: get_repository_name
run: echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" >> "$GITHUB_OUTPUT"
shell: bash
- name: Move binary to upload location
env:
TARGET: ${{ matrix.target }}
EXTENSION: ${{ matrix.suffix }}
run: |
mv -v "./target/release/git-mit$EXTENSION" "./git-mit-$TARGET$EXTENSION"
mv -v "./target/release/git-mit-config$EXTENSION" "./git-mit-config-$TARGET$EXTENSION"
mv -v "./target/release/git-mit-install$EXTENSION" "./git-mit-install-$TARGET$EXTENSION"
mv -v "./target/release/git-mit-relates-to$EXTENSION" "./git-mit-relates-to-$TARGET$EXTENSION"
mv -v "./target/release/mit-commit-msg$EXTENSION" "./mit-commit-msg-$TARGET$EXTENSION"
mv -v "./target/release/mit-pre-commit$EXTENSION" "./mit-pre-commit-$TARGET$EXTENSION"
mv -v "./target/release/mit-prepare-commit-msg$EXTENSION" "./mit-prepare-commit-msg-$TARGET$EXTENSION"
shell: bash
- uses: actions/upload-artifact@v4
with:
name: bins-${{ matrix.target }}${{ matrix.suffix }}
path: ./*${{ matrix.target }}${{ matrix.suffix }}
strategy:
matrix:
include:
- os: macos-latest
suffix: ""
target: aarch64-apple-darwin
install: echo nothing to install
- os: macos-latest
suffix: ""
target: x86_64-apple-darwin
install: echo nothing to install
- os: ubuntu-latest
suffix: ""
target: x86_64-unknown-linux-gnu
install: sudo apt-get install -y libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
- os: windows-latest
suffix: .exe
target: x86_64-pc-windows-msvc
install: echo nothing to install
generate-github-release:
permissions:
id-token: write
attestations: write
contents: write
if: needs.release.outputs.current_version != needs.release.outputs.previous_version
needs:
- release
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
ref: v${{ needs.release.outputs.current_version }}
- uses: anchore/sbom-action@v0
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: bins
pattern: bins-*
- name: Attest binaries
uses: actions/attest-build-provenance@v1
with:
subject-path: bins/**/*
- name: Sign binaries
run: |
cd bins
for file in *; do
if [[ -f "$file" ]]; then
sha256sum "$file" > "$file.sha256"
md5sum "$file" > "$file.md5"
fi
done
- uses: cargo-bins/cargo-binstall@main
name: Install cargo binstall
- shell: bash
run: cargo binstall --no-confirm --locked cocogitto
- run: cog changelog --at "$TAG_V" > CHANGELOG.md
shell: bash
env:
TAG_V: v${{ needs.release.outputs.current_version }}
- id: create_release
uses: ncipollo/[email protected]
with:
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
bodyFile: "CHANGELOG.md"
name: Release v${{ needs.release.outputs.current_version }}
tag: v${{ needs.release.outputs.current_version }}
artifacts: ./bins/**/*
docker-push:
if: needs.release.outputs.current_version != needs.release.outputs.previous_version
needs:
- release
uses: PurpleBooth/common-pipelines/.github/workflows/docker-push.yml@main
with:
current_version: ${{ needs.release.outputs.current_version }}
generate-formula:
if: needs.release.outputs.current_version != needs.release.outputs.previous_version
needs:
- release
name: Generate Homebrew Formula
runs-on: ubuntu-latest
steps:
- uses: PurpleBooth/generate-formula-action@03882ef6068c2622837703f93b664dcc8840d43e # v0.1.14
with:
current_version: ${{ needs.release.outputs.current_version }}
previous_version: ${{ needs.release.outputs.previous_version }}
committer_token: ${{ secrets.COMMITTER_TOKEN }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}