Skip to content

Commit

Permalink
Add automation to create a release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed Jan 22, 2025
1 parent 07c47b1 commit 7c748e9
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .ci/scripts/create_release_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -eu -o pipefail

BRANCH="$(git branch --show-current)"

if ! [[ "${BRANCH}" = "develop" ]]
then
echo ERROR: This is not the main branch!
exit 1
fi

NEW_VERSION="$(bump-my-version show new_version --increment release | sed -Ene 's/^([[:digit:]]+\.[[:digit:]]+)\.[[:digit:]]+$/\1/p')"

if [[ -z "${NEW_VERSION}" ]]
then
echo ERROR: Could not parse new version.
exit 1
fi

NEW_BRANCH="RELEASE-${NEW_VERSION}"

git branch "${NEW_BRANCH}"

bump-my-version bump minor --commit --message $'Bump version to {new_version}' --allow-dirty

git push origin "${NEW_BRANCH}"

if [ "${GITHUB_ENV:-}" ]
then
echo "NEW_BRANCH=${NEW_BRANCH}" >> "${GITHUB_ENV}"
fi
46 changes: 46 additions & 0 deletions .github/workflows/release_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: "Create Release Branch"
on:
workflow_dispatch:

jobs:
create-release-branch:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.13"
- name: "Setup git"
run: |
git config user.name pulpbot
git config user.email [email protected]
- name: "Install python dependencies"
run: |
pip install bump-my-version~=0.29.0
- name: "Create Release Branch"
run: |
.ci/scripts/create_release_branch.sh
- name: "Create Pull Request"
uses: "peter-evans/create-pull-request@v7"
with:
token: "${{ secrets.RELEASE_TOKEN }}"
title: "Bump dev-version"
body: ""
branch: "bump_version"
delete-branch: true
- name: "Add Backport Label for new Branch"
uses: "actions/github-script@v7"
with:
script: |
const { NEW_BRANCH } = process.env;
const labelName = "backport-" + NEW_BRANCH;
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: labelName,
color: "C8780A",
});
...

0 comments on commit 7c748e9

Please sign in to comment.