Skip to content

Commit fe3871a

Browse files
committed
refactor: simplify release PR workflow
1 parent a0e3a7b commit fe3871a

1 file changed

Lines changed: 11 additions & 110 deletions

File tree

.github/workflows/create-release-pr.yml

Lines changed: 11 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -32,49 +32,32 @@ jobs:
3232
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3333

3434
steps:
35-
- name: 📋 Display Configuration
36-
run: |
37-
echo "============================================"
38-
echo "📦 Release Version: $VERSION"
39-
echo "🎯 Base Branch (PR Target): $BASE_BRANCH"
40-
echo "🌿 Release Branch (to create): $BRANCH"
41-
echo "============================================"
42-
43-
- name: ✅ Validate Base Branch
35+
- name: Validate Base Branch
4436
run: |
4537
if [[ "$BASE_BRANCH" == "main" ]]; then
46-
echo "Valid base branch: main"
38+
echo "Valid base branch: main"
4739
elif [[ "$BASE_BRANCH" =~ ^[0-9]+\.[0-9]+-main$ ]]; then
48-
echo "Valid base branch: $BASE_BRANCH"
40+
echo "Valid base branch: $BASE_BRANCH"
4941
else
50-
echo "ERROR: Invalid base branch '$BASE_BRANCH'"
42+
echo "ERROR: Invalid base branch '$BASE_BRANCH'"
5143
echo ""
5244
echo "Base branch must be either:"
5345
echo " - 'main' (for regular releases)"
5446
echo " - 'X.Y-main' (for version-specific releases, e.g., 5.4-main, 5.5-main)"
55-
echo ""
56-
echo "Examples:"
57-
echo " ✅ main"
58-
echo " ✅ 5.4-main"
59-
echo " ✅ 5.10-main"
60-
echo " ❌ master"
61-
echo " ❌ 5.4"
62-
echo " ❌ 5.4-develop"
6347
exit 1
6448
fi
6549
6650
- name: Checkout repository
6751
uses: actions/checkout@v5
6852
with:
69-
fetch-depth: 0 # Ensure full history for git log
53+
fetch-depth: 0
7054
fetch-tags: true
7155

7256
- name: Setup Git User
7357
uses: OneSignal/sdk-shared/.github/actions/setup-git-user@main
7458

7559
- name: Create release branch from base
7660
run: |
77-
7861
if git ls-remote --exit-code --heads origin "$BRANCH"; then
7962
echo "Deleting remote branch $BRANCH"
8063
git push origin --delete "$BRANCH"
@@ -93,91 +76,9 @@ jobs:
9376
git commit -am "chore: bump SDK_VERSION to $VERSION"
9477
git push origin "$BRANCH"
9578
96-
- name: Fetch Last GitHub Release Tag
97-
id: fetch_last_release
98-
run: |
99-
echo "Fetching latest GitHub release tag..."
100-
LAST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
101-
102-
if [[ -z "$LAST_TAG" ]]; then
103-
echo "❌ No previous release tag found. Cannot generate release notes."
104-
exit 0
105-
fi
106-
107-
echo "✅ Found last release tag: $LAST_TAG"
108-
echo "range=$LAST_TAG..HEAD" >> $GITHUB_OUTPUT
109-
110-
- name: Generate Release Notes from PR Titles
111-
id: generate_notes
112-
run: |
113-
if [[ "$VERSION" == *"alpha"* ]]; then
114-
CHANNEL="alpha"
115-
elif [[ "$VERSION" == *"beta"* ]]; then
116-
CHANNEL="beta"
117-
else
118-
CHANNEL="current"
119-
fi
120-
121-
echo "**Channels:** $CHANNEL" >> pr_body.md
122-
echo "" >> pr_body.md
123-
124-
RANGE="${{ steps.fetch_last_release.outputs.range }}"
125-
echo "📦 Commit range: $RANGE"
126-
127-
COMMITS=$(git log "$RANGE" --pretty=format:"%H" | sort -u)
128-
129-
if [[ -z "$COMMITS" ]]; then
130-
echo "❌ No commits found. Exiting."
131-
exit 0
132-
fi
133-
134-
> raw_titles.txt
135-
for SHA in $COMMITS; do
136-
PR_INFO=$(gh api "repos/${{ github.repository }}/commits/$SHA/pulls" \
137-
-H "Accept: application/vnd.github.groot-preview+json" 2>/dev/null)
138-
139-
TITLE=$(echo "$PR_INFO" | jq -r '.[0].title // empty')
140-
NUMBER=$(echo "$PR_INFO" | jq -r '.[0].number // empty')
141-
142-
if [[ -n "$TITLE" && -n "$NUMBER" ]]; then
143-
echo "$TITLE ([#$NUMBER](https://github.com/${{ github.repository }}/pull/$NUMBER))" >> raw_titles.txt
144-
echo "✅ $SHA → $TITLE (#$NUMBER)"
145-
else
146-
echo "⚠️ $SHA → No PR found"
147-
fi
148-
done
149-
150-
sort -fu raw_titles.txt > pr_titles.txt
151-
152-
if [[ ! -s pr_titles.txt ]]; then
153-
echo "❌ No PR titles found from commits. Exiting."
154-
exit 0
155-
fi
156-
157-
echo "" >> pr_body.md
158-
echo "### 🚀 New Features" >> pr_body.md
159-
grep -i '^feat' pr_titles.txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
160-
161-
echo "" >> pr_body.md
162-
echo "### 🐛 Bug Fixes" >> pr_body.md
163-
grep -i '^bug' pr_titles.txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
164-
165-
echo "" >> pr_body.md
166-
echo "### 🔧 Improvements" >> pr_body.md
167-
grep -i -E '^(perf|refactor)' pr_titles.txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
168-
169-
echo "" >> pr_body.md
170-
echo "### 📝 Uncategorized PRs" >> pr_body.md
171-
grep -v -i -E '^(feat|bug|perf|refactor)' pr_titles.txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
172-
173-
echo "" >> pr_body.md
174-
echo "### 📦 Version" >> pr_body.md
175-
echo "$VERSION" >> pr_body.md
176-
177-
- name: Create Pull Request
178-
run: |
179-
gh pr create \
180-
--title "Release SDK v$VERSION" \
181-
--body-file pr_body.md \
182-
--head "$BRANCH" \
183-
--base "$BASE_BRANCH"
79+
create-release:
80+
needs: bump-version
81+
uses: OneSignal/sdk-shared/.github/workflows/create-release.yml@main
82+
with:
83+
release_branch: rel/${{ github.event.inputs.version }}
84+
target_branch: ${{ github.event.inputs.base_branch || 'main' }}

0 commit comments

Comments
 (0)