diff --git a/.github/workflows/mcad-release.yml b/.github/workflows/mcad-release.yml new file mode 100644 index 000000000..b5480cb95 --- /dev/null +++ b/.github/workflows/mcad-release.yml @@ -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 }} + diff --git a/CONTROLLER_VERSION b/CONTROLLER_VERSION deleted file mode 100644 index 34aae156b..000000000 --- a/CONTROLLER_VERSION +++ /dev/null @@ -1 +0,0 @@ -1.31.0 diff --git a/Dockerfile b/Dockerfile index 47acff9e3..acbe1a9ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index 68cd689cb..76e23110a 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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: diff --git a/README.md b/README.md index 52b60600a..33ef3d2d5 100644 --- a/README.md +++ b/README.md @@ -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-`. +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). diff --git a/deployment/Makefile b/deployment/Makefile index abcdcde2b..53f25c4f3 100644 --- a/deployment/Makefile +++ b/deployment/Makefile @@ -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 "****************************************************************************************************" diff --git a/doc/images/mcad-release.png b/doc/images/mcad-release.png new file mode 100644 index 000000000..0bc5fdfc7 Binary files /dev/null and b/doc/images/mcad-release.png differ