Skip to content

Commit b8f1236

Browse files
committed
chore: creates gh action for preparing a release
1 parent 81ff174 commit b8f1236

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Create Release Branch and PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Release type (minor, patch, major)'
8+
required: false
9+
default: 'minor'
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
create_release_branch:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Get last commit author
25+
id: last_author
26+
run: |
27+
AUTHOR=$(git log -1 --pretty=format:'%ae')
28+
echo "author_email=$AUTHOR" >> $GITHUB_OUTPUT
29+
30+
- name: Create release branch
31+
run: |
32+
BRANCH="release-$(date +%Y%m%d%H%M%S)"
33+
git checkout -b "$BRANCH"
34+
echo "RELEASE_BRANCH=$BRANCH" >> $GITHUB_ENV
35+
36+
- name: Run release task and commit changes
37+
run: |
38+
git config user.name "github-actions[bot]"
39+
git config user.email "github-actions[bot]@users.noreply.github.com"
40+
task release:${{ github.event.inputs.release_type }}
41+
git push origin "$RELEASE_BRANCH"
42+
43+
- name: Find GitHub username by email
44+
id: find_user
45+
uses: actions/github-script@v7
46+
with:
47+
script: |
48+
const email = process.env['AUTHOR_EMAIL'] || '${{ steps.last_author.outputs.author_email }}';
49+
const { data: users } = await github.rest.search.users({ q: `${email} in:email` });
50+
if (users.items.length > 0) {
51+
core.setOutput('username', users.items[0].login);
52+
} else {
53+
core.setOutput('username', '');
54+
}
55+
56+
- name: Create Pull Request
57+
uses: peter-evans/create-pull-request@v5
58+
with:
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
branch: ${{ env.RELEASE_BRANCH }}
61+
title: "Release: ${{ github.event.inputs.release_type }}"
62+
body: "Automated release PR for ${{ github.event.inputs.release_type }}"
63+
assignees: ${{ steps.find_user.outputs.username }}

0 commit comments

Comments
 (0)