chore: implement automatic releases

This commit is contained in:
Alex Zenla 2024-04-02 23:50:45 +00:00
parent 2083ec0604
commit 7c55e63f24
No known key found for this signature in database
GPG Key ID: 067B238899B51269
24 changed files with 247 additions and 18 deletions

View File

@ -1,5 +1,5 @@
name: check
on: [push, pull_request]
on: [push, pull_request, merge_group]
jobs:
fmt:
name: fmt

View File

@ -1,5 +1,5 @@
name: client
on: [push, pull_request]
on: [push, pull_request, merge_group]
jobs:
build:
strategy:

View File

@ -8,6 +8,8 @@ on:
paths:
- "kernel/**"
- "hack/ci/**"
merge_group:
jobs:
build:
runs-on: ubuntu-latest

View File

@ -16,8 +16,6 @@ jobs:
TARGET_ARCH: "${{ matrix.arch }}"
name: server ${{ matrix.arch }}
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
if: ${{ matrix.platform.os == 'windows' }}
- uses: actions/checkout@v4
with:
submodules: recursive
@ -77,6 +75,8 @@ jobs:
run:
shell: bash
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
if: ${{ matrix.platform.os == 'windows' }}
- uses: actions/checkout@v4
with:
submodules: recursive
@ -93,4 +93,10 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: kratactl-${{ matrix.platform.os }}-${{ matrix.platform.arch }}
path: "target/*/release/kratactl*"
path: "target/*/release/kratactl"
if: ${{ matrix.platform.os != 'windows' }}
- uses: actions/upload-artifact@v4
with:
name: kratactl-${{ matrix.platform.os }}-${{ matrix.platform.arch }}
path: "target/*/release/kratactl.exe"
if: ${{ matrix.platform.os == 'windows' }}

View File

@ -10,6 +10,7 @@ on:
- "os/**"
- "hack/os/**"
- "hack/ci/**"
merge_group:
jobs:
build:
runs-on: ubuntu-latest

91
.github/workflows/release-binaries.yml vendored Normal file
View File

@ -0,0 +1,91 @@
name: release-binaries
permissions:
contents: write
on:
release:
types:
- published
env:
CARGO_INCREMENTAL: 0
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTUP_MAX_RETRIES: 10
jobs:
server:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- aarch64
env:
TARGET_ARCH: "${{ matrix.arch }}"
name: server ${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.arch }}-unknown-linux-gnu,${{ matrix.arch }}-unknown-linux-musl"
- run: ./hack/ci/install-linux-deps.sh
- run: ./hack/dist/bundle.sh
env:
KRATA_KERNEL_BUILD_JOBS: "5"
- run: "./hack/ci/assemble-release-assets.sh bundle-systemd ${{ github.event.release.tag_name }} ${{ matrix.arch }} target/dist/bundle-systemd-${{ matrix.arch }}.tgz"
- run: ./hack/dist/deb.sh
env:
KRATA_KERNEL_BUILD_SKIP: "1"
- run: "./hack/ci/assemble-release-assets.sh debian ${{ github.event.release.tag_name }} ${{ matrix.arch }} target/dist/*.deb"
- run: ./hack/dist/apk.sh
env:
KRATA_KERNEL_BUILD_SKIP: "1"
- run: "./hack/ci/assemble-release-assets.sh alpine ${{ github.event.release.tag_name }} ${{ matrix.arch }} target/dist/*_${{ matrix.arch }}.apk"
- run: ./hack/os/build.sh
env:
KRATA_KERNEL_BUILD_SKIP: "1"
- run: "./hack/ci/assemble-release-assets.sh os ${{ github.event.release.tag_name }} ${{ matrix.arch }} target/os/krata-${{ matrix.arch }}.qcow2"
client:
strategy:
fail-fast: false
matrix:
platform:
- { os: linux, arch: x86_64, on: ubuntu-latest, deps: linux }
- { os: linux, arch: aarch64, on: ubuntu-latest, deps: linux }
- { os: darwin, arch: x86_64, on: macos-14, deps: darwin }
- { os: darwin, arch: aarch64, on: macos-14, deps: darwin }
- { os: freebsd, arch: x86_64, on: ubuntu-latest, deps: linux }
- { os: windows, arch: x86_64, on: windows-latest, deps: windows }
env:
TARGET_OS: "${{ matrix.platform.os }}"
TARGET_ARCH: "${{ matrix.platform.arch }}"
runs-on: "${{ matrix.platform.on }}"
name: client ${{ matrix.platform.os }}-${{ matrix.platform.arch }}
defaults:
run:
shell: bash
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
if: ${{ matrix.platform.os != 'darwin' }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.platform.arch }}-apple-darwin"
if: ${{ matrix.platform.os == 'darwin' }}
- uses: homebrew/actions/setup-homebrew@master
if: ${{ matrix.platform.os == 'darwin' }}
- run: ./hack/ci/install-${{ matrix.platform.deps }}-deps.sh
- run: ./hack/build/cargo.sh build --release --bin kratactl
- run: "./hack/ci/assemble-release-assets.sh kratactl ${{ github.event.release.tag_name }} ${{ matrix.platform.os }}-${{ matrix.platform.arch }} target/*/release/kratactl"
if: ${{ matrix.platform.os != 'windows' }}
- run: "./hack/ci/assemble-release-assets.sh kratactl ${{ github.event.release.tag_name }} ${{ matrix.platform.os }}-${{ matrix.platform.arch }} target/*/release/kratactl.exe"
if: ${{ matrix.platform.os == 'windows' }}
- run: "./hack/ci/upload-release-assets.sh ${{ github.event.release.tag_name }}"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

29
.github/workflows/release-plz.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: release-plz
permissions:
pull-requests: write
contents: write
on:
push:
branches:
- release-test
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
release-plz:
name: release-plz
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: release-plz
uses: MarcoIeni/release-plz-action@v0.5
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

View File

@ -1,5 +1,5 @@
name: server
on: [push, pull_request]
on: [push, pull_request, merge_group]
jobs:
build:
runs-on: ubuntu-latest

View File

@ -2,7 +2,7 @@
name = "krata-ctl"
description = "Command-line tool to control the krata hypervisor"
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-daemon"
description = "Daemon for the krata hypervisor."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-guest"
description = "Guest services for the krata hypervisor."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata"
description = "Client library and common services for the krata hypervisor."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-network"
description = "Networking services for the krata hypervisor."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-oci"
description = "OCI services for the krata hypervisor."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-runtime"
description = "Runtime for running guests on the krata hypervisor."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-xencall"
description = "An implementation of direct interfacing to xen privcmd for krata."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-xenclient"
description = "An implementation of Xen userspace for krata."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-xenevtchn"
description = "An implementation of xen evtchn for krata."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-xengnt"
description = "An implementation of xen grant interfaces for krata."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -2,7 +2,7 @@
name = "krata-xenstore"
description = "A client that interacts with xenstore for krata."
license.workspace = true
version= "0.0.3"
version.workspace = true
homepage.workspace = true
repository.workspace = true
edition = "2021"

View File

@ -0,0 +1,57 @@
#!/bin/sh
set -e
checksum_sha256() {
if type sha256sum > /dev/null 2>&1
then
sha256sum "${1}"
else
shasum -a 256 "${1}"
fi
}
asset() {
cp "${1}" "${2}"
PREVIOUS="${PWD}"
cd "$(dirname "${2}")"
BASE_FILE_NAME="$(basename "${2}")"
checksum_sha256 "${BASE_FILE_NAME}" > "${BASE_FILE_NAME}.sha256"
cd "${PREVIOUS}"
}
FORM="${1}"
shift
TAG_NAME="${1}"
shift
PLATFORM="${1}"
shift
mkdir -p target/assets
for SOURCE_FILE_PATH in "${@}"
do
if [ "${FORM}" = "kratactl" ]
then
SUFFIX=""
if echo "${PLATFORM}" | grep "^windows-" > /dev/null
then
SUFFIX=".exe"
fi
asset "${SOURCE_FILE_PATH}" "target/assets/kratactl_${TAG_NAME}_${PLATFORM}${SUFFIX}"
elif [ "${FORM}" = "debian" ]
then
asset "${SOURCE_FILE_PATH}" "target/assets/krata_${TAG_NAME}_${PLATFORM}.deb"
elif [ "${FORM}" = "alpine" ]
then
asset "${SOURCE_FILE_PATH}" "target/assets/krata_${TAG_NAME}_${PLATFORM}.deb"
elif [ "${FORM}" = "bundle-systemd" ]
then
asset "${SOURCE_FILE_PATH}" "target/assets/krata-systemd_${TAG_NAME}_${PLATFORM}.tgz"
elif [ "${FORM}" = "os" ]
then
asset "${SOURCE_FILE_PATH}" "target/assets/krata_${TAG_NAME}_${PLATFORM}.qcow2"
else
echo "ERROR: Unknown form '${FORM}'"
exit 1
fi
done

0
hack/ci/install-windows-deps.sh Normal file → Executable file
View File

View File

@ -0,0 +1,22 @@
#!/bin/sh
set -e
retry() {
for i in $(seq 1 10)
do
if "${@}"
then
return 0
else
sleep "${i}"
fi
done
"${@}"
}
TAG="${1}"
shift
cd target/assets
retry gh release upload "${TAG}" --clobber ./*

21
release-plz.toml Normal file
View File

@ -0,0 +1,21 @@
[workspace]
git_release_enable = false
git_tag_enable = false
changelog_update = false
publish = false
[[package]]
name = "krata"
git_tag_name = "v${version}"
git_tag_enable = true
git_release_enable = true
changelog_update = true
changelog_path = "./CHANGELOG.md"
changelog_include = [
"krata-daemon",
"krata-ctl",
"krata-guest",
"krata-network",
"krata-runtime",
"krata-oci"
]