From fb349df7917dbf46411dce2163f2ba48beeaa330 Mon Sep 17 00:00:00 2001 From: dierbei <1628652790@qq.com> Date: Wed, 11 Oct 2023 07:24:59 +0000 Subject: [PATCH] add workflow release Signed-off-by: dierbei <1628652790@qq.com> --- .github/workflows/release.yaml | 154 +++++++++++++++++++ Makefile | 2 +- scripts/build/build-containerd.sh | 53 +++++++ scripts/build/cargo-vendor.sh | 30 ++++ vmm/scripts/image/centos/build_rootfs.sh | 2 +- vmm/scripts/kernel/cloud_hypervisor/build.sh | 4 + 6 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100755 scripts/build/build-containerd.sh create mode 100755 scripts/build/cargo-vendor.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..ae11c556 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,154 @@ +name: release + +concurrency: + group: release-${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +on: + release: + type: + - published + +env: + CARGO_TERM_COLOR: always + +jobs: + vmm: + strategy: + matrix: + hypervisor: ["cloud_hypervisor"] + runs-on: ubuntu-22.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + - name: Build vmm sandboxer + run: make bin/vmm-sandboxer HYPERVISOR=${{ matrix.hypervisor }} + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: vmm-sandboxer ${{ matrix.hypervisor }} + path: | + bin/vmm-sandboxer + vmm/sandbox/config_clh.toml + + image: + runs-on: ubuntu-22.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - name: Build vm image + run: sudo make bin/kuasar.img RUNTIME=docker + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: image + path: bin/kuasar.img + + kernel: + strategy: + matrix: + hypervisor: ["cloud_hypervisor"] + runs-on: ubuntu-22.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - name: Build vm kernel + run: make bin/vmlinux.bin HYPERVISOR=${{ matrix.hypervisor }} + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: kernel ${{ matrix.hypervisor }} + path: bin/vmlinux.bin + + quark: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + - name: Build quark + run: make quark + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: quark + path: bin/quark-sandboxer + + wasm: + strategy: + matrix: + features: ["wasmedge"] + include: + - features: wasmedge + version: 0.11.2 + runs-on: ubuntu-22.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + - name: Install WasmEdge + if: ${{ matrix.features }} == 'wasmedge' + run: curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v ${{ matrix.version }} >> /dev/null + - name: Build wasm + run: make wasm WASM_RUNTIME=${{ matrix.features }} + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: wasm-sandboxer ${{ matrix.features }} + path: bin/wasm-sandboxer + + containerd: + runs-on: ubuntu-22.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - name: Build Containerd + run: ./scripts/build/build-containerd.sh + shell: bash + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: containerd + path: | + bin/containerd + bin/config.toml + + release: + permissions: + contents: write + needs: + - vmm + - image + - kernel + - quark + - wasm + - containerd + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Package vendor + run: | + releasever=${{ github.ref }} + releasever="${releasever#refs/tags/}" + bash ./scripts/build/cargo-vendor.sh + mkdir -p /tmp/kuasar-$releasever + cp -r ./* /tmp/kuasar-$releasever + mkdir _release + tar -czvf _release/kuasar-$releasever-vendor.tar.gz -C /tmp/ kuasar-$releasever + - uses: actions/download-artifact@v3 + with: + path: _artifacts + - name: Package binaries + run: | + releasever=${{ github.ref }} + releasever="${releasever#refs/tags/}" + mkdir _dist + find _artifacts -type f | xargs -I {} cp {} _dist/ + tar -czvf _release/kuasar-$releasever-linux-amd64.tar.gz -C _dist . + - name: Update Release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fail_on_unmatched_files: true + draft: false + prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'rc') }} + files: | + _release/*.tar.gz diff --git a/Makefile b/Makefile index 21957261..3f246489 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ BIN_DIR := /usr/local/bin SYSTEMD_SERVICE_DIR := /usr/lib/systemd/system SYSTEMD_CONF_DIR := /etc/sysconfig -.PHONY: vmm wasm quark clean all install-vmm install-wasm install-quark install +.PHONY: vmm wasm quark clean all install-vmm install-wasm install-quark install all: vmm quark wasm diff --git a/scripts/build/build-containerd.sh b/scripts/build/build-containerd.sh new file mode 100755 index 00000000..3f724e9b --- /dev/null +++ b/scripts/build/build-containerd.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# Copyright 2022 The Kuasar Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +git clone https://github.com/kuasar-io/containerd.git +mkdir bin && make -C containerd bin/containerd && mv containerd/bin/containerd bin + +tee bin/config.toml > /dev/null <>/etc/profile source /etc/profile diff --git a/vmm/scripts/kernel/cloud_hypervisor/build.sh b/vmm/scripts/kernel/cloud_hypervisor/build.sh index 3f73123b..a36bf3fd 100644 --- a/vmm/scripts/kernel/cloud_hypervisor/build.sh +++ b/vmm/scripts/kernel/cloud_hypervisor/build.sh @@ -17,6 +17,10 @@ set -e readonly version=${1:-6.1.6} readonly base_dir="$(dirname $(readlink -f $0))" + +sudo apt-get update +sudo apt-get install -y libelf-dev elfutils + # clone kernel from cloud-hypervisor github rm -rf /tmp/linux-cloud-hypervisor git clone --depth 1 https://github.com/cloud-hypervisor/linux.git -b ch-${version} /tmp/linux-cloud-hypervisor