Skip to content

Create GitHub action to automate mcad release #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/mcad-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow will create a GitHub release tag

name: mcad Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag'
required: true
default: 'v0.0.0-dev'
type: string

jobs:
release:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: checkout code
uses: actions/checkout@v3

- name: check tag format
run: |
if [[ "${{ github.event.inputs.tag }}" =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$ ]]; then
echo "Tag format is valid."
else
echo "Invalid tag format: ${{ github.event.inputs.tag }}"
exit 1
fi

- name: Create github release tag
run: |
if git rev-parse -q --verify "refs/tags/${{ github.event.inputs.tag }}"; then
echo "Tag ${{ github.event.inputs.tag }} already exist. Exiting workflow."
exit 1
else
gh release create ${{ github.event.inputs.tag }} --title "MCAD ${{ github.event.inputs.tag }} Release" --generate-notes --target ${{ github.ref }}
fi
env:
GITHUB_TOKEN: ${{ github.token }}

1 change: 0 additions & 1 deletion CONTROLLER_VERSION

This file was deleted.

1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ COPY go.sum go.sum
COPY cmd cmd
COPY pkg pkg
COPY hack hack
COPY CONTROLLER_VERSION CONTROLLER_VERSION

RUN cd /workdir && curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/$(go env GOARCH)/kubectl && chmod +x kubectl
ENV GO_BUILD_ARGS=$GO_BUILD_ARGS
Expand Down
32 changes: 18 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
BIN_DIR=_output/bin
CAT_CMD=$(if $(filter $(OS),Windows_NT),type,cat)
VERSION_FILE=./CONTROLLER_VERSION
RELEASE_VER=v$(shell $(CAT_CMD) $(VERSION_FILE))
RELEASE_VER:=
CURRENT_DIR=$(shell pwd)
GIT_BRANCH:=$(shell git symbolic-ref --short HEAD 2>&1 | grep -v fatal)
#define the GO_BUILD_ARGS if you need to pass additional arguments to the go build
Expand All @@ -18,19 +17,18 @@ ifneq ($(strip $(git_repository_id)),)
TAG:=${TAG}${git_repository_id}-
endif

# Check for current branch name
# Check for current branch name and update 'RELEASE_VER' and 'TAG'
ifneq ($(strip $(GIT_BRANCH)),)
TAG:=${TAG}${GIT_BRANCH}

# replace invalid characters that might exist in the branch name
TAG:=$(shell echo ${TAG} | sed 's/[^a-zA-Z0-9]/-/g')
endif

# Check if the string does not contain "release"
ifeq (,$(findstring release,$(GIT_BRANCH)))
TAG:=${TAG}-${RELEASE_VER}
else
TAG:=$(shell echo ${TAG} | sed 's/\(release-v[0-9]\)-\([0-9]*\)-\([0-9]*\)/\1.\2.\3/g')
ifeq ($(shell echo $(GIT_BRANCH) | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$'),$(GIT_BRANCH))
RELEASE_VER:=${GIT_BRANCH}
TAG:=release-${TAG}
else
RELEASE_VER:= $(shell git describe --tags --abbrev=0)
TAG:=${TAG}${GIT_BRANCH}
# replace invalid characters that might exist in the branch name
TAG:=$(shell echo ${TAG} | sed 's/[^a-zA-Z0-9]/-/g')
TAG:=${TAG}-${RELEASE_VER}
endif
endif

.PHONY: print-global-variables
Expand Down Expand Up @@ -117,6 +115,12 @@ ifeq ($(strip $(git_repository_id)),main)
docker tag mcad-controller:${TAG} ${quay_repository}/mcad-controller:latest
docker push ${quay_repository}/mcad-controller:latest
endif
ifeq ($(filter release-v%,$(TAG)),)
$(info Update the `stable` tag to point `latest` release image)
STABLE_TAG:= stable
docker tag mcad-controller:latest ${quay_repository}/mcad-controller:$(STABLE_TAG)
docker push ${quay_repository}/mcad-controller:$(STABLE_TAG)
endif
endif

run-test:
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ Refer to [deployment instructions here](./doc/deploy/deployment.md) on how to de

## Release Process

1. Update version in [CONTROLLER_VERSION file](https://github.com/project-codeflare/multi-cluster-app-dispatcher/blob/main/CONTROLLER_VERSION) to the new release version.
1. Run the [mcad-release.yml](https://github.com/project-codeflare/actions/workflows/mcad-release.yml) action under `Actions` by entering the new release version in the `Release tag` input field and click `Run workflow`.
![mcad-release](doc/images/mcad-release.png)

2. Once CONTROLLER_VERSION file change merged , create the release branch against the main as `release-<version>`.
2. Verify that [mcad-release.yml](https://github.com/project-codeflare/actions/workflows/mcad-release.yml) action passed successfully. This workflow will create GitHub release tag.

3. The release branch then trigger the [image build/push pipeline](https://app.travis-ci.com/github/project-codeflare/multi-cluster-app-dispatcher/branches) and push the image to [mcad-controller quay repository](https://quay.io/repository/project-codeflare/mcad-controller?tab=tags) with specified release version tag.
3. The release tag then trigger the [image build/push pipeline](https://app.travis-ci.com/github/project-codeflare/multi-cluster-app-dispatcher/branches) and push the image to [mcad-controller quay repository](https://quay.io/repository/project-codeflare/mcad-controller?tab=tags) with specified release version tag.

4. Create a new release on [Releases page](https://github.com/project-codeflare/multi-cluster-app-dispatcher/releases) by creating a tag with same value as in CONTROLLER_VERSION file formatted (with v prefix) , provide proper release title and description.
4. Verify a new release is created on the [Releases page](https://github.com/project-codeflare/multi-cluster-app-dispatcher/releases) .

5. The latest release changes should also reflect in the [mcad go package module](https://pkg.go.dev/github.com/project-codeflare/multi-cluster-app-dispatcher).

Expand Down
3 changes: 1 addition & 2 deletions deployment/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ CAT_CMD=$(if $(filter $(OS),Windows_NT),type,cat)
OPERATOR_VERSION_FILE=./OPERATOR_VERSION
OPERATOR_VER=v$(shell $(CAT_CMD) $(OPERATOR_VERSION_FILE))
OPERATOR_VER_NUM=$(shell $(CAT_CMD) $(OPERATOR_VERSION_FILE))
CONTROLLER_VERSION_FILE=../CONTROLLER_VERSION
CONTROLLER_VER=v$(shell $(CAT_CMD) $(CONTROLLER_VERSION_FILE))
CONTROLLER_VER=$(shell git describe --tags --abbrev=0)

check_delete_operator:
@echo "****************************************************************************************************"
Expand Down
Binary file added doc/images/mcad-release.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.