Skip to content

Commit f3b9c25

Browse files
committed
ci: create release PR
1 parent def8368 commit f3b9c25

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Create Unity Release PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'New Unity SDK version (e.g. 5.4.0-alpha01 or 3.2.1)'
8+
type: string
9+
required: true
10+
base_branch:
11+
description: 'Target branch for the PR (e.g. main for regular releases, 5.4-main for patch releases)'
12+
type: string
13+
required: false
14+
default: 'main'
15+
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
20+
jobs:
21+
create-unity-release:
22+
runs-on: ubuntu-latest
23+
24+
env:
25+
VERSION: ${{ github.event.inputs.version }}
26+
BASE_BRANCH: ${{ github.event.inputs.base_branch || 'main' }}
27+
BRANCH: release/${{ github.event.inputs.version }}
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
30+
steps:
31+
- name: 📋 Display Configuration
32+
run: |
33+
echo "============================================"
34+
echo "🎮 Creating Unity SDK Release"
35+
echo "📦 Version: $VERSION"
36+
echo "🎯 Base Branch (PR Target): $BASE_BRANCH"
37+
echo "🌿 Release Branch (to create): $BRANCH"
38+
echo "============================================"
39+
40+
- name: ✅ Validate Base Branch
41+
run: |
42+
if [[ "$BASE_BRANCH" == "main" ]]; then
43+
echo "✅ Valid base branch: main"
44+
elif [[ "$BASE_BRANCH" =~ ^[0-9]+\.[0-9]+-main$ ]]; then
45+
echo "✅ Valid base branch: $BASE_BRANCH"
46+
else
47+
echo "❌ ERROR: Invalid base branch '$BASE_BRANCH'"
48+
echo ""
49+
echo "Base branch must be either:"
50+
echo " - 'main' (for regular releases)"
51+
echo " - 'X.Y-main' (for patch lines, e.g., 5.4-main)"
52+
exit 1
53+
fi
54+
55+
- name: Checkout repository
56+
uses: actions/checkout@v4
57+
with:
58+
fetch-depth: 0
59+
fetch-tags: true
60+
61+
- name: Create release branch from base
62+
run: |
63+
if git ls-remote --exit-code --heads origin "$BRANCH"; then
64+
echo "Deleting remote branch $BRANCH"
65+
git push origin --delete "$BRANCH"
66+
fi
67+
68+
echo "Creating release branch $BRANCH from $BASE_BRANCH"
69+
git checkout -b "$BRANCH" origin/$BASE_BRANCH
70+
71+
- name: Run composeRelease.sh
72+
run: |
73+
chmod +x ./composeRelease.sh
74+
./composeRelease.sh $VERSION
75+
shell: bash
76+
77+
- name: Commit and Push version bump
78+
run: |
79+
git config user.name "github-actions[bot]"
80+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
81+
82+
if git diff --quiet; then
83+
echo "No version changes detected."
84+
else
85+
git commit -am "chore(release): prepare Unity SDK v$VERSION"
86+
git push origin "$BRANCH"
87+
fi
88+
89+
- name: Generate PR Body
90+
run: |
91+
echo "## 🎮 Unity SDK Release v$VERSION" > pr_body.md
92+
echo "" >> pr_body.md
93+
echo "**Summary:**" >> pr_body.md
94+
echo "- Automated release PR created by CI." >> pr_body.md
95+
echo "- Includes version bumps and changelog updates performed by composeRelease.sh." >> pr_body.md
96+
echo "" >> pr_body.md
97+
echo "**Next Steps:**" >> pr_body.md
98+
echo "1. Review and approve this PR." >> pr_body.md
99+
echo "2. Merge into \`$BASE_BRANCH\`." >> pr_body.md
100+
echo "3. Verify the generated draft GitHub release and attach the updated *.unitypackage if needed." >> pr_body.md
101+
echo "" >> pr_body.md
102+
echo "_This PR was auto-generated by create-unity-release CI._" >> pr_body.md
103+
104+
- name: Create Pull Request
105+
run: |
106+
gh pr create \
107+
--title "Release Unity SDK v$VERSION" \
108+
--body-file pr_body.md \
109+
--head "$BRANCH" \
110+
--base "$BASE_BRANCH"

0 commit comments

Comments
 (0)