Skip to content

Commit

Permalink
wip: Improve Release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz committed Mar 5, 2024
1 parent f186215 commit 7043c76
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 144 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#
# 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: Publish (Docker)

on:
workflow_dispatch:
inputs:
live-run:
type: boolean
required: true
version:
type: string
required: false
workflow_call:
inputs:
live-run:
type: boolean
required: true
version:
type: string
required: true

jobs:
main:
name: Docker build and push
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}

- name: Download packages from previous job
uses: actions/download-artifact@v3
with:
path: build

- name: Unzip artifacts
run: |
ls build
mkdir -p docker/linux/amd
unzip build/zenoh-${{ inputs.version }}-x86_64-unknown-linux-musl-artifacts.zip -d docker/linux/amd64/
rm docker/linux/amd64/libzenoh_plugin_example.so
mkdir -p docker/linux/arm64
unzip build/zenoh-${{ inputs.version }}-aarch64-unknown-linux-musl-artifacts.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: ${{ inputs.live-run }}
platforms: linux/amd64, linux/arm64
file: .github/workflows/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
199 changes: 55 additions & 144 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,108 +14,32 @@
name: Release

on:
release:
types: [published]
schedule:
- cron: "0 0 * * 1-5"
workflow_dispatch:
inputs:
dry-run:
live-run:
type: boolean
required: true
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

# TODO: The `check`, `test`, publish-docker jobs should be resuable workflows that optionally
# build in release mode instead of debug mode.
# TODO: The publish-docker
jobs:
check:
name: Code checks
runs-on: ubuntu-latest
steps:
- name: Clone this repository
uses: actions/checkout@v4

- name: Install Rust toolchain
run: |
rustup show
rustup component add rustfmt clippy
- name: Code format check
run: cargo fmt --check
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

- name: Clippy check
run: cargo clippy --all-targets -- --deny warnings

- name: Clippy unstable check
run: cargo clippy --all-targets -- --deny warnings

- name: Clippy all features
run: cargo clippy --all-targets --all-features -- --deny warnings

test:
name: Tests
needs: check
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 --verbose
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
ASYNC_STD_THREAD_COUNT: 4

- name: Run doctests
run: cargo test --release --doc
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
ASYNC_STD_THREAD_COUNT: 4

build-docs:
name: Doc generation
needs: check
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

tag:
name: Bump and tag crates
uses: eclipse-zenoh/ci/.github/workflows/tag-crates.yml@main
with:
repo: ${{ github.repository }}
dry-run: ${{ inputs.dry-run }}
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:
Expand All @@ -125,43 +49,70 @@ jobs:
secrets: inherit

build-artifacts:
name: Build executables and libraries
needs: tag
uses: eclipse-zenoh/ci/.github/workflows/build-crates-debian.yml@main
uses: eclipse-zenoh/ci/.github/workflows/build-crates-artifacts.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" }]'
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

publish-debian:
name: Publish Debian packages
needs: [tag, build-debian]
uses: eclipse-zenoh/ci/.github/workflows/publish-crates-debian.yml@main
with:
dry-run: ${{ inputs.dry-run }}
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}
secrets: inherit

publish-cargo:
build-docs:
name: Doc generation
needs: tag
runs-on: ubuntu-latest
steps:
- name: Clone this repository
uses: actions/checkout@v4
with:
ref: ${{ needs.tag.outputs.version }}

- name: Install Rust toolchain nightly for docs gen
run: rustup default install nightly

- name: generate doc
# Use a similar command than docs.rs build: rustdoc with nightly toolchain
# 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

publish-cargo:
name: Publish Cargo crates
needs: [tag, build-docs]
uses: eclipse-zenoh/ci/.github/workflows/publish-crates-cargo.yml@main
with:
repos: ${{ github.repository }}
dry-run: ${{ inputs.dry-run }}
live-run: ${{ inputs.live-run }}
branch: ${{ needs.tag.outputs.branch }}
inter-deps-pattern: zenoh.*
secrets: inherit

publish-homebrew:
name: Publish Homebrew formulae
needs: tag
uses: eclipse-zenoh/ci/.github/workflows/publish-crates-homebrew.yml@main
with:
repo: ${{ github.repository }}
dry-run: ${{ inputs.dry-run }}
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}
branch: ${{ needs.tag.outputs.branch }}
artifact-patterns: |
Expand All @@ -175,59 +126,19 @@ jobs:
zenoh-plugin-storage-manager
secrets: inherit

publish-docker:
name: Docker build and push
needs: [tag, check, build-artifacts, test, build-docs]
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.tag.outputs.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.tag.outputs.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 }}
publish-eclipse:
name: Publish artifacts to Eclipse downloads
needs: tag
uses: eclipse-zenoh/ci/.github/workflows/publish-crates-eclipse.yml@main
with:
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}
name: zenoh

- 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 }}
publish-docker:
name: Publish Docker image
needs: tag
uses: ./.github/workflows/publish-docker.yml
with:
live-run: ${{ inputs.live-run }}
version: ${{ needs.tag.outputs.version }}

0 comments on commit 7043c76

Please sign in to comment.