-
Notifications
You must be signed in to change notification settings - Fork 0
257 lines (253 loc) · 8.93 KB
/
cicd.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
name: CI/CD
on:
push:
branches: '*'
tags-ignore:
- dhall-package-*
pull_request: {}
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
toolchain:
- stable
- beta
- nightly
features:
- []
- [native-tls, dhall]
- [rustls]
include:
- toolchain: stable
components: clippy
- os: ubuntu-latest
toolchain: stable
features: []
components: clippy,rustfmt
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
env:
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEBUG_DEBUG: 0
RUSTFLAGS: --deny warnings
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v2
- name: Install `libsqlite3-dev`
if: runner.os == 'Linux'
run: sudo apt-get install libsqlite3-dev
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
profile: minimal
components: ${{ matrix.components }}
- name: Check format
if: contains(matrix.components, 'rustfmt')
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- uses: Swatinem/rust-cache@v1
- name: Clippy library
if: contains(matrix.components, 'clippy')
uses: actions-rs/cargo@v1
with:
command: clippy
args: --lib --no-default-features --features=winsqlite3,${{ join(matrix.features) }} -- --deny rust-2018-idioms --deny warnings
- name: Clippy all
# XXX: GitHub Actions seem to have no ability to handle array literals in expressions
# like `matrix.features != []`.
if: contains(matrix.components, 'clippy') && join(matrix.features) != ''
uses: actions-rs/cargo@v1
with:
command: clippy
args: --no-default-features --features=winsqlite3,${{ join(matrix.features) }} -- --deny rust-2018-idioms --deny warnings
- name: Build library
uses: actions-rs/cargo@v1
with:
command: build
args: --lib --verbose --no-default-features --features=winsqlite3,${{ join(matrix.features) }}
- name: Build all
if: join(matrix.features) != ''
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --no-default-features --features=winsqlite3,${{ join(matrix.features) }}
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --no-default-features --features=winsqlite3,${{ join(matrix.features) }}
build:
name: Build release artifacts
# XXX: Yes, I doubt if this is the best way of doing it...
# Ideally, we want it to match SemVer tag names.
if: |
github.event_name == 'push'
&& startsWith(github.event.ref, 'refs/tags/v0.')
|| startsWith(github.event.ref, 'refs/tags/v1')
|| startsWith(github.event.ref, 'refs/tags/v2')
|| startsWith(github.event.ref, 'refs/tags/v3')
|| startsWith(github.event.ref, 'refs/tags/v4')
|| startsWith(github.event.ref, 'refs/tags/v5')
|| startsWith(github.event.ref, 'refs/tags/v6')
|| startsWith(github.event.ref, 'refs/tags/v7')
|| startsWith(github.event.ref, 'refs/tags/v8')
|| startsWith(github.event.ref, 'refs/tags/v9')
|| github.event.ref == 'refs/heads/release-test'
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-unknown-linux-gnu
- aarch64-apple-darwin
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
# - x86_64-unknown-freebsd
include:
- os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
use_cross: true
- target: armv7-unknown-linux-gnueabihf
use_cross: true
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
features: [winsqlite3]
# - target: x86_64-unknown-freebsd
# use_cross: true
env:
CARGO_INCREMENTAL: 0
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
CARGO_PROFILE_RELEASE_LTO: fat
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v2
- name: Install packages (x86_64-unknown-linux-gnu)
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: sudo apt-get install libsqlite3-dev libssl-dev
- name: Install packages (Windows)
if: runner.os == 'Windows'
run: vcpkg install sqlite3:x64-windows
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
- uses: Swatinem/rust-cache@v1
if: github.event.ref == 'refs/heads/release-test'
- name: Install `cross`
if: matrix.use_cross && join(matrix.features) != ''
uses: actions-rs/install@v0.1
with:
crate: cross
use-tool-cache: true
# Workaround for <https://github.com/rust-embedded/cross/issues/466>.
- name: Install `cross`
if: matrix.use_cross && join(matrix.features) == ''
run: |
REV=8ea5d4600fe65dd0797509cfc2e1786638a0327f
curl -fLOsS "https://github.com/rust-embedded/cross/archive/$REV.zip"
unzip "$REV.zip"
cargo install --path="cross-$REV"
env:
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 16
CARGO_PROFILE_RELEASE_LTO: thin
- name: Set opt-level
if: github.event.ref == 'refs/heads/release-test'
run: |
cat <<ENV >> "$GITHUB_ENV"
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16
CARGO_PROFILE_RELEASE_LTO=false
CARGO_PROFILE_RELEASE_OPT_LEVEL=0
ENV
shell: bash
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --bin pipitor --release '--features=${{ join(matrix.features) }}' '--target=${{ matrix.target }}'
use-cross: ${{ matrix.use_cross }}
env:
# Work around <https://github.com/actions/virtual-environments/issues/2557>.
SDKROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
- name: Archive the binary
id: archive
run: |
set -o errexit
tag="${GITHUB_REF##*/}"
name="pipitor-$tag-${{ matrix.target }}"
if [ '${{ runner.os }}' = Windows ]; then
asset_name="$name.zip"
ln 'target/${{ matrix.target }}/release/pipitor.exe' .
7z a "$asset_name" pipitor.exe
else
asset_name="$name.tar.gz"
ln 'target/${{ matrix.target }}/release/pipitor' .
tar -czf "$asset_name" pipitor
fi
echo "::set-output name=asset::$asset_name"
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: ${{ steps.archive.outputs.asset }}
release:
name: Create GitHub release
needs: [test, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
- name: Sign release assets
working-directory: artifact
run: |
set -o errexit -o xtrace
gpg --batch --import <<< "$PRIVATE_KEY"
for f in *; do
gpg --batch --local-user C90F234F43B5075A0D96C6D5986E104E7F079F61 --armor --detach-sign "$f"
done
gpg --batch --yes --delete-secret-keys C90F234F43B5075A0D96C6D5986E104E7F079F61
shell: bash
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
- name: Get the tag info
id: tag
run: |
set -o errexit
if [[ "$GITHUB_REF" == 'refs/tags/'* ]]; then
tag="${GITHUB_REF#refs/tags/}"
git tag -d "$tag"
git fetch --no-tags origin "$tag:$GITHUB_REF"
echo "::set-output name=subject::$(git tag --list --format='%(contents:subject)' "$tag")"
git tag -l --format='%(contents:body)' "$tag" |
sed -n '/^-----BEGIN PGP SIGNATURE-----$/q; p' \
> body.txt
else
echo "::set-output name=subject::Test release"
touch body.txt
fi
shell: bash
- name: Create release
uses: tesaguri/action-gh-release@draft-wo-tag
with:
body_path: body.txt
name: ${{ steps.tag.outputs.subject }}
draft: ${{ github.event.ref == 'refs/heads/release-test' }}
files: artifact/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}