release version v0.1.4 (release) #291
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Images | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch to use' | |
required: true | |
default: 'main' | |
env: | |
PACKER_VERSION: "latest" | |
QCOW2_IMG: ${{ vars.REGISTRY }}/${{ vars.REPO }}/vjailbreak | |
UI_IMG: ${{ vars.REGISTRY }}/${{ vars.REPO }}/vjailbreak-ui | |
V2V_IMG: ${{ vars.REGISTRY }}/${{ vars.REPO }}/vjailbreak-v2v-helper | |
CONTROLLER_IMG: ${{ vars.REGISTRY }}/${{ vars.REPO }}/vjailbreak-controller | |
jobs: | |
build-containers: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# - name: Bump version | |
# id: bump_version | |
# uses: phips28/gh-action-bump-version@master | |
# with: | |
# minor-wording: 'add,Adds,new' | |
# major-wording: 'MAJOR,cut-major' | |
# patch-wording: 'patch,fixes' # Providing patch-wording will override commits | |
# # defaulting to a patch bump. | |
# rc-wording: 'RELEASE,alpha' | |
# skip-tag: 'true' | |
# skip-commit: 'true' | |
# skip-push: 'true' | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set environment variables for images | |
run: | | |
# Get the branch name, remove 'refs/heads/' from github.ref | |
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-') | |
GIT_SHA=$(echo "$(git rev-parse --short HEAD)") | |
GIT_BRANCH=$(echo "$(git rev-parse --abbrev-ref HEAD)") | |
# if its a release event bump the version and use that as tag | |
if [[ "${{ github.event_name }}" == "release" ]]; then | |
# In case of release event the tag will be the next version | |
# build version will be the same as tag | |
TAG=${{ github.event.release.tag_name }} | |
BUILD_VERSION=${TAG} | |
else | |
BUILD_VERSION=${{ github.run_number }} | |
# build release version as version-branch-sha | |
VERSION=${BUILD_VERSION}-${GIT_BRANCH}-${GIT_SHA} | |
# Since this is a merge or pull-request | |
# use the TAG as the version | |
TAG=${VERSION} | |
fi | |
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "TAG=${TAG}" >> $GITHUB_ENV | |
echo "QCOW2_IMG=${{ env.QCOW2_IMG }}:$TAG" >> $GITHUB_ENV | |
echo "UI_IMG=${{ env.UI_IMG }}:$TAG" >> $GITHUB_ENV | |
echo "V2V_IMG=${{ env.V2V_IMG }}:$TAG" >> $GITHUB_ENV | |
echo "CONTROLLER_IMG=${{ env.CONTROLLER_IMG }}:$TAG" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ vars.REGISTRY }} | |
username: ${{ secrets.QUAY_ROBOT_USERNAME }} | |
password: ${{ secrets.QUAY_ROBOT_PASSWORD }} | |
- name: Build and push UI image | |
run: make ui | |
- name: Build and push v2v-helper image | |
run: make v2v-helper | |
- name: Build and push controller image | |
run: make -o v2v-helper vjail-controller | |
- name: Create deploy folder | |
run: mkdir -p image_builder/deploy | |
- name: Substitue image tags in manifests | |
uses: danielr1996/[email protected] | |
with: | |
input: ./ui/deploy/ui.yaml | |
output: ./image_builder/deploy/01ui.yaml | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '>=1.22.5' | |
- name: Generate Controller Manifests | |
run: | | |
make -C ./k8s/migration/ build-installer | |
cp ./k8s/migration/dist/install.yaml image_builder/deploy/00controller.yaml | |
cp -r ./k8s/kube-prometheus image_builder/deploy/ | |
- name: Check PR Title | |
id: check_pr | |
run: | | |
echo "PR message: ${{ github.event.pull_request.title }}" | |
if [[ "${{ github.event.pull_request.title }}" == *"release"* ]]; then | |
echo "Release keyword found." | |
echo "release_found=true" >> $GITHUB_ENV | |
else | |
echo "Release keyword not found." | |
echo "release_found=false" >> $GITHUB_ENV | |
fi | |
- name: Check if release event | |
id: check_release | |
run: | | |
if [[ "${{ github.event_name }}" == "release" ]]; then | |
echo "release_found=true" >> $GITHUB_ENV | |
fi | |
- name: Check if manual trigger from main branch | |
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' | |
run: echo "release_found=true" >> $GITHUB_ENV | |
id: check_manual_trigger | |
- name: Enable KVM group perms | |
if: env.release_found == 'true' | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Set up QEMU | |
if: env.release_found == 'true' | |
run: sudo apt-get update && sudo apt-get install qemu-system qemu-utils -y | |
- name: Setup `packer` | |
if: env.release_found == 'true' | |
uses: hashicorp/setup-packer@main | |
id: setup | |
with: | |
version: ${{ env.PACKER_VERSION }} | |
- name: Run `packer init` | |
if: env.release_found == 'true' | |
id: init | |
run: "packer init ./image_builder/vjailbreak-image.pkr.hcl" | |
- name: Run `packer validate` | |
if: env.release_found == 'true' | |
id: validate | |
run: "packer validate ./image_builder/vjailbreak-image.pkr.hcl" | |
- name: setup-oras | |
uses: oras-project/[email protected] | |
- name: Download base image | |
if: env.release_found == 'true' | |
run: | | |
oras pull quay.io/platform9/vjailbreak:base-v0.1.4 | |
- name: Run `packer build` | |
if: env.release_found == 'true' | |
id: build | |
run: "PACKER_LOG=1 packer build ./image_builder/vjailbreak-image.pkr.hcl" | |
- name: Upload vjailbreak qcow2 to quay | |
if: env.release_found == 'true' | |
run: | | |
oras push ${{ env.QCOW2_IMG }} \ | |
--artifact-type="application/qcow2" \ | |
./vjailbreak_qcow2/vjailbreak-image.qcow2 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: vjailbreak-yamls | |
path: | | |
image_builder/deploy/00controller.yaml | |
image_builder/deploy/01ui.yaml | |