-
Notifications
You must be signed in to change notification settings - Fork 17
346 lines (346 loc) · 14.1 KB
/
mono_workflow.yaml
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
name: mono-workflow
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+' # matches 0.1.0, 0.2.1, etc.
schedule:
- cron: '0 1 * * *' # 1am UTC
workflow_dispatch:
permissions:
contents: write
packages: write
actions: read
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Update Nightly Tag
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
uses: richardsimko/update-tag@v1
with:
tag_name: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout code
if: startsWith(github.ref, 'refs/tags/') == true
uses: actions/checkout@v3
- name: Search for version
if: startsWith(github.ref, 'refs/tags/') == true
run: |
if grep -q "version = \"${{ env.GITHUB_REF }}\"" Cargo.toml; then
echo "Match found!"
else
echo "No match found."
exit 1
fi
env:
GITHUB_REF: ${{ github.ref_name }}
# test:
# needs: tag
# if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') == true
# runs-on: ${{ matrix.config.os }}
# env:
# SCCACHE_AZURE_BLOB_CONTAINER: ${{ secrets.SCCACHE_AZURE_BLOB_CONTAINER }}
# SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
# SCCACHE_AZURE_KEY_PREFIX: 'wick-github-actions-test'
# RUSTC_WRAPPER: 'sccache'
# OCI_USERNAME: ${{ secrets.CANDLE_REG_USERNAME }}
# OCI_PASSWORD: ${{ secrets.CANDLE_REG_PASSWORD }}
# strategy:
# matrix:
# config:
# - {
# os: 'ubuntu-latest',
# name: 'linux',
# arch: 'amd64',
# target: 'x86_64-unknown-linux-gnu',
# }
# steps:
# - name: make space
# run: |
# sudo rm -rf /usr/share/dotnet
# sudo rm -rf /opt/ghc
# sudo rm -rf "/usr/local/share/boost"
# sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# - uses: actions/checkout@v3
# - name: install protobuf
# uses: arduino/setup-protoc@v1
# with:
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# - name: setup for cross-compiled linux aarch64 build
# if: matrix.config.target == 'aarch64-unknown-linux-gnu'
# run: |
# sudo apt update
# sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu pkg-config
# echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
# echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
# echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
# - name: setup for cross-compiled windows build
# if: matrix.config.target == 'x86_64-pc-windows-gnu'
# run: |
# sudo apt update
# sudo apt install mingw-w64
# echo "PKG_CONFIG_SYSROOT_DIR=/usr/x86_64-w64-mingw32" >> $GITHUB_ENV
# echo "PKG_CONFIG_PATH=/usr/lib/x86_64-w64-mingw32/pkgconfig" >> $GITHUB_ENV
# echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
# - name: Install sccache (ubuntu-latest)
# if: matrix.config.os == 'ubuntu-latest'
# run: |
# mkdir -p $HOME/.local/bin
# curl -L "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz" | tar xz
# mv -f sccache-v0.3.3-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
# echo "$HOME/.local/bin" >> $GITHUB_PATH
# - name: Install sccache (macos-latest)
# if: matrix.config.os == 'macos-latest'
# run: |
# mkdir -p $HOME/.local/bin
# curl -L "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-apple-darwin.tar.gz" | tar xz
# mv -f sccache-v0.3.3-x86_64-apple-darwin/sccache $HOME/.local/bin/sccache
# echo "$HOME/.local/bin" >> $GITHUB_PATH
# - name: Get Rust version from rust-toolchain.toml
# run: |
# rust_version=$(grep 'channel =' rust-toolchain.toml | awk -F\" '{print $2}')
# echo "RUST_VERSION=$rust_version" >> $GITHUB_ENV
# - name: Rust toolchain cache
# uses: actions/cache@v3
# with:
# path: |
# ~/.cargo/bin/
# ~/.cargo/registry
# ~/.cargo/git
# key: ${{ runner.os }}-${{ matrix.config.target }}-rust-toolchain-${{ env.RUST_VERSION }}
# - name: Install Rust toolchain
# uses: dtolnay/rust-toolchain@stable
# with:
# target: ${{ matrix.config.target }}
# - name: 'rustup updates'
# run: |
# rustup target add wasm32-unknown-unknown wasm32-wasi
# cargo install cargo-deny just cargo-nextest
# #Updating rustup updates means that the github cache needs to be manually deleted.
# - name: Run just ci-tests
# id: just-ci-test
# run: |
# just ci-tests
# # - name: Build wasms for tests
# # id: just-wasm
# # run: |
# # just wasm
# # cargo clean
# # - name: Run just integration
# # id: just-integration
# # run: |
# # just integration
# # cargo clean
build:
needs: tag
runs-on: ${{ matrix.config.os }}
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') == true || github.event_name == 'workflow_dispatch'
env:
SCCACHE_AZURE_BLOB_CONTAINER: ${{ secrets.SCCACHE_AZURE_BLOB_CONTAINER }}
SCCACHE_AZURE_CONNECTION_STRING: ${{ secrets.SCCACHE_AZURE_CONNECTION_STRING }}
SCCACHE_AZURE_KEY_PREFIX: 'wick-github-actions'
RUSTC_WRAPPER: 'sccache'
CARGO_PROFILE_RELEASE_DEBUG: '0' # https://doc.rust-lang.org/cargo/reference/profiles.html#debug
CARGO_INCREMENTAL: 'true' # https://doc.rust-lang.org/cargo/reference/profiles.html#incremental
CARGO_PROFILE_RELEASE_LTO: 'true' # https://doc.rust-lang.org/cargo/reference/profiles.html#lto
CARGO_PROFILE_RELEASE_OPT_LEVEL: '3' # https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1' # https://doc.rust-lang.org/cargo/reference/profiles.html#codegen-units
CARGO_PROFILE_RELEASE_STRIP: 'true' # https://doc.rust-lang.org/cargo/reference/unstable.html#profile-strip-option
strategy:
matrix:
config:
- {
os: 'ubuntu-latest',
name: 'linux',
arch: 'amd64',
target: 'x86_64-unknown-linux-gnu',
args: '',
}
- {
os: 'ubuntu-latest',
name: 'linux',
target: 'aarch64-unknown-linux-gnu',
arch: 'aarch64',
args: '--features cross',
}
- {
os: 'macos-latest',
name: 'macos',
target: 'x86_64-apple-darwin',
arch: 'amd64',
}
- {
os: 'macos-latest',
name: 'macos',
target: 'aarch64-apple-darwin',
arch: 'aarch64',
args: '--features cross',
}
- {
os: 'ubuntu-latest',
name: 'win',
target: 'x86_64-pc-windows-gnu',
arch: 'amd64',
args: '--features cross',
}
steps:
- uses: actions/checkout@v3
- name: install protobuf
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: setup for cross-compiled linux aarch64 build
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu pkg-config
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- name: setup for cross-compiled windows build
if: matrix.config.target == 'x86_64-pc-windows-gnu'
run: |
sudo apt update
sudo apt install mingw-w64
echo "PKG_CONFIG_SYSROOT_DIR=/usr/x86_64-w64-mingw32" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-w64-mingw32/pkgconfig" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
- name: Install sccache (ubuntu-latest)
if: matrix.config.os == 'ubuntu-latest'
run: |
mkdir -p $HOME/.local/bin
curl -L "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz" | tar xz
mv -f sccache-v0.3.3-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install sccache (macos-latest)
if: matrix.config.os == 'macos-latest'
run: |
mkdir -p $HOME/.local/bin
curl -L "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-apple-darwin.tar.gz" | tar xz
mv -f sccache-v0.3.3-x86_64-apple-darwin/sccache $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Get Rust version from rust-toolchain.toml
run: |
rust_version=$(grep 'channel =' rust-toolchain.toml | awk -F\" '{print $2}')
echo "RUST_VERSION=$rust_version" >> $GITHUB_ENV
- name: Rust toolchain cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-${{ matrix.config.target }}-rust-toolchain-${{ env.RUST_VERSION }}
- name: build cache
uses: actions/cache@v3
with:
path: |
target/
crates/**/target
key: ${{ runner.os }}-${{ matrix.config.target }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.config.target }}
- name: 'rustup updates'
run: |
rustup target add wasm32-unknown-unknown wasm32-wasi
- name: 'build binary'
run: |
cargo build --release -p wick-cli --target=${{ matrix.config.target }} ${{ matrix.config.args }}
- name: package release assets
if: matrix.config.target != 'x86_64-pc-windows-gnu'
run: |
mkdir -p _dist
cp README.md LICENSE target/${{ matrix.config.target }}/release/wick _dist/
cd _dist
tar czf wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.tar.gz README.md LICENSE wick
- name: Upload artifacts
if: matrix.config.target != 'x86_64-pc-windows-gnu'
uses: actions/upload-artifact@v2
with:
name: wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.tar.gz
path: _dist/wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.tar.gz
- name: package release assets (windows)
if: matrix.config.target == 'x86_64-pc-windows-gnu'
shell: bash
run: |
mkdir -p _dist
cp README.md LICENSE target/${{ matrix.config.target }}/release/wick.exe _dist/
cd _dist
7z a -tzip wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.zip README.md LICENSE wick.exe
- name: Upload artifacts (windows)
if: matrix.config.target == 'x86_64-pc-windows-gnu'
uses: actions/upload-artifact@v3
with:
name: wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.zip
path: _dist/wick-${{ matrix.config.name }}-${{ matrix.config.arch }}.zip
release:
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') == true || github.event_name == 'workflow_dispatch'
needs: [build]
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Move artifacts to _dist
working-directory: ${{ github.workspace }}
run: |
mkdir -p _dist
for dir in artifacts/*/; do
# Move the contents of each directory to the destination folder
echo "Moving {$dir}"
mv "$dir"* _dist/
done
#Copy the schema manifest into the dist directory
cp crates/wick/wick-config/json-schema/manifest.json _dist/schema.json
#Copy the TypeScript SDKs into the dist directory
cp crates/wick/wick-config/typescript/v1.ts _dist/
ls -la _dist
- name: upload release assets (tag)
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') == true
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: upload release assets (nightly)
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/*
tag: nightly
overwrite: true
file_glob: true
- name: ghcr login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile.nightly
push: true
tags: ghcr.io/candlecorp/wick:nightly
platforms: linux/amd64,linux/arm64
- name: build and push
uses: docker/build-push-action@v2
if: startsWith(github.ref, 'refs/tags/') == true
with:
context: .
file: ./docker/Dockerfile.latest
push: true
tags: ghcr.io/candlecorp/wick:latest, ghcr.io/candlecorp/wick:${{ github.ref_name }}
platforms: linux/amd64,linux/arm64