44 pull_request :
55 types : [closed]
66 branches : [main]
7+ workflow_dispatch :
8+ inputs :
9+ version :
10+ description : ' Specific version to update (optional)'
11+ required : false
12+ type : string
713
814permissions :
915 contents : write
1016
1117jobs :
1218 update-description :
1319 runs-on : ubuntu-latest
14- # Only run when release PR is merged (branch starts with 'release/')
20+ # Run on manual dispatch OR when release PR is merged
1521 if : |
16- github.event.pull_request.merged == true &&
17- startsWith(github.event.pull_request.head.ref, 'release/')
22+ github.event_name == 'workflow_dispatch' ||
23+ (github.event.pull_request.merged == true &&
24+ startsWith(github.event.pull_request.head.ref, 'release/'))
1825
1926 steps :
2027 - name : Checkout code
@@ -25,80 +32,96 @@ jobs:
2532
2633 - name : Update release workflow description
2734 run : |
28- echo "✅ Release PR merged: ${{ github.event.pull_request.title }}"
29- echo " Branch: ${{ github.event.pull_request.head.ref }}"
30- echo " Proceeding with description update"
31-
32- # Wait for release tag to be created (Release workflow runs after PR merge)
33- echo "⏳ Waiting for release tag to be created..."
34- for i in {1..12}; do
35- sleep 10
35+ # 수동 실행 시와 PR 머지 시를 구분하여 처리
36+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
37+ echo "🔄 Manual execution triggered"
38+ echo "📋 This will update the workflow description with the latest version"
39+
40+ # 수동 실행 시에는 최신 태그를 찾아서 업데이트
3641 LATEST_TAG=$(git fetch --tags && git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+-[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
3742 if [ -n "$LATEST_TAG" ]; then
3843 LATEST_VERSION=$(echo "$LATEST_TAG" | sed 's/^v//')
39- # Extract expected version from branch to verify
40- BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
41- EXPECTED_VERSION=$(echo "$BRANCH_NAME" | sed 's|release/||')
42-
43- if [ "$LATEST_VERSION" = "$EXPECTED_VERSION" ]; then
44- echo "✅ Found expected release tag: ${LATEST_TAG}"
45- break
46- else
47- echo " Found tag ${LATEST_TAG} but expected ${EXPECTED_VERSION}, continuing to wait..."
48- fi
44+ echo "✅ Found latest release tag: ${LATEST_TAG}"
4945 else
50- echo " No release tags found yet, waiting... (${i}/12)"
46+ echo "❌ No release tags found"
47+ exit 1
5148 fi
52- done
53-
54- if [ -n "$LATEST_VERSION" ] && [ "$LATEST_VERSION" = "$EXPECTED_VERSION" ]; then
55- echo "📋 Using release version: ${LATEST_VERSION}"
56-
57- # Extract version parts for next version suggestions
58- CURRENT_KOTLIN=$(echo "$LATEST_VERSION" | cut -d'-' -f1)
59- CURRENT_LIB=$(echo "$LATEST_VERSION" | cut -d'-' -f2)
60-
61- # Extract library version parts (MAJOR.MINOR.PATCH)
62- LIB_MAJOR=$(echo "$CURRENT_LIB" | cut -d'.' -f1)
63- LIB_MINOR=$(echo "$CURRENT_LIB" | cut -d'.' -f2)
64- LIB_PATCH=$(echo "$CURRENT_LIB" | cut -d'.' -f3)
65-
66- # Calculate next versions
67- NEXT_PATCH="${CURRENT_KOTLIN}-${LIB_MAJOR}.${LIB_MINOR}.$((LIB_PATCH + 1))"
68- NEXT_MINOR="${CURRENT_KOTLIN}-${LIB_MAJOR}.$((LIB_MINOR + 1)).0"
69-
70- # Get current Kotlin version from build.gradle.kts
71- BUILD_KOTLIN_VERSION=$(grep 'kotlin("jvm") version' build.gradle.kts | sed 's/.*version "\([^"]*\)".*/\1/')
49+ else
50+ echo "✅ Release PR merged: ${{ github.event.pull_request.title }}"
51+ echo " Branch: ${{ github.event.pull_request.head.ref }}"
52+ echo " Proceeding with description update"
7253
73- # Create new description with suggested versions
74- SUGGESTED_TEXT="${NEXT_PATCH} (patch), ${NEXT_MINOR} (minor)"
54+ # Wait for release tag to be created (Release workflow runs after PR merge)
55+ echo "⏳ Waiting for release tag to be created..."
56+ for i in {1..12}; do
57+ sleep 10
58+ LATEST_TAG=$(git fetch --tags && git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+-[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
59+ if [ -n "$LATEST_TAG" ]; then
60+ LATEST_VERSION=$(echo "$LATEST_TAG" | sed 's/^v//')
61+ # Extract expected version from branch to verify
62+ BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
63+ EXPECTED_VERSION=$(echo "$BRANCH_NAME" | sed 's|release/||')
64+
65+ if [ "$LATEST_VERSION" = "$EXPECTED_VERSION" ]; then
66+ echo "✅ Found expected release tag: ${LATEST_TAG}"
67+ break
68+ else
69+ echo " Found tag ${LATEST_TAG} but expected ${EXPECTED_VERSION}, continuing to wait..."
70+ fi
71+ else
72+ echo " No release tags found yet, waiting... (${i}/12)"
73+ fi
74+ done
7575
76- # Check if Kotlin version has been updated
77- if [ "$CURRENT_KOTLIN" != "$BUILD_KOTLIN_VERSION" ]; then
78- KOTLIN_UPDATE="${BUILD_KOTLIN_VERSION}-0.0.1"
79- SUGGESTED_TEXT="${SUGGESTED_TEXT}, ${KOTLIN_UPDATE} (Kotlin update)"
76+ if [ -n "$LATEST_VERSION" ] && [ "$LATEST_VERSION" = "$EXPECTED_VERSION" ]; then
77+ echo "📋 Using release version: ${LATEST_VERSION}"
78+
79+ # Extract version parts for next version suggestions
80+ CURRENT_KOTLIN=$(echo "$LATEST_VERSION" | cut -d'-' -f1)
81+ CURRENT_LIB=$(echo "$LATEST_VERSION" | cut -d'-' -f2)
82+
83+ # Extract library version parts (MAJOR.MINOR.PATCH)
84+ LIB_MAJOR=$(echo "$CURRENT_LIB" | cut -d'.' -f1)
85+ LIB_MINOR=$(echo "$CURRENT_LIB" | cut -d'.' -f2)
86+ LIB_PATCH=$(echo "$CURRENT_LIB" | cut -d'.' -f3)
87+
88+ # Calculate next versions
89+ NEXT_PATCH="${CURRENT_KOTLIN}-${LIB_MAJOR}.${LIB_MINOR}.$((LIB_PATCH + 1))"
90+ NEXT_MINOR="${CURRENT_KOTLIN}-${LIB_MAJOR}.$((LIB_MINOR + 1)).0"
91+
92+ # Get current Kotlin version from build.gradle.kts
93+ BUILD_KOTLIN_VERSION=$(grep 'kotlin("jvm") version' build.gradle.kts | sed 's/.*version "\([^"]*\)".*/\1/')
94+
95+ # Create new description with suggested versions
96+ SUGGESTED_TEXT="${NEXT_PATCH} (patch), ${NEXT_MINOR} (minor)"
97+
98+ # Check if Kotlin version has been updated
99+ if [ "$CURRENT_KOTLIN" != "$BUILD_KOTLIN_VERSION" ]; then
100+ KOTLIN_UPDATE="${BUILD_KOTLIN_VERSION}-0.0.1"
101+ SUGGESTED_TEXT="${SUGGESTED_TEXT}, ${KOTLIN_UPDATE} (Kotlin update)"
102+ fi
103+
104+ # Use sed to update the description lines in the workflow file
105+ # First, find and replace the "Current:" line
106+ sed -i "s/Current: .*/Current: ${LATEST_VERSION}/" .github/workflows/create-release-pr.yml
107+
108+ # Then, find and replace the "Suggested:" line
109+ sed -i "s/Suggested: .*/Suggested: ${SUGGESTED_TEXT}/" .github/workflows/create-release-pr.yml
110+
111+ echo "✅ Updated description with latest version: ${LATEST_VERSION}"
112+ echo "📝 New suggested versions: ${SUGGESTED_TEXT}"
113+ else
114+ echo "❌ Failed to find expected release tag after waiting 2 minutes"
115+ echo " Expected version: ${EXPECTED_VERSION} from branch ${BRANCH_NAME}"
116+ echo " Latest found tag: ${LATEST_TAG:-"none"}"
117+ echo " Release workflow may still be running, will retry on next trigger"
118+ exit 1
80119 fi
81-
82- # Use sed to update the description lines in the workflow file
83- # First, find and replace the "Current:" line
84- sed -i "s/Current: .*/Current: ${LATEST_VERSION}/" .github/workflows/create-release-pr.yml
85-
86- # Then, find and replace the "Suggested:" line
87- sed -i "s/Suggested: .*/Suggested: ${SUGGESTED_TEXT}/" .github/workflows/create-release-pr.yml
88-
89- echo "✅ Updated description with latest version: ${LATEST_VERSION}"
90- echo "📝 New suggested versions: ${SUGGESTED_TEXT}"
91- else
92- echo "❌ Failed to find expected release tag after waiting 2 minutes"
93- echo " Expected version: ${EXPECTED_VERSION} from branch ${BRANCH_NAME}"
94- echo " Latest found tag: ${LATEST_TAG:-"none"}"
95- echo " Release workflow may still be running, will retry on next trigger"
96- exit 1
97120 fi
98121
99122 - name : Create PR for workflow description update
100123 env :
101- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
124+ GITHUB_TOKEN : ${{ secrets.WORKFLOW_UPDATE_TOKEN }}
102125 run : |
103126 # Check if there are changes
104127 if git diff --quiet .github/workflows/create-release-pr.yml; then
0 commit comments