Skip to content

Commit b51a06f

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

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

.github/workflows/mcad-release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# This workflow will create a release branch and 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: set release branch
27+
id: release-branch
28+
run: |
29+
if [[ "${{ github.event.inputs.tag }}" =~ "^v\d+\.\d+\.\d+$" ]]; then
30+
echo ":: set-output name=release_branch::release-${{ github.events.inputs.tag }}"
31+
else
32+
echo "Invalid tag format: ${{ github.event.inputs.tag }}"
33+
exit 1
34+
fi
35+
36+
- name: Create release branch
37+
run: |
38+
if git rev-parse -q --verify "refs/remotes/origin/release-v${{ github.event.inputs.tag }}; then
39+
echo "Branch ${{ steps.release-branch.outputs.release_branch }} already exist. Exiting workflow."
40+
exit 1
41+
else
42+
git checkout -b ${{ steps.release-branch.outputs.release_branch }}
43+
git push origin ${{ steps.release-branch.outputs.release_branch }}
44+
fi
45+
46+
- name: Create github release tag
47+
run: |
48+
if git rev-parse -q --verify "refs/tags/${{ github.event.inputs.tag }}"; then
49+
echo "Tag ${{ github.event.inputs.tag }} already exist. Exiting workflow."
50+
exit 1
51+
else
52+
gh release create ${{ github.event.inputs.tag }} --title "MCAD ${{ github.event.inputs.tag }} Release" --generate-notes
53+
fi

CONTROLLER_VERSION

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

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
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
87
GO_BUILD_ARGS?=
98

9+
ifeq ($(findstring release-,$(GIT_BRANCH)),release-)
10+
ifeq ($(shell echo $(GIT_BRANCH) | grep -E '^release-v[0-9]+\.[0-9]+\.[0-9]+$$'),$(GIT_BRANCH))
11+
RELEASE_VER:=$(subst release-,,$(GIT_BRANCH))
12+
endif
13+
else
14+
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)
15+
endif
16+
1017
# Reset branch name if this a Travis CI environment
1118
ifneq ($(strip $(TRAVIS_BRANCH)),)
1219
GIT_BRANCH:=${TRAVIS_BRANCH}
@@ -117,6 +124,12 @@ ifeq ($(strip $(git_repository_id)),main)
117124
docker tag mcad-controller:${TAG} ${quay_repository}/mcad-controller:latest
118125
docker push ${quay_repository}/mcad-controller:latest
119126
endif
127+
ifeq ($(filter release-v%,$(TAG)),)
128+
$(info Update the `stable` tag to point `latest` release image)
129+
STABLE_TAG:= stable
130+
docker tag mcad-controller:latest ${quay_repository}/mcad-controller:$(STABLE_TAG)
131+
docker push ${quay_repository}/mcad-controller:$(STABLE_TAG)
132+
endif
120133
endif
121134

122135
run-test:

README.md

Lines changed: 3 additions & 3 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 release branch and GitHub release tag.
2323

2424
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.
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

0 commit comments

Comments
 (0)