Skip to content

Commit

Permalink
[#557] Add Create Release Pull Request workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
markgravity committed Nov 13, 2024
1 parent cdef603 commit 99d94b8
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/project_workflows/configs/changelog-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"categories": [
{
"title": "## ✨ Features",
"labels": [
"type: feature"
]
},
{
"title": "## 🐛 Bug fixes",
"labels": [
"type: bug"
]
},
{
"title": "## 🧹 Chores",
"labels": [
"type: chore"
]
},
{
"title": "## Others",
"exclude_labels": [
"type: feature",
"type: bug",
"type: chore",
"type: release"
]
}
],
"max_pull_requests": 200
}
98 changes: 98 additions & 0 deletions .github/project_workflows/create_release_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Create Release Pull Request

on:
workflow_dispatch:
inputs:
nextVersion:
description: "Next version (eg. 1.0.0)"
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
create_release_pull_request:
name: Create Release Pull Request
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Find HEAD commit
id: head
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Build changelog on "main"
id: changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
configuration: ".github/workflows/configs/changelog-config.json"
# Listing PRs from the last tag to the HEAD commit
toTag: ${{ steps.head.outputs.sha }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare variables
run: |
filename=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj \; | head -n 1)
release_version=$(sed -n 's/.*MARKETING_VERSION *= *\([^;]*\);.*/\1/p' "$filename.xcodeproj/project.pbxproj" | head -n 1 | sed 's/^[^=]*=\s*//' | tr -d ' ')
echo $release_version
echo "RELEASE_VERSION=$release_version" >> "$GITHUB_ENV"
echo "${{ steps.changelog.outputs.changelog }}" | sed 's/"/\\"/g' > escaped-changelog.txt
- name: Create Release branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: release/${{ env.RELEASE_VERSION }}

- name: Create pull request
run: gh pr create --draft -B main -H release/${{ env.RELEASE_VERSION }} -t 'Release - ${{ env.RELEASE_VERSION }}' -b "$(cat escaped-changelog.txt)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

create_bump_version_pull_request:
name: Create Bump Version Pull Request
runs-on: macos-latest
timeout-minutes: 30
permissions:
contents: write
pull-requests: write
steps:
- name: Create Bump Version branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: chore/bump-version-to-${{ github.event.inputs.nextVersion }}

- name: Checkout code
uses: actions/checkout@v4
with:
ref: chore/bump-version-to-${{ github.event.inputs.nextVersion }}

- name: Bump version
run: |
filename=$(find . -maxdepth 1 -name "*.xcodeproj" -exec basename {} .xcodeproj \; | head -n 1)
sed -i "" "s/MARKETING_VERSION = .*/MARKETING_VERSION = ${{ github.event.inputs.nextVersion }};/g" $filename.xcodeproj/project.pbxproj
- name: Set up Git
run: |
git config --global user.name 'Github Actions'
git config --global user.email '[email protected]'
- name: Commit changes
run: |
git add .
git commit -m "[Chore] Bump version to ${{ github.event.inputs.nextVersion }}"
git push origin HEAD
- name: Create pull request
run: |
echo -e "## What happened 👀\n\nBump version to ${{ github.event.inputs.nextVersion }}" > body
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"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 99d94b8

Please sign in to comment.