Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYNC] : Hotfix 24.24.1 to develop #29

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions .github/actions/calculate-distribution-version/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
name: 'Calculate Distribution Version'
description: 'Calculate Next Distribution Version'

inputs:
is_hotfix:
description: '핫픽스를 위한 버전 여부'
default: false
required: false
file:
description: "업데이트 할 파일 경로"
required: true

outputs:
year:
description: "다음 정기배포 년도 버전"
Expand All @@ -17,7 +26,6 @@ outputs:
version_name:
description: "다음 정기배포 버전 네임"
value: ${{ steps.calc-next-version.outputs.version_name }}


runs:
using: "composite"
Expand All @@ -26,14 +34,30 @@ runs:
id: calc-next-version
shell: bash
run: |
# 다음 정기배포 버전 정보
year=$(TZ="Asia/Seoul" date +'%y')
week=$(TZ="Asia/Seoul" date +'%V')
hotfix=00

version_code="${year}${week}00"
version_name="${year}.${week}.0"

if ${{ inputs.is_hotfix }}; then
# 핫픽스 배포의 경우, 기존 버전 정보에서 핫픽스 번호 증가
if command -v jq &> /dev/null; then
year=$(jq -r .year ${{ inputs.file }})
week=$(jq -r .week_no ${{ inputs.file }})
hotfix=$(jq -r .hotfix ${{ inputs.file }})
else
year=$(sed -n 's/.*"year": \([0-9]*\).*/\1/p' ${{ inputs.file }})
week=$(sed -n 's/.*"week_no": \([0-9]*\).*/\1/p' ${{ inputs.file }})
hotfix=$(sed -n 's/.*"hotfix": \([0-9]*\).*/\1/p' ${{ inputs.file }})
fi

hotfix=$((hotfix + 1))
else
# 정기 배포의 경우, 현재 날짜 기준으로 새 버전 생성
year=$(TZ="Asia/Seoul" date +'%y')
week=$(TZ="Asia/Seoul" date +'%V')
hotfix=00 # 핫픽스 초기화
fi

version_code="$(printf "%02d" $year)$(printf "%02d" $week)$(printf "%02d" $hotfix)"
version_name="${year}.${week}.${hotfix}"

# 계산된 배포 버전 반환
echo "year=$year" >> $GITHUB_OUTPUT
echo "week=$week" >> $GITHUB_OUTPUT
echo "hotfix=$hotfix" >> $GITHUB_OUTPUT
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/create-hotfix-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "[CD] Create Hotfix Branch and Update App Version"

on:
workflow_dispatch:

env:
BRANCH_PREFIX: hotfix

permissions:
contents: write
pull-requests: write

jobs:
create-hotfix:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# with:
# ref: main

- name: Setup Git User Info
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

- name: Calculate Next Version
id: calculate-distribution-version
uses: ./.github/actions/calculate-distribution-version
with:
is_hotfix: true
file: ./app-version.json

- name: Check Release Branch
run: |
echo "원격 브랜치 중 '${{ env.BRANCH_PREFIX }}/*' 형태가 존재하는지 확인해요"
existing_branches=$(git ls-remote --heads origin | grep "refs/heads/${{ env.BRANCH_PREFIX }}/" || true)

if [ -n "$existing_branches" ]; then
formatted_branches=$(echo "$existing_branches" | sed 's/.*refs\/heads\///')
echo "$formatted_branches 브랜치들이 이미 존재해서 작업을 종료해요"
fi

- name: Create Milestone
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/milestones \
-d @- << EOF
{
"title": "${{ steps.calculate-distribution-version.outputs.version_name }}",
"due_on": "$(TZ="Asia/Seoul" date +'%Y-%m-%dT09:00:00Z')"
}
EOF

- name: Create Release Branch
run: |
branch_name="${{ env.BRANCH_PREFIX }}/${{ steps.calculate-distribution-version.outputs.version_code }}"

echo "릴리즈 브랜치 생성"
git switch -c $branch_name
git push origin $branch_name
echo "브랜치 $branch_name 생성했어요"

- name: Update App Version
uses: ./.github/actions/update-app-version
with:
year: ${{ steps.calculate-distribution-version.outputs.year }}
week_no: ${{ steps.calculate-distribution-version.outputs.week }}
hotfix: ${{ steps.calculate-distribution-version.outputs.hotfix }}
file: ./app-version.json

- name: Create Pull Request to Release
uses: ./.github/actions/create-pull-request-to-release
with:
branch: "${{ env.BRANCH_PREFIX }}/${{ steps.calculate-distribution-version.outputs.version_code }}"
version_name: "${{ steps.calculate-distribution-version.outputs.version_name }}"
github_token: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 2 additions & 0 deletions .github/workflows/create-release-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
- name: Calculate Release Version
id: calculate-distribution-version
uses: ./.github/actions/calculate-distribution-version
with:
file: ./app-version.json

- name: Check Release Branch
run: |
Expand Down
2 changes: 1 addition & 1 deletion app-version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"year": 24,
"week_no": 24,
"hotfix": 0
"hotfix": 1
}