Release: Bump #3
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: "Release: Bump" | |
on: | |
workflow_dispatch: | |
inputs: | |
force_version_bump: | |
required: false | |
default: "" | |
type: choice | |
options: | |
- "" | |
- patch | |
- minor | |
- major | |
concurrency: | |
group: release | |
jobs: | |
UnitTests: | |
name: Unit Tests | |
uses: ./.github/workflows/code_quality.yml | |
with: | |
branch: mainline | |
secrets: inherit | |
Bump: | |
needs: UnitTests | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: mainline | |
fetch-depth: 0 | |
token: ${{ secrets.CI_TOKEN }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: ConfigureGit | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "client-software-ci" | |
- name: Bump | |
run: | | |
BUMP_ARGS="" | |
if [[ "${{ inputs.force_version_bump }}" != "" ]]; then | |
BUMP_ARGS="$BUMP_ARGS --${{ inputs.force_version_bump }}" | |
fi | |
# Backup actual changelog to preserve its contents | |
touch CHANGELOG.md | |
cp CHANGELOG.md CHANGELOG.bak.md | |
# Run semantic-release to generate new changelog | |
pip install --upgrade hatch | |
hatch env create release | |
NEXT_SEMVER=$(hatch run release:bump $BUMP_ARGS) | |
# Grab the new version's changelog and prepend it to the original changelog contents | |
python .github/scripts/get_latest_changelog.py > NEW_LOG.md | |
cat NEW_LOG.md CHANGELOG.bak.md > CHANGELOG.md | |
rm NEW_LOG.md | |
git checkout -b bump/$NEXT_SEMVER | |
git add CHANGELOG.md | |
git commit -sm "chore(release): $NEXT_SEMVER" | |
echo "NEXT_SEMVER=$NEXT_SEMVER" >> $GITHUB_ENV | |
{ | |
echo 'RELEASE_NOTES<<EOF' | |
python .github/scripts/get_latest_changelog.py | |
echo EOF | |
} >> $GITHUB_ENV | |
- name: PushPR | |
env: | |
GH_TOKEN: ${{ secrets.CI_TOKEN }} | |
run: | | |
git push -u origin bump/$NEXT_SEMVER | |
# Needs "Allow GitHub Actions to create and approve pull requests" under Settings > Actions | |
gh pr create --base mainline --title "chore(release): $NEXT_SEMVER" --body "$RELEASE_NOTES" |