-
Notifications
You must be signed in to change notification settings - Fork 0
349 lines (329 loc) · 12.9 KB
/
Copy pathci.yml
File metadata and controls
349 lines (329 loc) · 12.9 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
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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
compile:
name: Compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse3-dev
- name: Build workspace
run: cargo build --workspace --all-targets
- name: Save compilation for downstream jobs
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: compile-${{ github.run_id }}
check:
name: Check
needs: compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: rustfmt, clippy
- name: Restore compilation
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: compile-${{ github.run_id }}
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse3-dev
- name: Format
run: cargo fmt --check
- name: Clippy
run: cargo clippy --workspace
- name: Check
run: cargo check --workspace
- name: Docs
run: cargo doc --workspace --no-deps --document-private-items
env:
RUSTDOCFLAGS: "-D warnings"
test:
name: Test
needs: compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Restore compilation
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: compile-${{ github.run_id }}
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse3-dev
- name: Run tests
run: cargo test --workspace
release:
name: Release
needs: [check, test]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
released: ${{ steps.release.outputs.released }}
version: ${{ steps.release.outputs.version }}
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Install release-plz
uses: taiki-e/install-action@13608cbb45b01feb47ef444ab1a42dc41ad56f1a # v2
with:
tool: release-plz
- name: Run release-plz
id: release
run: |
set +e
OUTPUT=$(release-plz release --git-token ${{ secrets.GITHUB_TOKEN }} 2>&1)
RC=$?
set -e
echo "$OUTPUT"
# release-plz logs lines like "released cascade 0.1.0 (git-only)".
# Parse them to determine whether the binary crate was released
# and extract the version for downstream build jobs.
if echo "$OUTPUT" | grep -q 'released cascade ';
then
VERSION=$(echo "$OUTPUT" | grep 'released cascade ' | head -1 | grep -oP 'released cascade \K[^ ]+')
TAG="cascade-v${VERSION}"
echo "released=true" >> "$GITHUB_OUTPUT"
echo "version=${TAG}" >> "$GITHUB_OUTPUT"
echo "Detected release: ${TAG}"
else
echo "released=false" >> "$GITHUB_OUTPUT"
echo 'No cascade binary release detected'
fi
exit $RC
build-macos-arm:
name: Build macOS ARM
needs: release
if: needs.release.outputs.released == 'true'
runs-on: macos-latest
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ needs.release.outputs.version }}
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
targets: aarch64-apple-darwin
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Build
run: cargo build --release --target aarch64-apple-darwin -p cascade
- name: Package archive
run: |
mkdir -p dist
cp target/aarch64-apple-darwin/release/cascade dist/cascade
cd dist
tar czf cascade-aarch64-macos.tar.gz cascade
shasum -a 256 cascade-aarch64-macos.tar.gz | awk '{print $1}' > cascade-aarch64-macos.tar.gz.sha256
- name: Upload to release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
with:
tag_name: ${{ needs.release.outputs.version }}
files: dist/cascade-aarch64-macos.tar.gz*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-macos-x86:
name: Build macOS x86_64
needs: release
if: needs.release.outputs.released == 'true'
runs-on: macos-latest
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ needs.release.outputs.version }}
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
targets: x86_64-apple-darwin
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Build
run: cargo build --release --target x86_64-apple-darwin -p cascade
- name: Package archive
run: |
mkdir -p dist
cp target/x86_64-apple-darwin/release/cascade dist/cascade
cd dist
tar czf cascade-x86_64-macos.tar.gz cascade
shasum -a 256 cascade-x86_64-macos.tar.gz | awk '{print $1}' > cascade-x86_64-macos.tar.gz.sha256
- name: Upload to release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
with:
tag_name: ${{ needs.release.outputs.version }}
files: dist/cascade-x86_64-macos.tar.gz*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-linux-x86:
name: Build Linux x86_64
needs: release
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ needs.release.outputs.version }}
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse3-dev
- name: Build
run: cargo build --release --target x86_64-unknown-linux-gnu -p cascade
- name: Package archive
run: |
mkdir -p dist
cp target/x86_64-unknown-linux-gnu/release/cascade dist/cascade
cd dist
tar czf cascade-x86_64-linux.tar.gz cascade
sha256sum cascade-x86_64-linux.tar.gz | awk '{print $1}' > cascade-x86_64-linux.tar.gz.sha256
- name: Upload to release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
with:
tag_name: ${{ needs.release.outputs.version }}
files: dist/cascade-x86_64-linux.tar.gz*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-linux-arm:
name: Build Linux ARM64
needs: release
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ needs.release.outputs.version }}
- uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
targets: aarch64-unknown-linux-gnu
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Install cross-compilation toolchain
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build
run: cargo build --release --target aarch64-unknown-linux-gnu -p cascade
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Package archive
run: |
mkdir -p dist
cp target/aarch64-unknown-linux-gnu/release/cascade dist/cascade
cd dist
tar czf cascade-aarch64-linux.tar.gz cascade
sha256sum cascade-aarch64-linux.tar.gz | awk '{print $1}' > cascade-aarch64-linux.tar.gz.sha256
- name: Upload to release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
with:
tag_name: ${{ needs.release.outputs.version }}
files: dist/cascade-aarch64-linux.tar.gz*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-tap:
name: Update Homebrew tap
needs: [release, build-macos-arm, build-macos-x86, build-linux-x86, build-linux-arm]
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout tap via SSH deploy key
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: Mearman/homebrew-cascade
ssh-key: ${{ secrets.TAP_DEPLOY_KEY }}
- name: Download checksums
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
TAG_URL="https://github.com/Mearman/cascade/releases/download/${VERSION}"
curl -sL "${TAG_URL}/cascade-aarch64-macos.tar.gz.sha256" | awk '{print $1}' > sha-macos-arm
curl -sL "${TAG_URL}/cascade-x86_64-macos.tar.gz.sha256" | awk '{print $1}' > sha-macos-x86
curl -sL "${TAG_URL}/cascade-x86_64-linux.tar.gz.sha256" | awk '{print $1}' > sha-linux-x86
curl -sL "${TAG_URL}/cascade-aarch64-linux.tar.gz.sha256" | awk '{print $1}' > sha-linux-arm
- name: Generate formula
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
VERSION_NUM="${VERSION#v}"
MACOS_ARM_SHA=$(cat sha-macos-arm)
MACOS_X86_SHA=$(cat sha-macos-x86)
LINUX_X86_SHA=$(cat sha-linux-x86)
LINUX_ARM_SHA=$(cat sha-linux-arm)
mkdir -p Formula
cat > Formula/cascade.rb <<EOF
# Auto-generated by CI — do not edit manually.
# Regenerated on each semantic release from Mearman/cascade.
class Cascade < Formula
desc "Cross-platform cloud storage filesystem client"
homepage "https://github.com/Mearman/cascade"
version "${VERSION_NUM}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "https://github.com/Mearman/cascade/releases/download/${VERSION}/cascade-aarch64-macos.tar.gz"
sha256 "${MACOS_ARM_SHA}"
else
url "https://github.com/Mearman/cascade/releases/download/${VERSION}/cascade-x86_64-macos.tar.gz"
sha256 "${MACOS_X86_SHA}"
end
end
on_linux do
if Hardware::CPU.arm?
url "https://github.com/Mearman/cascade/releases/download/${VERSION}/cascade-aarch64-linux.tar.gz"
sha256 "${LINUX_ARM_SHA}"
else
url "https://github.com/Mearman/cascade/releases/download/${VERSION}/cascade-x86_64-linux.tar.gz"
sha256 "${LINUX_X86_SHA}"
end
end
def install
bin.install "cascade"
end
test do
assert_match version.to_s, shell_output("\#{bin}/cascade --version")
end
end
EOF
- name: Commit and push
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/cascade.rb
git diff --cached --quiet || git commit -m "chore: update formula to ${VERSION}"
git push