From fe166c7900d47fbee670f397866a7cb5620a1d6c Mon Sep 17 00:00:00 2001 From: marcel Date: Thu, 25 Jan 2024 00:45:46 +0100 Subject: [PATCH] Simplify the release workflow by moving it to generic ubuntu runner Signed-off-by: marcel --- .github/workflows/release.yaml | 31 ++++--- test/prepare-platform.sh | 148 +++++++++++++++++---------------- 2 files changed, 97 insertions(+), 82 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a072d188..9ccdd8ae 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,30 +6,41 @@ on: - v* jobs: - call-build: - uses: IndustryFusion/DigitalTwin/.github/workflows/build.yaml@main - call-test: - uses: IndustryFusion/DigitalTwin/.github/workflows/k8s-tests.yaml@main push-release-images: - needs: call-test - runs-on: private + runs-on: ubuntu-22.04 env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} DOCKER_PREFIX: ${{ secrets.DOCKER_PREFIX }} - SELF_HOSTED_RUNNER: true + BUILDONLY: true steps: + - uses: actions/checkout@v2 + - name: Prepare K3d cluster + run: | + cd ./test && bash ./prepare-platform.sh + sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java + java --version + - name: Build Platform locally + run: | + export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 + cd test && bash build-local-platform.sh - name: Push release images shell: bash run: | set +o pipefail docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" TARGET_DOCKER_TAG=`git describe --tags --exact-match` || exit 1 + echo Selected tag ${TARGET_DOCKER_TAG} # Tag and push passed "k3d-iff.localhost:12345" with release tag - images=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep ":${TARGET_DOCKER_TAG}") + docker images + images=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep ":${TARGET_DOCKER_TAG}" | grep "k3d-iff.localhost") + echo I will push the following images: ${images} for image in $images; do - newimage=$(echo $image | sed -r "s/k3d-iff.localhost:12345/${DOCKER_PREFIX}/g"); + newimage=$(echo $image | sed -r "s/k3d-iff.localhost:12345/docker.io/g"); + echo I will push image ${image} as ${newimage} docker tag ${image} ${newimage}; docker push ${newimage}; done - + - name: Setup upterm session + if: failure() + uses: lhotari/action-upterm@v1 diff --git a/test/prepare-platform.sh b/test/prepare-platform.sh index d4e945a6..99384e28 100644 --- a/test/prepare-platform.sh +++ b/test/prepare-platform.sh @@ -46,6 +46,7 @@ sudo chmod +x /usr/bin/docker-compose printf "\033[1mSuccessfully installed docker-compose %s\033[0m\n" printf "\n" + echo Installing kubectl echo ---------------------- sudo apt -qq install snapd @@ -63,27 +64,29 @@ curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | TAG=v5.4 k3d registry create iff.localhost -p 12345 k3d cluster create --image ${K3S_IMAGE} -a 2 --registry-use k3d-iff.localhost:12345 iff-cluster -echo Install Helm v3.10.3 -echo --------------- - # helm v3.10.3 -wget https://get.helm.sh/helm-v3.10.3-linux-amd64.tar.gz -tar -zxvf helm-v3.10.3-linux-amd64.tar.gz -sudo mv linux-amd64/helm /usr/bin/helm -rm helm-v3.10.3-linux-amd64.tar.gz - -echo Install Helm diff plugin -echo ------------------------ -helm plugin install https://github.com/databus23/helm-diff - -echo Install Helmfile 0.149.0 -echo ---------------- -cd ../helm || exit 1 -# helmfile v0.149.0 -wget https://github.com/helmfile/helmfile/releases/download/v0.149.0/helmfile_0.149.0_linux_amd64.tar.gz -tar -zxvf helmfile_0.149.0_linux_amd64.tar.gz -chmod u+x helmfile -rm helmfile_0.149.0_linux_amd64.tar.gz -cd - +if [ -z "$BUILDONLY" ];then + echo Install Helm v3.10.3 + echo --------------- + # helm v3.10.3 + wget https://get.helm.sh/helm-v3.10.3-linux-amd64.tar.gz + tar -zxvf helm-v3.10.3-linux-amd64.tar.gz + sudo mv linux-amd64/helm /usr/bin/helm + rm helm-v3.10.3-linux-amd64.tar.gz + + echo Install Helm diff plugin + echo ------------------------ + helm plugin install https://github.com/databus23/helm-diff + + echo Install Helmfile 0.149.0 + echo ---------------- + cd ../helm || exit 1 + # helmfile v0.149.0 + wget https://github.com/helmfile/helmfile/releases/download/v0.149.0/helmfile_0.149.0_linux_amd64.tar.gz + tar -zxvf helmfile_0.149.0_linux_amd64.tar.gz + chmod u+x helmfile + rm helmfile_0.149.0_linux_amd64.tar.gz + cd - +fi echo Install Java 17 echo --------------- @@ -105,57 +108,58 @@ sudo mv maven.sh /etc/profile.d/ source /etc/profile.d/maven.sh mvn --version - -echo Install shellcheck -echo ------------------ -sudo apt install -yq shellcheck - -echo Install jq -echo ------------------ -sudo apt install -yq jq - -echo Install kafkacat -echo ------------------ -sudo apt install -yq kafkacat - -echo Install bats -echo ------------------ -sudo apt install -yq bats - -echo Install kubefwd -echo ------------------ -wget https://github.com/txn2/kubefwd/releases/download/1.22.0/kubefwd_Linux_x86_64.tar.gz -tar xvzf kubefwd_Linux_x86_64.tar.gz -sudo mv kubefwd /usr/local/bin -rm kubefwd_Linux_x86_64.tar.gz - -echo Install bats version 1.9.0 -echo ------------------ -wget https://github.com/bats-core/bats-core/archive/refs/tags/v1.9.0.tar.gz -tar -zxvf v1.9.0.tar.gz -sudo ./bats-core-1.9.0/install.sh /usr/local -rm -rf v1.9.0.tar.gz bats-core-1.9.0 - -echo Install sqlite and pcre component -echo --------------------------------- -sudo apt install -yq sqlite3 sqlite3-pcre - -echo Install python3-pip -echo ------------------- -sudo apt install -yq python3-pip python3-venv - -echo Install nodejs -echo ------------------- -sudo apt remove -y nodejs libnode-dev libnode72 -sudo apt purge -y nodejs -curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh -sudo bash /tmp/nodesource_setup.sh -sudo apt install -y nodejs - - -echo Install Bats -echo ------------------- -sudo apt install -yq bats +if [ -z "$BUILDONLY" ];then + echo Install shellcheck + echo ------------------ + sudo apt install -yq shellcheck + + echo Install jq + echo ------------------ + sudo apt install -yq jq + + echo Install kafkacat + echo ------------------ + sudo apt install -yq kafkacat + + echo Install bats + echo ------------------ + sudo apt install -yq bats + + echo Install kubefwd + echo ------------------ + wget https://github.com/txn2/kubefwd/releases/download/1.22.0/kubefwd_Linux_x86_64.tar.gz + tar xvzf kubefwd_Linux_x86_64.tar.gz + sudo mv kubefwd /usr/local/bin + rm kubefwd_Linux_x86_64.tar.gz + + echo Install bats version 1.9.0 + echo ------------------ + wget https://github.com/bats-core/bats-core/archive/refs/tags/v1.9.0.tar.gz + tar -zxvf v1.9.0.tar.gz + sudo ./bats-core-1.9.0/install.sh /usr/local + rm -rf v1.9.0.tar.gz bats-core-1.9.0 + + echo Install sqlite and pcre component + echo --------------------------------- + sudo apt install -yq sqlite3 sqlite3-pcre + + echo Install python3-pip + echo ------------------- + sudo apt install -yq python3-pip python3-venv + + echo Install nodejs + echo ------------------- + sudo apt remove -y nodejs libnode-dev libnode72 + sudo apt purge -y nodejs + curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh + sudo bash /tmp/nodesource_setup.sh + sudo apt install -y nodejs + + + echo Install Bats + echo ------------------- + sudo apt install -yq bats +fi if [ -n "${SELF_HOSTED_RUNNER}" ]; then echo Change group of /etc/hosts