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 7, 2023
1 parent cec5440 commit 0aea580
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 5 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
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/

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/

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/

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: shim/bin/

containerd:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: Download and Extract Containerd
run: ./scripts/build/gen-containerd-config.sh
shell: bash
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: containerd
path: bin/

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: |
gh release create $RELEASE_VERSION --generate-notes
./scripts/build/cargo-vendor.sh
mkdir ../temp
cp -r ./* ../temp/
tar -czvf $VENDOR_NAME -C ../temp .
gh release upload $RELEASE_VERSION $VENDOR_NAME
shell: bash
- uses: actions/download-artifact@v3
with:
path: _artifacts
- name: Package release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p _dist
find _artifacts -type f | xargs -I {} cp {} _dist/
tar -czvf ${{ env.ARCHIVE_NAME }} -C _dist .
gh release upload ${{ env.RELEASE_VERSION }} ${{ env.ARCHIVE_NAME }}
13 changes: 9 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 install/containerd

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 Expand Up @@ -86,4 +86,9 @@ install-quark:
@install -d -m 750 ${DEST_DIR}${SYSTEMD_SERVICE_DIR}
@install -p -m 640 quark/service/kuasar-quark.service ${DEST_DIR}${SYSTEMD_SERVICE_DIR}/kuasar-quark.service

install/containerd:
curl -LJO https://github.com/containerd/containerd/releases/download/v1.7.0/containerd-1.7.0-linux-amd64.tar.gz
mkdir bin && tar -C bin -xzvf containerd-1.7.0-linux-amd64.tar.gz
cp docs/config.toml bin/

install: all install-vmm install-wasm install-quark
31 changes: 31 additions & 0 deletions docs/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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"
13 changes: 13 additions & 0 deletions scripts/build/cargo-vendor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

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

for dir in "${directories[@]}"; do
(cd "$dir" && cargo vendor)
done
40 changes: 40 additions & 0 deletions scripts/build/gen-containerd-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

sudo curl -LJO https://github.com/containerd/containerd/releases/download/v1.7.0/containerd-1.7.0-linux-amd64.tar.gz
sudo mkdir bin && sudo tar -C bin -xzvf containerd-1.7.0-linux-amd64.tar.gz

sudo 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

sudo echo "config.toml has been created!"
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 0aea580

Please sign in to comment.