-
Notifications
You must be signed in to change notification settings - Fork 25
109 lines (108 loc) · 4.22 KB
/
create_release_branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Create Release Branch
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Name of the release (ie 5.5.0)'
required: true
releaseDescription:
description: "A short description of the release content (will be added the PR's body)"
required: false
nextReleaseVersion:
description: 'Next release version (1.1.1-SNAPSHOT)'
required: true
jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Create release branch
run: git checkout -b release/v${{ github.event.inputs.releaseVersion }}
- name: Initialize mandatory git config
run: |
git config user.name "GitHub Actions"
git config user.email [email protected]
- name: Change version number and set new snapshot version
run: |
printf '${{ github.event.inputs.releaseVersion }}' > ./VERSION.txt
printf '${{ github.event.inputs.nextReleaseVersion }}' > ./SNAPSHOT.txt
- name: Change version in package.json
uses: sergeysova/jq-action@v2
with:
cmd: "jq --arg a '${{ github.event.inputs.releaseVersion }}' '.version = $a' package.json > tmp.$$.json && mv tmp.$$.json package.json"
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install gitmoji-changelog
run: npm install -g gitmoji-changelog
- name: Update Changelog
run: gitmoji-changelog
- name: Commit changelog and manifest files
id: make-commit
run: |
git add ./VERSION.txt
git add ./SNAPSHOT.txt
git add ./package.json
git add ./CHANGELOG.md
git commit --message ":bookmark: Prepare release ${{ github.event.inputs.releaseVersion }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
git push origin release/v${{ github.event.inputs.releaseVersion }}
- name: Create Pull Request into main
uses: actions/github-script@v7
with:
script: |
const { repo, owner } = context.repo;
const result = await github.rest.pulls.create({
title: '[release-branch] v${{ github.event.inputs.releaseVersion }} into main',
owner,
repo,
head: 'release/v${{ github.event.inputs.releaseVersion }}',
base: 'main',
body: [
'⚙️ This PR was created in response workflow running.',
'---',
`➡️ I've updated the version name and code commit: ${{ steps.make-commit.outputs.commit }}.`,
'\n',
'📄 Release description :',
`- ${{ github.event.inputs.releaseDescription }}.`,
'\n',
'---',
'❤️ This PR is auto-generated by [actions/github-script](https://github.com/actions/github-script).'
].join('\n')
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['GitHub Actions', 'Release']
});
- name: Create Pull Request into develop
uses: actions/github-script@v7
with:
script: |
const { repo, owner } = context.repo;
const result = await github.rest.pulls.create({
title: '[release-branch] v${{ github.event.inputs.releaseVersion }} into develop',
owner,
repo,
head: 'release/v${{ github.event.inputs.releaseVersion }}',
base: 'develop',
body: [
'⚙️ This PR was created in response workflow running.',
'---',
`➡️ I've updated the version name and code commit: ${{ steps.make-commit.outputs.commit }}.`,
'\n',
'📄 Release description :',
`- ${{ github.event.inputs.releaseDescription }}.`,
'\n',
'---',
'❤️ This PR is auto-generated by [actions/github-script](https://github.com/actions/github-script).'
].join('\n')
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['GitHub Actions', 'Release']
});