Skip to content

Commit

Permalink
chore: add action to automate creation of release branches/prs (#3427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius authored Jan 22, 2024
1 parent 1d4a2c9 commit 1ee1979
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/create-release-branch.yml
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']
});

0 comments on commit 1ee1979

Please sign in to comment.