Skip to content

Commit 1d7cbee

Browse files
committed
Create GitHub action to automate mcad release
1 parent 9035cd7 commit 1d7cbee

File tree

6 files changed

+65
-22
lines changed

6 files changed

+65
-22
lines changed

.github/workflows/mcad-release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow will create a GitHub release tag
2+
3+
name: mcad Release
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
tag:
8+
description: 'Release tag'
9+
required: true
10+
default: 'v0.0.0-dev'
11+
type: string
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Configure Git
22+
run: |
23+
git config user.name "GitHub Actions"
24+
git config user.email "github-actions@github.com"
25+
26+
- name: check tag format
27+
run: |
28+
if [[ "${{ github.event.inputs.tag }}" =~ "^v\d+\.\d+\.\d+$" ]]; then
29+
echo "Tag format is valid."
30+
else
31+
echo "Invalid tag format: ${{ github.event.inputs.tag }}"
32+
exit 1
33+
fi
34+
35+
- name: Create github release tag
36+
run: |
37+
if git rev-parse -q --verify "refs/tags/${{ github.event.inputs.tag }}"; then
38+
echo "Tag ${{ github.event.inputs.tag }} already exist. Exiting workflow."
39+
exit 1
40+
else
41+
gh release create ${{ github.event.inputs.tag }} --title "MCAD ${{ github.event.inputs.tag }} Release" --generate-notes
42+
fi

CONTROLLER_VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ COPY go.sum go.sum
99
COPY cmd cmd
1010
COPY pkg pkg
1111
COPY hack hack
12-
COPY CONTROLLER_VERSION CONTROLLER_VERSION
1312

1413
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
1514
ENV GO_BUILD_ARGS=$GO_BUILD_ARGS

Makefile

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
BIN_DIR=_output/bin
22
CAT_CMD=$(if $(filter $(OS),Windows_NT),type,cat)
3-
VERSION_FILE=./CONTROLLER_VERSION
4-
RELEASE_VER=v$(shell $(CAT_CMD) $(VERSION_FILE))
3+
RELEASE_VER:=
54
CURRENT_DIR=$(shell pwd)
65
GIT_BRANCH:=$(shell git symbolic-ref --short HEAD 2>&1 | grep -v fatal)
76
#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)),)
1817
TAG:=${TAG}${git_repository_id}-
1918
endif
2019

21-
# Check for current branch name
20+
# Check for current branch name and update 'RELEASE_VER' and 'TAG'
2221
ifneq ($(strip $(GIT_BRANCH)),)
23-
TAG:=${TAG}${GIT_BRANCH}
24-
25-
# replace invalid characters that might exist in the branch name
26-
TAG:=$(shell echo ${TAG} | sed 's/[^a-zA-Z0-9]/-/g')
27-
endif
28-
29-
# Check if the string does not contain "release"
30-
ifeq (,$(findstring release,$(GIT_BRANCH)))
31-
TAG:=${TAG}-${RELEASE_VER}
32-
else
33-
TAG:=$(shell echo ${TAG} | sed 's/\(release-v[0-9]\)-\([0-9]*\)-\([0-9]*\)/\1.\2.\3/g')
22+
ifeq ($(shell echo $(GIT_BRANCH) | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$'),$(GIT_BRANCH))
23+
RELEASE_VER:=${GIT_BRANCH}
24+
TAG:=release-${TAG}
25+
else
26+
RELEASE_VER:= $(shell curl -s https://pkg.go.dev/github.com/project-codeflare/multi-cluster-app-dispatcher | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
27+
TAG:=${TAG}${GIT_BRANCH}
28+
# replace invalid characters that might exist in the branch name
29+
TAG:=$(shell echo ${TAG} | sed 's/[^a-zA-Z0-9]/-/g')
30+
TAG:=${TAG}-${RELEASE_VER}
31+
endif
3432
endif
3533

3634
.PHONY: print-global-variables
@@ -117,6 +115,12 @@ ifeq ($(strip $(git_repository_id)),main)
117115
docker tag mcad-controller:${TAG} ${quay_repository}/mcad-controller:latest
118116
docker push ${quay_repository}/mcad-controller:latest
119117
endif
118+
ifeq ($(filter release-v%,$(TAG)),)
119+
$(info Update the `stable` tag to point `latest` release image)
120+
STABLE_TAG:= stable
121+
docker tag mcad-controller:latest ${quay_repository}/mcad-controller:$(STABLE_TAG)
122+
docker push ${quay_repository}/mcad-controller:$(STABLE_TAG)
123+
endif
120124
endif
121125

122126
run-test:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Refer to [deployment instructions here](./doc/deploy/deployment.md) on how to de
1717

1818
## Release Process
1919

20-
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.
20+
1. Run the [mcad-release.yml](https://github.com/project-codeflare/actions/workflows/mcad-release.yml) action.
2121

22-
2. Once CONTROLLER_VERSION file change merged , create the release branch against the main as `release-<version>`.
22+
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.
2323

24-
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.
24+
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.
2525

26-
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.
26+
4. Verify a new release is created on the [Releases page](https://github.com/project-codeflare/multi-cluster-app-dispatcher/releases) .
2727

2828
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).
2929

deployment/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ CAT_CMD=$(if $(filter $(OS),Windows_NT),type,cat)
77
OPERATOR_VERSION_FILE=./OPERATOR_VERSION
88
OPERATOR_VER=v$(shell $(CAT_CMD) $(OPERATOR_VERSION_FILE))
99
OPERATOR_VER_NUM=$(shell $(CAT_CMD) $(OPERATOR_VERSION_FILE))
10-
CONTROLLER_VERSION_FILE=../CONTROLLER_VERSION
11-
CONTROLLER_VER=v$(shell $(CAT_CMD) $(CONTROLLER_VERSION_FILE))
10+
CONTROLLER_VER=$(shell curl -s https://pkg.go.dev/github.com/project-codeflare/multi-cluster-app-dispatcher | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
1211

1312
check_delete_operator:
1413
@echo "****************************************************************************************************"

0 commit comments

Comments
 (0)