[ignore] Added a release PR step to commit a version bump messages #17
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_pr | |
on: | |
push: | |
branches: | |
- release-pr-test | |
jobs: | |
release-pr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Unshallow | |
run: git fetch --prune --unshallow | |
# Setup | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- run: pip install git-cliff typos | |
- name: Set git config | |
run: git config user.email "dcn-ecosystem@cisco.com" && git config user.name "dcn-ecosystem" | |
# Check new changlog entry for version bump type | |
- name: Find version bump type | |
id: type | |
run: | | |
changelog=$(git cliff --unreleased) | |
case $changelog in | |
*"BREAKING CHANGES:"* ) | |
echo "MAJOR" | |
echo "bump="MAJOR"" >> $GITHUB_OUTPUT | |
;; | |
*"IMPROVEMENTS:"* ) | |
echo "MINOR" | |
echo "bump="MINOR"" >> $GITHUB_OUTPUT | |
;; | |
*"DEPRECATIONS:"* ) | |
echo "MINOR" | |
echo "bump="MINOR"" >> $GITHUB_OUTPUT | |
;; | |
* ) | |
echo "PATCH" | |
echo "bump="PATCH"" >> $GITHUB_OUTPUT | |
;; | |
esac | |
# Commit major or minor version change messages | |
# NOTE: Without these commit messages git-cliff will only increase patch version. | |
- name: Commit major version change message | |
if: steps.type.outputs.bump == 'MAJOR' | |
run: 'git commit -m "major: [ignore] Major version change" --allow-empty' | |
- name: Commit minor version change message | |
if: steps.type.outputs.bump == 'MINOR' | |
run: 'git commit -m "minor: [ignore] Minor version change" --allow-empty' | |
# git-cliff generates CHANGELOG.md | |
- name: Get next version | |
id: vars | |
run: echo "version=$(git cliff --bumped-version)" >> $GITHUB_OUTPUT | |
- name: Generate changelog output | |
run: git cliff --bump --unreleased | |
- name: Prepend new changelog entry | |
run: git cliff --bump --unreleased -p CHANGELOG.md | |
# Generate annotation_unsupported.go | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- name: Generate annotation unsupported provider code | |
run: go generate | |
env: | |
GEN_ANNOTATION_UNSUPPORTED: '1' | |
# Commit changes to release_pr branch | |
- name: Commit | |
run: git add -u && git status && git commit -m "[ignore] Update Changelog and annotation_unsupported.go for new release (${{ steps.vars.outputs.version }})" | |
- name: Branch & Push | |
run: git checkout -b release_pr && git push --set-upstream origin release_pr --force && git clean -f -d | |
# Create or update release PR | |
- run: gh pr create --base master --head release_pr --title "Pre-Release PR (${{ steps.vars.outputs.version }})" --body "" | |
id: pr | |
continue-on-error: true | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: gh pr edit release_pr --title "Pre-Release PR (${{ steps.vars.outputs.version }})" | |
if: steps.pr.outcome == 'failure' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |