Version bump #94
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: Version bump | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
inputs: | |
versionPart: | |
description: "Version bump part" | |
required: true | |
default: patch | |
type: choice | |
options: | |
- prepatch | |
- patch | |
- minor | |
- major | |
jobs: | |
deploy: | |
name: Version bump on release branch | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
- name: Install Poetry | |
run: pipx install poetry | |
- name: Add Poetry Version for __init__.py | |
run: poetry self add poetry-bumpversion | |
- name: Setup git config | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
git checkout -b release | |
- name: Bump Version | |
id: bump_version | |
run: | | |
VERSION=$(poetry version --short) | |
poetry version ${{ github.event.inputs.versionPart }} | |
BUMPED_VERSION=$(poetry version --short) | |
echo "BUMPED_VERSION=$BUMPED_VERSION" >> $GITHUB_OUTPUT | |
echo "PRE_BUMP_VERSION=$VERSION" >> $GITHUB_OUTPUT | |
- name: Commiting Version change | |
run: | | |
git add --all | |
git commit -m "π Package ${{ steps.bump_version.outputs.PRE_BUMP_VERSION }} to ${{ steps.bump_version.outputs.BUMPED_VERSION }}" | |
- name: Git push | |
run: | | |
git push origin release --force | |
- name: Create Pull Request | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { repo, owner } = context.repo; | |
let page = 1; | |
let bumpCommits = []; | |
let shouldContinue = true; | |
while (shouldContinue) { | |
const { data: commits } = await github.rest.repos.listCommits({ | |
owner: owner, | |
repo: repo, | |
per_page: 100, | |
page: page++ | |
}); | |
for (const commit of commits) { | |
if (commit.commit.message.startsWith('π')) { | |
shouldContinue = false; | |
break; | |
} else { | |
const firstLine = commit.commit.message.split('\n')[0]; | |
const commitLink = `- [${firstLine}](${commit.html_url})`; | |
bumpCommits.push(commitLink); | |
} | |
} | |
if (commits.length < 100) { | |
// Break on last page | |
shouldContinue = false; | |
} | |
} | |
let bodyText = [ | |
'Bumps Package Version ${{ steps.bump_version.outputs.PRE_BUMP_VERSION }} --> ${{ steps.bump_version.outputs.BUMPED_VERSION }},', | |
'', | |
'# What\'s Changed', | |
'', | |
...bumpCommits | |
].join('\n'); | |
console.log("PR Text: ", bodyText) | |
const result = await github.rest.pulls.create({ | |
title: 'π Bump to Version: ${{ steps.bump_version.outputs.BUMPED_VERSION }}', | |
owner, | |
repo, | |
head: 'release', | |
base: 'main', | |
body: bodyText, | |
}); | |
github.rest.issues.addLabels({ | |
owner, | |
repo, | |
issue_number: result.data.number, | |
labels: ['release', 'automated pr', 'auto-release'] | |
}); |