fix: fix cicd build project #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |