-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add action to automate creation of release branches/prs (#3427)
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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@v6 | ||
with: | ||
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 }}', | ||
body: [ | ||
'/deploy ', | ||
'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: ['release'] | ||
}); | ||