-
Notifications
You must be signed in to change notification settings - Fork 34
71 lines (69 loc) · 2.44 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
name: "Create Release PR"
on:
workflow_dispatch:
inputs:
version:
description: New release version (e.g. 0.46.0)
type: string
required: true
target_branch:
description: Target branch to create a release/PR to
type: string
required: true
default: master
jobs:
create-release-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
token: "${{ secrets.RENKUBOT_GITHUB_TOKEN }}"
ref: '${{ github.event.inputs.target_branch}}'
- name: Setup Git
run: |
git config --global --add user.name "Renku Bot"
git config --global --add user.email "[email protected]"
git config push.autoSetupRemote true
- name: Create Branch
run: git checkout -b "release-${{ github.event.inputs.version }}"
- name: Update changelog
id: changelog
shell: bash
run: |
VERSION_LENGTH=$(echo -n "${{ github.event.inputs.version }}" | wc -m)
DELIMITER=$(printf "%.0s-" $(seq $VERSION_LENGTH))
sed -i -E "s/^(.*.. _changelog:)/\1\n\n${{ github.event.inputs.version }}\n$DELIMITER\n\n/" CHANGELOG.rst
head -n 10 CHANGELOG.rst
- name: Commit changes
run: |
git add CHANGELOG.rst
git commit -m "chore: create release ${{ github.event.inputs.version }}"
git push
- name: Create Pull Request
uses: actions/github-script@v7
with:
github-token: ${{ secrets.RENKUBOT_GITHUB_TOKEN }}
script: |
const { repo, owner } = context.repo;
const result = await github.rest.pulls.create({
title: 'release ${{ github.event.inputs.version }}',
owner,
repo,
head: 'release-${{ github.event.inputs.version }}',
base: '${{ github.event.inputs.target_branch }}',
draft: true,
body: [
'Release ${{ github.event.inputs.version }}',
'',
'This PR is auto-generated by [actions/github-script](https://github.com/actions/github-script).',
'',
'/deploy ',
].join('\n')
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['release']
});