Create Release PR #26
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
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'] | |
}); | |