Skip to content

Commit 61fd6bc

Browse files
committed
[#557] Add Create Release Pull Request workflow
1 parent 42c5ca0 commit 61fd6bc

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"categories": [
3+
{
4+
"title": "## ✨ Features",
5+
"labels": [
6+
"type: feature"
7+
]
8+
},
9+
{
10+
"title": "## 🐛 Bug fixes",
11+
"labels": [
12+
"type: bug"
13+
]
14+
},
15+
{
16+
"title": "## 🧹 Chores",
17+
"labels": [
18+
"type: chore"
19+
]
20+
},
21+
{
22+
"title": "## Others",
23+
"exclude_labels": [
24+
"type: feature",
25+
"type: bug",
26+
"type: chore",
27+
"type: release"
28+
]
29+
}
30+
],
31+
"max_pull_requests": 200
32+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Create Release Pull Request
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
nextVersion:
7+
description: "Next version (eg. 1.0.0)"
8+
required: true
9+
type: string
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
create_release_pull_request:
17+
name: Create Release Pull Request
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 30
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Find HEAD commit
25+
id: head
26+
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
27+
28+
- name: Build changelog on "main"
29+
id: changelog
30+
uses: mikepenz/release-changelog-builder-action@v4
31+
with:
32+
configuration: ".github/workflows/configs/changelog-config.json"
33+
# Listing PRs from the last tag to the HEAD commit
34+
toTag: ${{ steps.head.outputs.sha }}
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Prepare variables
38+
run: |
39+
echo "RELEASE_VERSION=$(grep -oP 'MARKETING_VERSION\s*=\s*[^;]+' {PROJECT_NAME}.xcodeproj/project.pbxproj | head -n 1 | sed 's/^[^=]*=\s*//' | tr -d ' ')" >> $GITHUB_ENV
40+
echo "${{ steps.changelog.outputs.changelog }}" | sed 's/"/\\"/g' > escaped-changelog.txt
41+
42+
- name: Create Release branch
43+
uses: peterjgrainger/[email protected]
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
with:
47+
branch: release/${{ env.RELEASE_VERSION }}
48+
49+
- name: Create pull request
50+
run: gh pr create --draft -B main -H release/${{ env.RELEASE_VERSION }} -t 'Release - ${{ env.RELEASE_VERSION }}' -b "$(cat escaped-changelog.txt)"
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
create_bump_version_pull_request:
55+
name: Create Bump Version Pull Request
56+
runs-on: macos-latest
57+
timeout-minutes: 30
58+
permissions:
59+
contents: write
60+
pull-requests: write
61+
steps:
62+
- name: Create Bump Version branch
63+
uses: peterjgrainger/[email protected]
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
branch: chore/bump-version-to-${{ github.event.inputs.nextVersion }}
68+
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
with:
72+
ref: chore/bump-version-to-${{ github.event.inputs.nextVersion }}
73+
74+
- name: Bump version
75+
run: sed -i "" "s/MARKETING_VERSION = .*/MARKETING_VERSION = ${{ github.event.inputs.nextVersion }};/g" {PROJECT_NAME}.xcodeproj/project.pbxproj
76+
77+
- name: Set up Git
78+
run: |
79+
git config --global user.name 'Github Actions'
80+
git config --global user.email '[email protected]'
81+
82+
- name: Commit changes
83+
run: |
84+
git add .
85+
git commit -m "[Chore] Bump version to ${{ github.event.inputs.nextVersion }}"
86+
git push origin HEAD
87+
88+
- name: Create pull request
89+
run: |
90+
echo -e "## What happened 👀\n\nBump version to ${{ github.event.inputs.nextVersion }}" > body
91+
export body=$(cat body) ; gh pr create --draft -B develop -H chore/bump-version-to-${{ github.event.inputs.nextVersion }} -t '[Chore] Bump version to ${{ github.event.inputs.nextVersion }}' -b "$body"
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)