-
Notifications
You must be signed in to change notification settings - Fork 175
532 lines (483 loc) · 18.2 KB
/
release.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
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
#
# Copyright (c) 2023 ZettaScale Technology
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# ZettaScale Zenoh Team, <[email protected]>
#
name: Release
on:
schedule:
- cron: "0 0 * * 1-5"
workflow_dispatch:
inputs:
live-run:
type: boolean
description: If false (or undefined) the workflow runs in dry-run mode (i.e. with no side-effects)
required: false
version:
type: string
description: Release number. If undefined, the workflow auto-generates a version using git-describe
required: false
jobs:
tag:
name: Bump and tag crates
uses: eclipse-zenoh/ci/.github/workflows/tag-crates.yml@main
with:
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run }}
version: ${{ inputs.version }}
inter-deps-pattern: zenoh.*
secrets: inherit
build-debian:
name: Build Debian packages
needs: tag
uses: eclipse-zenoh/ci/.github/workflows/build-crates-debian.yml@main
with:
repo: ${{ github.repository }}
version: ${{ needs.tag.outputs.version }}
branch: ${{ needs.tag.outputs.branch }}
secrets: inherit
build-standalone:
name: Build executables and libraries
needs: tag
uses: eclipse-zenoh/ci/.github/workflows/build-crates-standalone.yml@main
with:
repo: ${{ github.repository }}
version: ${{ needs.tag.outputs.version }}
branch: ${{ needs.tag.outputs.branch }}
exclude-builds: '[{ build: { target: "x86_64-pc-windows-gnu", os: "windows-2019" } }]'
artifact-patterns: |
^zenohd(\.exe)?$
^libzenoh_plugin_(rest|storage_manager)\.(dylib|so)$
^zenoh_plugin_(rest|storage_manager)\.dll$
secrets: inherit
cargo:
name: Publish Cargo crates
needs: tag
uses: eclipse-zenoh/ci/.github/workflows/release-crates-cargo.yml@main
with:
repos: ${{ github.repository }}
live-run: ${{ inputs.live-run }}
branch: ${{ needs.tag.outputs.branch }}
inter-deps-pattern: zenoh.*
secrets: inherit
debian:
name: Publish Debian packages
needs: [tag, build-debian]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-debian.yml@main
with:
no-build: true
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}
repo: ${{ github.repository }}
branch: ${{ needs.tag.outputs.branch }}
secrets: inherit
homebrew:
name: Publish Homebrew formulae
needs: [tag, build-standalone]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-homebrew.yml@main
with:
no-build: true
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}
branch: ${{ needs.tag.outputs.branch }}
artifact-patterns: |
^zenohd$
^libzenoh_plugin_rest\.dylib$
^libzenoh_plugin_storage_manager\.dylib$
formulae: |
zenoh
zenohd
zenoh-plugin-rest
zenoh-plugin-storage-manager
secrets: inherit
eclipse:
name: Publish artifacts to Eclipse downloads
needs: [tag, build-standalone]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-eclipse.yml@main
with:
no-build: true
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}
repo: ${{ github.repository }}
branch: ${{ needs.tag.outputs.branch }}
artifact-patterns: |
^zenohd(\.exe)?$
^libzenoh_plugin_(rest|storage_manager)\.(dylib|so)$
^zenoh_plugin_(rest|storage_manager)\.dll$
name: zenoh
secrets: inherit
github:
name: Publish artifacts to GitHub Releases
needs: [tag, build-standalone]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-github.yml@main
with:
no-build: true
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}
repo: ${{ github.repository }}
branch: ${{ needs.tag.outputs.branch }}
artifact-patterns: |
^zenohd(\.exe)?$
^libzenoh_plugin_(rest|storage_manager)\.(dylib|so)$
^zenoh_plugin_(rest|storage_manager)\.dll$
secrets: inherit
dockerhub:
name: Publish container image to DockerHub
needs: [tag, build-standalone]
uses: eclipse-zenoh/ci/.github/workflows/release-crates-dockerhub.yml@main
with:
no-build: true
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}
repo: ${{ github.repository }}
tags: "eclipse/zenoh:${{ needs.tag.outputs.version }}"
binary: zenohd
files: |
zenohd
libzenoh_plugin_rest.so
libzenoh_plugin_storage_manager.so
platforms: |
linux/arm64
linux/amd64
secrets: inherit
ZENOH_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "zenoh") | .version')
echo "ZENOH_VERSION=${ZENOH_VERSION}" >> $GITHUB_OUTPUT
if [ -n "${GIT_TAG}" ]; then
IS_RELEASE="true"
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
PKG_VERSION=${ZENOH_VERSION}
elif [ -n "${GIT_BRANCH}" ]; then
PKG_VERSION=${GIT_BRANCH}-${GITHUB_SHA:0:8}
else
PKG_VERSION=${ZENOH_VERSION}-${GITHUB_SHA:0:8}
fi
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_OUTPUT
echo "GITHUB_OUTPUT : ${GITHUB_OUTPUT}"
outputs:
GIT_BRANCH: ${{ steps.env.outputs.GIT_BRANCH }}
GIT_TAG: ${{ steps.env.outputs.GIT_TAG }}
IS_RELEASE: ${{ steps.env.outputs.IS_RELEASE }}
ZENOH_VERSION: ${{ steps.env.outputs.ZENOH_VERSION }}
PKG_VERSION: ${{ steps.env.outputs.PKG_VERSION }}
tests:
name: Tests
if: ${{ !(github.event.inputs.runtests == 'false') }}
needs: checks
runs-on: ubuntu-latest
steps:
- name: Clone this repository
uses: actions/checkout@v4
- name: Install Rust toolchain
run: rustup show
- name: Install nextest
run: cargo install --version ${{ env.VERSION_CARGO_NEXTEST }} --locked cargo-nextest
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
- name: Run tests
run: cargo nextest run --release --features=${{ github.event.inputs.features}} --verbose
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
- name: Run doctests
run: cargo test --release --features=${{ github.event.inputs.features}} --doc
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
doc:
name: Doc generation
if: ${{ !(github.event.inputs.doc == 'false') }}
needs: checks
runs-on: ubuntu-latest
steps:
- name: Clone this repository
uses: actions/checkout@v4
# Use a similar command than docs.rs build: rustdoc with nightly toolchain
- name: Install Rust toolchain nightly for docs gen
run: rustup toolchain install nightly
- name: generate doc
# NOTE: force 'unstable' feature for doc generation, as forced for docs.rs build in zenoh/Cargo.toml
run: >
cargo +nightly rustdoc --manifest-path ./zenoh/Cargo.toml --lib --features unstable -j3
-Z rustdoc-map -Z unstable-options -Z rustdoc-scrape-examples
--config build.rustdocflags='["-Z", "unstable-options", "--emit=invocation-specific", "--cap-lints", "warn", "--disable-per-crate-search", "--extern-html-root-takes-precedence"]'
env:
RUSTDOCFLAGS: -Dwarnings
builds:
name: Build for ${{ matrix.job.target }} on ${{ matrix.job.os }}
if: ${{ !(github.event.inputs.build == 'false') }}
needs: checks
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
- {
target: x86_64-unknown-linux-gnu,
arch: amd64,
os: ubuntu-20.04,
build-cmd: "cargo",
}
- {
target: x86_64-unknown-linux-musl,
arch: amd64,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: arm-unknown-linux-gnueabi,
arch: armel,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: arm-unknown-linux-gnueabihf,
arch: armhf,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: armv7-unknown-linux-gnueabihf,
arch: armhf,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: aarch64-unknown-linux-musl,
arch: arm64,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: x86_64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: aarch64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: x86_64-pc-windows-msvc,
arch: win64,
os: windows-2019,
build-cmd: "cargo",
}
# - { target: x86_64-pc-windows-gnu , arch: win64 , os: windows-2019 }
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 500 # NOTE: get long history for git-version crate to correctly compute a version
- name: Fetch Git tags # NOTE: workaround for https://github.com/actions/checkout/issues/290
shell: bash
run: git fetch --tags --force
- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
*-linux-gnu*) cargo install --version ${{ env.VERSION_CARGO_DEB }} cargo-deb ;;
esac
case ${{ matrix.job.target }} in
arm-unknown-linux-gnueabi)
sudo apt-get -y update
sudo apt-get -y install gcc-arm-linux-gnueabi
;;
arm*-unknown-linux-gnueabihf)
sudo apt-get -y update
sudo apt-get -y install gcc-arm-linux-gnueabihf
;;
aarch64-unknown-linux-gnu)
sudo apt-get -y update
sudo apt-get -y install gcc-aarch64-linux-gnu
;;
esac
cargo install --version ${{ env.VERSION_CROSS }} cross
- name: Install Rust toolchain
run: |
rustup show
rustup target add ${{ matrix.job.target }}
- name: Build
run: ${{ matrix.job.build-cmd }} build --release --bins --lib --features=${{ github.event.inputs.features}} --target=${{ matrix.job.target }}
- name: Debian package - zenohd
if: contains(matrix.job.target, '-linux-gnu')
run: cargo deb --no-build --target=${{ matrix.job.target }} -p zenohd
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
- name: Debian package - zenoh-plugin-storage-manager
if: contains(matrix.job.target, '-linux-gnu')
run: cargo deb --no-build --target=${{ matrix.job.target }} -p zenoh-plugin-storage-manager
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
- name: Debian package - zenoh-plugin-rest
if: contains(matrix.job.target, '-linux-gnu')
run: cargo deb --no-build --target=${{ matrix.job.target }} -p zenoh-plugin-rest
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
- name: Packaging
id: package
shell: bash
run: |
TARGET=${{ matrix.job.target }}
MAIN_PKG_NAME="${GITHUB_WORKSPACE}/zenoh-${{ needs.checks.outputs.PKG_VERSION }}-${TARGET}.zip"
DEBS_PKG_NAME="${GITHUB_WORKSPACE}/zenoh-${{ needs.checks.outputs.PKG_VERSION }}-${TARGET}-deb-pkgs.zip"
case ${TARGET} in
*linux*)
cd "target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} zenohd libzenoh_plugin_*.so
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
# check if debian packages has been created and packages them in a single tgz
if [[ -d target/${TARGET}/debian ]]; then
cd target/${TARGET}/debian
echo "Packaging ${DEBS_PKG_NAME}:"
zip ${DEBS_PKG_NAME} *.deb
cd -
echo "DEBS_PKG_NAME=${DEBS_PKG_NAME}" >> $GITHUB_OUTPUT
fi
;;
*apple*)
cd "target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} zenohd libzenoh_plugin_*.dylib
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*windows*)
cd "target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
7z -y a "${MAIN_PKG_NAME}" zenohd.exe zenoh_plugin_*.dll
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
esac
- name: "Upload packages"
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.job.target }}
path: |
${{ steps.package.outputs.MAIN_PKG_NAME }}
${{ steps.package.outputs.DEBS_PKG_NAME }}
publication:
name: Release publication
if: ${{ (needs.checks.outputs.IS_RELEASE == 'true' || github.event.inputs.publish == 'true') && !failure() }}
needs: [checks, builds, tests, doc]
runs-on: ubuntu-latest
steps:
- name: Download result of previous builds
uses: actions/download-artifact@v3
with:
path: ARTIFACTS
- name: Publish as github release
if: ${{ !(github.event.inputs.githubrelease == 'false') }}
uses: softprops/action-gh-release@v1
with:
files: ARTIFACTS/*/*.*
- name: Publish to download.eclipse.org/zenoh
if: ${{ !(github.event.inputs.eclipse == 'false') }}
env:
SSH_TARGET: [email protected]
ECLIPSE_BASE_DIR: /home/data/httpd/download.eclipse.org/zenoh
shell: bash
run: |
echo "--- setup ssh-agent"
eval "$(ssh-agent -s)"
echo 'echo "${{ secrets.SSH_PASSPHRASE }}"' > ~/.ssh_askpass && chmod +x ~/.ssh_askpass
echo "${{ secrets.SSH_PRIVATE_KEY }}" | tr -d '\r' | DISPLAY=NONE SSH_ASKPASS=~/.ssh_askpass ssh-add - > /dev/null 2>&1
rm -f ~/.ssh_askpass
echo "--- test ssh:"
ssh -o "StrictHostKeyChecking=no" ${SSH_TARGET} ls -al
echo "---- list artifacts to upload:"
ls -R ARTIFACTS || true
DOWNLOAD_DIR=${ECLIPSE_BASE_DIR}/zenoh/${{ needs.checks.outputs.ZENOH_VERSION }}
echo "---- copy artifacts into ${DOWNLOAD_DIR}"
ssh -o "StrictHostKeyChecking=no" ${SSH_TARGET} mkdir -p ${DOWNLOAD_DIR}
cd ARTIFACTS
sha256sum */* > sha256sums.txt
scp -o "StrictHostKeyChecking=no" -r * ${SSH_TARGET}:${DOWNLOAD_DIR}/
echo "---- cleanup identity"
ssh-add -D
- name: Checkout this repository
uses: actions/checkout@v4
- name: Install Rust toolchain
if: ${{ !(github.event.inputs.cratesio == 'false') }}
run: rustup show
- name: Check crates
if: ${{ !(github.event.inputs.cratesio == 'false') }}
shell: bash
run: .github/workflows/crates_check.sh
- name: Publish to crates.io
if: ${{ !(github.event.inputs.cratesio == 'false') }}
shell: bash
run: |
set +x
.github/workflows/crates_publish.sh ${{ secrets.CRATES_IO_TOKEN }}
- name: Cancel workflow if fail # thus Docker job be interrupted
if: failure()
uses: andymckay/[email protected]
docker:
name: Docker build and push
if: ${{ !(github.event.inputs.dockerhub == 'false') && !failure() }}
needs: [checks, builds, tests, doc]
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
fetch-depth: 500 # NOTE: get long history for git-version crate to correctly compute a version
- name: Fetch Git tags # NOTE: workaround for https://github.com/actions/checkout/issues/290
shell: bash
run: git fetch --tags --force
- name: Download packages from previous job
uses: actions/download-artifact@v3
with:
path: PACKAGES
- name: Unzip PACKAGES
run: |
ls PACKAGES
mkdir -p docker/linux/amd
unzip PACKAGES/x86_64-unknown-linux-musl/zenoh-${{ needs.checks.outputs.PKG_VERSION }}-x86_64-unknown-linux-musl.zip -d docker/linux/amd64/
rm docker/linux/amd64/libzenoh_plugin_example.so
mkdir -p docker/linux/arm64
unzip PACKAGES/aarch64-unknown-linux-musl/zenoh-${{ needs.checks.outputs.PKG_VERSION }}-aarch64-unknown-linux-musl.zip -d docker/linux/arm64/
rm docker/linux/arm64/libzenoh_plugin_example.so
tree docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta - set tags and labels
id: meta
uses: docker/metadata-action@v5
with:
images: eclipse/zenoh
labels: |
org.opencontainers.image.licenses=EPL-2.0 OR Apache-2.0
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_COM_USERNAME }}
password: ${{ secrets.DOCKER_COM_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64, linux/arm64
file: .github/workflows/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}