Skip to content

Commit

Permalink
add workflow release
Browse files Browse the repository at this point in the history
Signed-off-by: dierbei <1628652790@qq.com>
  • Loading branch information
dierbei committed Oct 8, 2023
1 parent cec5440 commit 8f9ae33
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 5 deletions.
131 changes: 131 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: release

concurrency:
group: release-${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

on:
push:
tags:
- '**/v[0-9]+.[0-9]+.*'

env:
CARGO_TERM_COLOR: always

jobs:
vmm:
strategy:
matrix:
features: ["cloud_hypervisor"]

runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- name: Build vmm
run: make vmm HYPERVISOR=${{ matrix.features }} RUNTIME=docker
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.features }}
path: |
bin/kuasar.img
bin/vmlinux.bin
bin/vmm-sandboxer
quark:
runs-on: ubuntu-latest
timeout-minutes: 30
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"]

runs-on: ubuntu-latest
timeout-minutes: 30
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 0.11.2 >> /dev/null
- name: Build wasm
run: make wasm WASM_RUNTIME=${{ matrix.features }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.features }}
path: bin/wasm-sandboxer

shim:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: Build shim
working-directory: shim
run: make all
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: shim
path: |
bin/containerd-shim-kuasar-vmm-v2
bin/containerd-shim-kuasar-wasm-v2
containerd:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: Download and Extract Containerd
run: sudo -E ./scripts/build/download-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
- quark
- wasm
- shim
- containerd
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set RELEASE_VERSION ENV var
run: |
echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
echo "ARCHIVE_NAME=kuasar-${GITHUB_REF:10}-linux-amd64.tar.gz" >> $GITHUB_ENV
echo "VENDOR_NAME=kuasar-${GITHUB_REF:10}-vendor.tar.gz" >> $GITHUB_ENV
- name: Package vendor
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: sudo -E ./scripts/build/cargo-vendor.sh
shell: bash
- uses: actions/download-artifact@v3
with:
path: _artifacts
- name: Package release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: sudo -E ./scripts/build/github-release.sh
shell: bash
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ 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

bin/vmm-sandboxer:
@cd vmm/sandbox && cargo build --release --features=${HYPERVISOR}
@mkdir -p bin && cp vmm/sandbox/target/release/vmm-sandboxer bin/vmm-sandboxer

bin/vmm-task:
@cd vmm/task && cargo build --release --target=${ARCH}-unknown-linux-musl
@mkdir -p bin && cp vmm/task/target/${ARCH}-unknown-linux-musl/release/vmm-task bin/vmm-task
Expand All @@ -28,11 +28,11 @@ bin/vmlinux.bin:

bin/kuasar.img:
@bash -x vmm/scripts/image/${GUESTOS_IMAGE}/build.sh image
@mkdir -p bin && cp /tmp/kuasar.img bin/kuasar.img && rm /tmp/kuasar.img
@mkdir -p bin && cp /tmp/kuasar.img bin/kuasar.img && sudo rm /tmp/kuasar.img

bin/kuasar.initrd:
@bash -x vmm/scripts/image/${GUESTOS_IMAGE}/build.sh initrd
@mkdir -p bin && cp /tmp/kuasar.initrd bin/kuasar.initrd && rm /tmp/kuasar.initrd
@mkdir -p bin && cp /tmp/kuasar.initrd bin/kuasar.initrd && sudo rm /tmp/kuasar.initrd

bin/wasm-sandboxer:
@cd wasm && cargo build --release --features=${WASM_RUNTIME}
Expand Down
38 changes: 38 additions & 0 deletions scripts/build/cargo-vendor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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

export PATH="$PATH:/home/runner/.cargo/bin"

gh release create $RELEASE_VERSION --generate-notes

directories=(
"quark"
"shim"
"vmm/sandbox"
"vmm/task"
"vmm/common"
"wasm"
)

for dir in "${directories[@]}"; do
(cd "$dir" && cargo vendor)
done

mkdir ../temp
cp -r ./* ../temp/
tar -czvf $VENDOR_NAME -C ../temp .
gh release upload $RELEASE_VERSION $VENDOR_NAME
53 changes: 53 additions & 0 deletions scripts/build/download-containerd.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
version = 2
[plugins."io.containerd.grpc.v1.cri"]
disable_apparmor = true
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.vmm]
runtime_type = "io.containerd.kuasar.v1"
sandboxer = "vmm"
io_type = "hvsock"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.quark]
runtime_type = "io.containerd.quark.v1"
sandboxer = "quark"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.wasm]
runtime_type = "io.containerd.wasm.v1"
sandboxer = "wasm"
[proxy_plugins.vmm]
type = "sandbox"
address = "/run/vmm-sandboxer.sock"
[proxy_plugins.quark]
type = "sandbox"
address = "/run/quark-sandboxer.sock"
[proxy_plugins.wasm]
type = "sandbox"
address = "/run/wasm-sandboxer.sock"
EOF
21 changes: 21 additions & 0 deletions scripts/build/github-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/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

mkdir -p _dist
find _artifacts -type f | xargs -I {} cp {} _dist/
tar -czvf $ARCHIVE_NAME -C _dist .
gh release upload $RELEASE_VERSION $ARCHIVE_NAME
2 changes: 1 addition & 1 deletion vmm/scripts/image/centos/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fi

case "$1" in
image)
bash -x ${REPO_DIR}/vmm/scripts/image/build_image.sh
sudo bash -x ${REPO_DIR}/vmm/scripts/image/build_image.sh
fn_check_result $? "build image failed!"
;;
initrd)
Expand Down
4 changes: 4 additions & 0 deletions vmm/scripts/kernel/cloud_hypervisor/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f9ae33

Please sign in to comment.