Merge pull request #3067 from github/update-v3.30.0-92eada825 · github/codeql-action@2d92b76 (original) (raw)
``
1
`+
name: "Prepare mergeback branch"
`
``
2
`+
description: Prepares a mergeback branch and opens a PR for it
`
``
3
`+
inputs:
`
``
4
`+
base:
`
``
5
`+
description: "The name of the base branch"
`
``
6
`+
required: true
`
``
7
`+
head:
`
``
8
`+
description: "The name of the head branch"
`
``
9
`+
required: true
`
``
10
`+
branch:
`
``
11
`+
description: "The name of the branch to create."
`
``
12
`+
required: true
`
``
13
`+
version:
`
``
14
`+
description: "The new version"
`
``
15
`+
required: true
`
``
16
`+
token:
`
``
17
`+
description: "The token to use"
`
``
18
`+
required: true
`
``
19
`+
dry-run:
`
``
20
`+
description: "Set to true to skip creating the PR. The branch will still be pushed."
`
``
21
`+
default: "false"
`
``
22
`+
runs:
`
``
23
`+
using: composite
`
``
24
`+
steps:
`
``
25
`+
- name: Create mergeback branch
`
``
26
`+
shell: bash
`
``
27
`+
env:
`
``
28
`+
VERSION: "${{ inputs.version }}"
`
``
29
`+
NEW_BRANCH: "${{ inputs.branch }}"
`
``
30
`+
run: |
`
``
31
`+
set -exu
`
``
32
+
``
33
`+
Ensure we are on the new branch
`
``
34
`+
git checkout "${NEW_BRANCH}"
`
``
35
+
``
36
`+
Update the version number ready for the next release
`
``
37
`+
npm version patch --no-git-tag-version
`
``
38
+
``
39
`+
Update the changelog, adding a new version heading directly above the most recent existing one
`
``
40
`+
awk '!f && /##/{print "'"## [UNRELEASED]\n\nNo user facing changes.\n"'"; f=1}1' CHANGELOG.md > temp && mv temp CHANGELOG.md
`
``
41
`+
git add .
`
``
42
`+
git commit -m "Update changelog and version after ${VERSION}"
`
``
43
+
``
44
`+
git push origin "${NEW_BRANCH}"
`
``
45
+
``
46
`+
- name: Create PR
`
``
47
`+
shell: bash
`
``
48
`+
if: inputs.dry-run != 'true'
`
``
49
`+
env:
`
``
50
`+
VERSION: "${{ inputs.version }}"
`
``
51
`+
BASE_BRANCH: "${{ inputs.base }}"
`
``
52
`+
HEAD_BRANCH: "${{ inputs.head }}"
`
``
53
`+
NEW_BRANCH: "${{ inputs.branch }}"
`
``
54
`+
GITHUB_TOKEN: "${{ inputs.token }}"
`
``
55
`+
run: |
`
``
56
`+
set -exu
`
``
57
`+
pr_title="Mergeback VERSION{VERSION} VERSION{HEAD_BRANCH} into ${BASE_BRANCH}"
`
``
58
`+
pr_body=$(cat << EOF
`
``
59
`+
This PR bumps the version number and updates the changelog after the ${VERSION} release.
`
``
60
+
``
61
`+
Please do the following:
`
``
62
+
``
63
`+
- Remove and re-add the "Rebuild" label to the PR to trigger just this workflow.
`
``
64
`+
- Wait for the "Rebuild" workflow to push a commit updating the distribution files.
`
``
65
`+
- Mark the PR as ready for review to trigger the full set of PR checks.
`
``
66
`+
- Approve and merge the PR. When merging the PR, make sure "Create a merge commit" is
`
``
67
`+
selected rather than "Squash and merge" or "Rebase and merge".
`
``
68
`+
EOF
`
``
69
`+
)
`
``
70
+
``
71
`+
PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft
`
``
72
`+
so that a maintainer can take the PR out of draft, thereby triggering the PR checks.
`
``
73
`+
gh pr create \
`
``
74
`+
--head "${NEW_BRANCH}" \
`
``
75
`+
--base "${BASE_BRANCH}" \
`
``
76
`+
--title "${pr_title}" \
`
``
77
`+
--label "Rebuild" \
`
``
78
`+
--body "${pr_body}" \
`
``
79
`+
--assignee "${GITHUB_ACTOR}" \
`
``
80
`+
--draft
`