Skip to content

Release

Release #419

Workflow file for this run

#
# Copyright (c) 2022 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:
release:
types: [published]
schedule:
- cron: "0 1 * * 1-5"
workflow_dispatch:
jobs:
checks:
name: Code checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy
- name: Code format check
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Clippy check
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
- name: Environment setup
id: env
shell: bash
run: |
# log some info
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
echo "GITHUB_REF=${GITHUB_REF}"
echo "GITHUB_SHA=${GITHUB_SHA:0:8}"
GIT_BRANCH=`[[ $GITHUB_REF =~ ^refs/heads/.* ]] && echo ${GITHUB_REF/refs\/heads\//} || true`
echo "GIT_BRANCH=${GIT_BRANCH}"
echo ::set-output name=GIT_BRANCH::"${GIT_BRANCH}"
GIT_TAG=`[[ $GITHUB_REF =~ ^refs/tags/.* ]] && echo ${GITHUB_REF/refs\/tags\//} || true`
echo "GIT_TAG=${GIT_TAG}"
echo ::set-output name=GIT_TAG::"${GIT_TAG}"
ZENOH_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
echo "ZENOH_VERSION=${ZENOH_VERSION}"
echo ::set-output name=ZENOH_VERSION::"${ZENOH_VERSION}"
if [ -n "${GIT_TAG}" ]; then
IS_RELEASE="true"
echo "IS_RELEASE=${IS_RELEASE}"
echo ::set-output name=IS_RELEASE::"${IS_RELEASE}"
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}"
echo ::set-output name=PKG_VERSION::"${PKG_VERSION}"
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 }}
builds:
name: Build for ${{ matrix.job.target }} on ${{ matrix.job.os }}
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 }
- {
target: x86_64-unknown-linux-musl,
arch: amd64,
os: ubuntu-20.04,
use-cross: true,
}
- {
target: arm-unknown-linux-gnueabi,
arch: armel,
os: ubuntu-20.04,
use-cross: true,
}
- {
target: arm-unknown-linux-gnueabihf,
arch: armhf,
os: ubuntu-20.04,
use-cross: true,
}
- {
target: armv7-unknown-linux-gnueabihf,
arch: armhf,
os: ubuntu-20.04,
use-cross: true,
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
use-cross: true,
}
- { target: x86_64-apple-darwin, arch: darwin, os: macos-latest }
- { target: aarch64-apple-darwin, arch: darwin, os: macos-latest }
- { target: x86_64-pc-windows-msvc, arch: win64, os: windows-2019 }
- { target: x86_64-pc-windows-gnu, arch: win64, os: windows-2019 }
steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 500 # NOTE: get all 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 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
- name: Windows > Install LLVM and Clang # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@v1
if: matrix.job.os == 'windows-2019'
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm
- name: Windows > Set LIBCLANG_PATH
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: matrix.job.os == 'windows-2019'
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.job.target }}
override: true
profile: minimal
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --release --target=${{ matrix.job.target }}
- name: Debian package
if: contains(matrix.job.target, '-linux-gnu')
uses: actions-rs/cargo@v1
with:
command: deb
args: --no-build --target=${{ matrix.job.target }}
- name: Packaging
id: package
shell: bash
run: |
TARGET=${{ matrix.job.target }}
MAIN_PKG_NAME="${GITHUB_WORKSPACE}/zenoh-plugin-webserver-${{ needs.checks.outputs.PKG_VERSION }}-${TARGET}.zip"
DEBS_PKG_NAME="${GITHUB_WORKSPACE}/zenoh-plugin-webserver-${{ 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} *.so
cd -
echo ::set-output name=MAIN_PKG_NAME::"${MAIN_PKG_NAME}"
# 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 ::set-output name=DEBS_PKG_NAME::"${DEBS_PKG_NAME}"
fi
;;
*apple*)
cd "target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} *.dylib
cd -
echo ::set-output name=MAIN_PKG_NAME::"${MAIN_PKG_NAME}"
;;
*windows*)
cd "target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
7z -y a "${MAIN_PKG_NAME}" *.dll
cd -
echo ::set-output name=MAIN_PKG_NAME::"${MAIN_PKG_NAME}"
;;
esac
- name: "Upload packages"
uses: actions/upload-artifact@master
with:
name: ${{ matrix.job.target }}
path: |
${{ steps.package.outputs.MAIN_PKG_NAME }}
${{ steps.package.outputs.DEBS_PKG_NAME }}
publication:
name: Publish the release
if: needs.checks.outputs.IS_RELEASE == 'true'
needs: [checks, builds]
runs-on: ubuntu-latest
steps:
- name: Download result of previous builds
uses: actions/download-artifact@v2
with:
path: ARTIFACTS
- name: Publish as github release
uses: softprops/action-gh-release@v1
with:
files: ARTIFACTS/*/*.*
- name: Publish to download.eclipse.org/zenoh
env:
SSH_TARGET: [email protected]
ECLIPSE_BASE_DIR: /home/data/httpd/download.eclipse.org/zenoh/zenoh-plugin-webserver
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}/${{ 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
- uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
- name: Publish to crates.io
shell: bash
run: |
cargo login ${{ secrets.CRATES_IO_TOKEN }}
cargo publish