Create Release Branch #1
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
# 새로운 버전의 Release Branch 생성 | |
name: Create Release Branch | |
on: | |
workflow_dispatch: | |
inputs: | |
artifact: | |
type: choice | |
description: 'artifact type' | |
required: true | |
default: 'Api' | |
options: | |
- 'Api' | |
- 'Batch' | |
version-up: | |
type: choice | |
description: 'version up type' | |
required: true | |
default: 'patch' | |
options: | |
- 'major' | |
- 'minor' | |
- 'patch' | |
jobs: | |
create-branch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.MY_TOKEN }} | |
fetch-depth: 0 | |
# 최신 Tag 가져오기 | |
- name: Get latest tag | |
id: get-latest-tag | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0 --match "${{ github.event.inputs.artifact }}-v*" 2>/dev/null || echo "") | |
echo "LATEST_TAG=$latest_tag" >> $GITHUB_OUTPUT | |
# 최신 Tag 기준으로 버전 업데이트 | |
- name: Version up | |
id: version-up | |
run: | | |
latest_tag=${{ steps.get-latest-tag.outputs.LATEST_TAG }} | |
if [ -z "$latest_tag" ]; then | |
new_version="1.0.0" | |
else | |
version=$(echo $latest_tag | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}') | |
if [ ${{ github.event.inputs.version-up }} == "major" ]; then | |
new_version=$(echo $version | awk -F'.' '{printf "%d.%d.%d", $1 + 1, 0, 0}') | |
elif [ ${{ github.event.inputs.version-up }} == "minor" ]; then | |
new_version=$(echo $version | awk -F'.' '{printf "%d.%d.%d", $1, $2 + 1, 0}') | |
else | |
new_version=$(echo $version | awk -F'.' '{printf "%d.%d.%d", $1, $2, $3 + 1}') | |
fi | |
fi | |
echo "NEW_VERSION=$new_version" >> $GITHUB_OUTPUT | |
# 새 버전 Release Branch 생성 | |
- name: Create and push release branch | |
run: | | |
new_version=${{ steps.version-up.outputs.NEW_VERSION }} | |
git checkout -b release/${{ github.event.inputs.artifact}}-v$new_version | |
git push origin release/${{ github.event.inputs.artifact}}-v$new_version |