release: Move bash from the actions to separate bash file

Try to move all the common bash logic from the actions toml file
to separate scripts and call these scripts instead.
Note the repo itself is now checked out to get access to
these scripts.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Signed-off-by: Eric Ernst <eric.ernst@intel.com>
This commit is contained in:
Archana Shinde
2019-11-14 17:11:26 -08:00
parent 383e70344f
commit 29c2ff8476
3 changed files with 127 additions and 148 deletions

18
.github/workflows/gather-artifacts.sh vendored Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
set -o errexit
set -o pipefail
pushd kata-artifacts >>/dev/null
for c in ./*.tar.gz
do
echo "untarring tarball $c"
tar -xvf $c
done
tar cfJ ../kata-static.tar.xz ./opt
popd >>/dev/null

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
set -o errexit
set -o pipefail
main() {
artifact_stage=${1:-}
artifact=$(echo ${artifact_stage} | sed -n -e 's/^install_//p' | sed -r 's/_/-/g')
if [ -z "${artifact}" ]; then
"Scripts needs artifact name to build"
exit 1
fi
tag=$(echo $GITHUB_REF | cut -d/ -f3-)
export GOPATH=$HOME/go
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
git checkout $tag
pushd ../obs-packaging
./gen_versions_txt.sh $tag
popd
source ./kata-deploy-binaries.sh
${artifact_stage} $tag
popd
mv $HOME/go/src/github.com/kata-containers/packaging/release/kata-static-${artifact}.tar.gz .
}
main $@

View File

@@ -20,34 +20,25 @@ jobs:
with: with:
name: artifact-list name: artifact-list
path: artifact-list.txt path: artifact-list.txt
build-kernel: build-kernel:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: get-artifact-list needs: get-artifact-list
env:
buildstr: "install_kernel"
steps: steps:
- uses: actions/checkout@v1
- name: get-artifact-list - name: get-artifact-list
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: artifact-list name: artifact-list
- run: |
sudo apt-get update && sudo apt install -y flex bison libelf-dev bc iptables
- name: build-kernel - name: build-kernel
run: | run: |
if grep -q "install_kernel" ./artifact-list/artifact-list.txt; then if grep -q $buildstr ./artifact-list/artifact-list.txt; then
# install kernel dependencies $GITHUB_WORKSPACE/.github/workflows/generate-artifact-tarball.sh $buildstr
sudo apt-get update && sudo apt install -y flex bison libelf-dev bc iptables
export GOPATH=$HOME/go
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
# Get versions information
tag=`echo $GITHUB_REF | cut -d/ -f3-`
git checkout $tag
pushd ../obs-packaging
./gen_versions_txt.sh $tag
popd
# Build the kernel:
source ./kata-deploy-binaries.sh
install_kernel
echo ::set-env name=artifact-built::true echo ::set-env name=artifact-built::true
popd >>/dev/null
mv $HOME/go/src/github.com/kata-containers/packaging/release/kata-kernel.tar.gz .
else else
echo ::set-env name=artifact-built::false echo ::set-env name=artifact-built::false
fi fi
@@ -56,34 +47,26 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: kata-artifacts name: kata-artifacts
path: kata-kernel.tar.gz path: kata-static-kernel.tar.gz
build-experimental-kernel: build-experimental-kernel:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: get-artifact-list needs: get-artifact-list
env:
buildstr: "install_experimental_kernel"
steps: steps:
- uses: actions/checkout@v1
- name: get-artifact-list - name: get-artifact-list
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: artifact-list name: artifact-list
- run: |
sudo apt-get update && sudo apt install -y flex bison libelf-dev bc iptables
- name: build-experimental-kernel - name: build-experimental-kernel
run: | run: |
if grep -q "install_experimental_kernel" ./artifact-list/artifact-list.txt; then if grep -q $buildstr ./artifact-list/artifact-list.txt; then
# install kernel dependencies $GITHUB_WORKSPACE/.github/workflows/generate-artifact-tarball.sh $buildstr
sudo apt-get update && sudo apt install -y flex bison libelf-dev bc iptables
export GOPATH=$HOME/go
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
# Get versions information
tag=`echo $GITHUB_REF | cut -d/ -f3-`
git checkout $tag
../obs-packaging/gen_versions_txt.sh $tag
# Build the kernel:
source ./kata-deploy-binaries.sh
install_experimental_kernel
echo ::set-env name=artifact-built::true echo ::set-env name=artifact-built::true
popd >>/dev/null
mv $HOME/go/src/github.com/kata-containers/packaging/release/kata-kernel-experimental.tar.gz .
else else
echo ::set-env name=artifact-built::false echo ::set-env name=artifact-built::false
fi fi
@@ -92,33 +75,24 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: kata-artifacts name: kata-artifacts
path: kata-kernel-experimental.tar.gz path: kata-static-experimental-kernel.tar.gz
# Job for building the QEMU binaries
build-qemu: build-qemu:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: get-artifact-list needs: get-artifact-list
env:
buildstr: "install_qemu"
steps: steps:
- uses: actions/checkout@v1
- name: get-artifact-list - name: get-artifact-list
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: artifact-list name: artifact-list
- name: build-qemu - name: build-qemu
run: | run: |
if grep -q "install_qemu" ./artifact-list/artifact-list.txt; then if grep -q $buildstr ./artifact-list/artifact-list.txt; then
export GOPATH=$HOME/go $GITHUB_WORKSPACE/.github/workflows/generate-artifact-tarball.sh $buildstr
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
# Get versions information
tag=`echo $GITHUB_REF | cut -d/ -f3-`
git checkout $tag
../obs-packaging/gen_versions_txt.sh $tag
# Build the VMM:
source ./kata-deploy-binaries.sh
install_qemu
echo ::set-env name=artifact-built::true echo ::set-env name=artifact-built::true
popd >>/dev/null
mv $HOME/go/src/github.com/kata-containers/packaging/release/kata-qemu-static.tar.gz .
else else
echo ::set-env name=artifact-built::false echo ::set-env name=artifact-built::false
fi fi
@@ -127,33 +101,25 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: kata-artifacts name: kata-artifacts
path: kata-qemu-static.tar.gz path: kata-static-qemu.tar.gz
# Job for building the QEMU binaries with virtiofs support # Job for building the QEMU binaries with virtiofs support
build-qemu-virtiofsd: build-qemu-virtiofsd:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: get-artifact-list needs: get-artifact-list
env:
buildstr: "install_qemu_virtiofsd"
steps: steps:
- uses: actions/checkout@v1
- name: get-artifact-list - name: get-artifact-list
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: artifact-list name: artifact-list
- name: build-qemu-virtiofsd - name: build-qemu-virtiofsd
run: | run: |
if grep -q "install_qemu_virtiofsd" ./artifact-list/artifact-list.txt; then if grep -q $buildstr ./artifact-list/artifact-list.txt; then
export GOPATH=$HOME/go $GITHUB_WORKSPACE/.github/workflows/generate-artifact-tarball.sh $buildstr
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
# Get versions information
tag=`echo $GITHUB_REF | cut -d/ -f3-`
git checkout $tag
../obs-packaging/gen_versions_txt.sh $tag
# Build the VMM:
source ./kata-deploy-binaries.sh
install_qemu_virtiofsd
echo ::set-env name=artifact-built::true echo ::set-env name=artifact-built::true
popd >>/dev/null
mv $HOME/go/src/github.com/kata-containers/packaging/release/kata-qemu-virtiofs-static.tar.gz .
else else
echo ::set-env name=artifact-built::false echo ::set-env name=artifact-built::false
fi fi
@@ -162,35 +128,25 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: kata-artifacts name: kata-artifacts
path: kata-qemu-virtiofs-static.tar.gz path: kata-static-qemu-virtiofsd.tar.gz
# Job for building the image # Job for building the image
build-image: build-image:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: get-artifact-list needs: get-artifact-list
env:
buildstr: "install_image"
steps: steps:
- uses: actions/checkout@v1
- name: get-artifact-list - name: get-artifact-list
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: artifact-list name: artifact-list
- name: build-image - name: build-image
run: | run: |
if grep -q "install_image" ./artifact-list/artifact-list.txt; then if grep -q $buildstr ./artifact-list/artifact-list.txt; then
export GOPATH=$HOME/go $GITHUB_WORKSPACE/.github/workflows/generate-artifact-tarball.sh $buildstr
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
# Get versions information
tag=`echo $GITHUB_REF | cut -d/ -f3-`
git checkout $tag
pushd ../obs-packaging
./gen_versions_txt.sh $tag
popd
# Build the VMM:
source ./kata-deploy-binaries.sh
install_image $tag
echo ::set-env name=artifact-built::true echo ::set-env name=artifact-built::true
popd >>/dev/null
mv $HOME/go/src/github.com/kata-containers/packaging/release/kata-image.tar.gz .
else else
echo ::set-env name=artifact-built::false echo ::set-env name=artifact-built::false
fi fi
@@ -199,33 +155,25 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: kata-artifacts name: kata-artifacts
path: kata-image.tar.gz path: kata-static-image.tar.gz
# Job for building firecracker hypervisor # Job for building firecracker hypervisor
build-firecracker: build-firecracker:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: get-artifact-list needs: get-artifact-list
env:
buildstr: "install_firecracker"
steps: steps:
- uses: actions/checkout@v1
- name: get-artifact-list - name: get-artifact-list
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: artifact-list name: artifact-list
- name: build-firecracker - name: build-firecracker
run: | run: |
if grep -q "install_firecracker" ./artifact-list/artifact-list.txt; then if grep -q $buildstr ./artifact-list/artifact-list.txt; then
export GOPATH=$HOME/go $GITHUB_WORKSPACE/.github/workflows/generate-artifact-tarball.sh $buildstr
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
# Get versions information
tag=`echo $GITHUB_REF | cut -d/ -f3-`
git checkout $tag
../obs-packaging/gen_versions_txt.sh $tag
# Build the VMM:
source ./kata-deploy-binaries.sh
install_firecracker
echo ::set-env name=artifact-built::true echo ::set-env name=artifact-built::true
popd >>/dev/null
mv $HOME/go/src/github.com/kata-containers/packaging/release/kata-firecracker-static.tar.gz .
else else
echo ::set-env name=artifact-built::false echo ::set-env name=artifact-built::false
fi fi
@@ -234,33 +182,25 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: kata-artifacts name: kata-artifacts
path: kata-firecracker-static.tar.gz path: kata-static-firecracker.tar.gz
# Job for building kata components # Job for building kata components
build-kata-components: build-kata-components:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: get-artifact-list needs: get-artifact-list
env:
buildstr: "install_kata_components"
steps: steps:
- uses: actions/checkout@v1
- name: get-artifact-list - name: get-artifact-list
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: artifact-list name: artifact-list
- name: build-kata-components - name: build-kata-components
run: | run: |
if grep -q "install_kata_components" ./artifact-list/artifact-list.txt; then if grep -q $buildstr ./artifact-list/artifact-list.txt; then
export GOPATH=$HOME/go $GITHUB_WORKSPACE/.github/workflows/generate-artifact-tarball.sh $buildstr
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
# Get versions information
tag=`echo $GITHUB_REF | cut -d/ -f3-`
git checkout $tag
../obs-packaging/gen_versions_txt.sh $tag
# Build the VMM:
source ./kata-deploy-binaries.sh
install_kata_components $tag
echo ::set-env name=artifact-built::true echo ::set-env name=artifact-built::true
popd >>/dev/null
mv $HOME/go/src/github.com/kata-containers/packaging/release/kata-components.tar.gz .
else else
echo ::set-env name=artifact-built::false echo ::set-env name=artifact-built::false
fi fi
@@ -269,35 +209,20 @@ jobs:
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: kata-artifacts name: kata-artifacts
path: kata-components.tar.gz path: kata-static-kata-components.tar.gz
gather-artifacts: gather-artifacts:
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
needs: [build-kernel, build-qemu, build-qemu-virtiofsd, build-image, build-firecracker, build-kata-components] needs: [build-kernel, build-qemu, build-qemu-virtiofsd, build-image, build-firecracker, build-kata-components]
steps: steps:
- uses: actions/checkout@v1
- name: get-artifacts - name: get-artifacts
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: kata-artifacts name: kata-artifacts
- name: colate-artifacts - name: colate-artifacts
run: | run: |
export GOPATH=$HOME/go $GITHUB_WORKSPACE/.github/workflows/gather-artifacts.sh
go get github.com/kata-containers/packaging || true
pushd $GOPATH/src/github.com/kata-containers/packaging/release >>/dev/null
# Get versions information
tag=`echo $GITHUB_REF | cut -d/ -f3-`
popd >>/dev/null
pushd kata-artifacts >>/dev/null
for c in ./*.tar.gz
do
echo "untarring tarball $c"
tar -xvf $c
done
ls ./opt/kata/bin
ls ./opt/kata/share
tar cfJ ../kata-static.tar.xz ./opt
popd >>/dev/null
ls -l && ls kata-artifacts
- name: store-artifacts - name: store-artifacts
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with: