-
-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (36 loc) · 1.44 KB
/
create-release-branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright © 2023 KubeCub open source community. All rights reserved.
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
name: Create Release Branch
on:
push:
branches:
- main
tags:
- 'v*'
jobs:
create_release_branch:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create release branch
run: |
# Gets the currently pushed tag
TAG_NAME=$(echo "${GITHUB_REF}" | sed -e 's,.*/\(.*\),\1,')
# Check whether the tag format meets expectations
if [[ "${TAG_NAME}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR_VERSION=${BASH_REMATCH[1]}
MINOR_VERSION=${BASH_REMATCH[2]}
PATCH_VERSION=${BASH_REMATCH[3]}
if [[ ${PATCH_VERSION} -eq 0 && ! ${TAG_NAME} =~ [A-Za-z-] ]]; then
RELEASE_BRANCH_NAME="release-v${MAJOR_VERSION}.0"
git branch "${RELEASE_BRANCH_NAME}" "${TAG_NAME}"
git push origin "${RELEASE_BRANCH_NAME}"
echo "Created release branch: ${RELEASE_BRANCH_NAME}"
else
echo "Tag format is invalid or does not meet the conditions. Release branch not created."
fi
else
echo "Tag format is invalid. Release branch not created."
fi