-
Notifications
You must be signed in to change notification settings - Fork 0
279 lines (268 loc) · 8.97 KB
/
ci.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
name: CI
on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
name: Check
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- run: |
rustup component add rustfmt clippy
cargo check --locked
cargo fmt --all -- --check
cargo clippy -- -Dwarnings
tests:
if: github.ref_type == 'tag' || startsWith(github.ref, 'refs/pull/')
needs: lint
runs-on: ubuntu-latest
name: Tests
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- run: cargo test
build-windows:
if: github.ref_type == 'tag' || startsWith(github.ref, 'refs/pull/')
needs: [lint, tests]
runs-on: windows-latest
name: Release build for Windows
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Build release binary
run: cargo build --release
env:
RUSTFLAGS: '-C target-feature=+crt-static'
- uses: actions/upload-artifact@v3
with:
name: awsbck-windows
path: target/release/awsbck.exe
build-macos:
if: github.ref_type == 'tag' || startsWith(github.ref, 'refs/pull/')
needs: [lint, tests]
runs-on: macos-latest
name: Release build for macOS
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Build release binary
run: cargo build --release
env:
LZMA_API_STATIC: 'true'
- uses: actions/upload-artifact@v3
with:
name: awsbck-macos
path: target/release/awsbck
build-macos-arm:
if: github.ref_type == 'tag' || startsWith(github.ref, 'refs/pull/')
needs: [lint, tests]
runs-on: macos-latest
name: Release build for macOS aarch64
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '14.2'
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Build release binary
run: |
SDKROOT=$(xcrun -sdk macosx13.1 --show-sdk-path) \
MACOS_DEPLOYMENT_TARGET=$(xcrun -sdk macosx13.1 --show-sdk-platform-version) \
cargo build --release --target=aarch64-apple-darwin
env:
LZMA_API_STATIC: 'true'
- uses: actions/upload-artifact@v3
with:
name: awsbck-macos-aarch64
path: target/aarch64-apple-darwin/release/awsbck
build-linux:
if: github.ref_type == 'tag' || startsWith(github.ref, 'refs/pull/')
needs: [lint, tests]
runs-on: ubuntu-latest
name: Release build for linux x86_64
steps:
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- uses: Swatinem/rust-cache@v2
- name: Install musl tools
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends musl-tools
- uses: actions/checkout@v3
- name: Build release binary
run: cargo build --release --target x86_64-unknown-linux-musl
- uses: actions/upload-artifact@v3
with:
name: awsbck-linux
path: target/x86_64-unknown-linux-musl/release/awsbck
build-arm:
if: github.ref_type == 'tag' || startsWith(github.ref, 'refs/pull/')
needs: [lint, tests]
name: Release builds for linux ARM
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: aarch64-unknown-linux-musl
arch: aarch64
- target: armv7-unknown-linux-gnueabihf
arch: armv7
steps:
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- run: cargo install cross --git https://github.com/cross-rs/cross
- uses: actions/checkout@v3
- run: cross build --release --target ${{ matrix.target }}
- uses: actions/upload-artifact@v3
with:
name: awsbck-${{ matrix.arch }}
path: target/${{ matrix.target }}/release/awsbck
build-docker:
if: github.ref_type == 'tag'
needs: [build-linux, build-arm]
name: Create docker container
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: actions/download-artifact@v3
with:
name: awsbck-linux
path: linux_amd64/awsbck
- uses: actions/download-artifact@v3
with:
name: awsbck-aarch64
path: linux_arm64/awsbck
- uses: actions/download-artifact@v3
with:
name: awsbck-armv7
path: linux_arm/awsbck
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata for root image
id: meta-root
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/awsbck
flavor: |
latest=false
tags: |
type=semver,pattern=root-{{version}}
type=semver,pattern=root-{{major}}.{{minor}}
type=raw,value=root-latest
- name: Build and push for root image
uses: docker/build-push-action@v3
with:
push: true
context: .
file: Dockerfile.root
tags: ${{ steps.meta-root.outputs.tags }}
labels: ${{ steps.meta-root.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
- name: Docker metadata # generates tags (version number and "latest") and labels
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/awsbck
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
make-release:
if: github.ref_type == 'tag'
needs: [build-linux, build-arm, build-windows, build-macos, build-macos-arm]
name: Create Github release
runs-on: ubuntu-latest
environment: Cargo
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: cargo publish
- name: extract version from Cargo.toml
uses: SebRollen/[email protected]
id: version
with:
file: Cargo.toml
field: package.version
- name: download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: create release directory
run: mkdir release
- name: create release files
run: |
tar -C ./artifacts/awsbck-linux -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-x64.tar.gz awsbck
tar -C ./artifacts/awsbck-aarch64 -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-aarch64.tar.gz awsbck
tar -C ./artifacts/awsbck-armv7 -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-armv7.tar.gz awsbck
zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-windows.zip ./artifacts/awsbck-windows/awsbck.exe
zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-macos.zip ./artifacts/awsbck-macos/awsbck
zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-macos-aarch64.zip ./artifacts/awsbck-macos-aarch64/awsbck
- name: release
uses: softprops/action-gh-release@v1
with:
name: awsbck v${{ steps.version.outputs.value }}
generate_release_notes: true
files: |
release/*.tar.gz
release/*.zip
changelog:
if: github.ref == 'refs/heads/main'
name: Generate changelog
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
- uses: orhun/git-cliff-action@v2
id: git-cliff
with:
config: cliff.toml
env:
OUTPUT: CHANGELOG.md
- name: Print changelog
run: cat "./CHANGELOG.md"
- name: commit changelog
run: |
git config --global user.name 'beeb'
git config --global user.email '[email protected]'
git commit -am "chore: update changelog"
git push