Skip to content

Commit

Permalink
Updated bump_version.yml action
Browse files Browse the repository at this point in the history
  • Loading branch information
dougollerenshaw committed Sep 19, 2024
1 parent 44784f4 commit 0820bd4
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
name: Bump version
name: Version Management

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
push:
branches:
- main

jobs:
preview-bump:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: "Preview version bump"
steps:
- name: Check out
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install commitizen
run: pip install commitizen

- name: Preview version bump
id: preview
run: |
if git log -1 --pretty=%B | grep -qE '^(feat|fix|BREAKING CHANGE):|#(minor|major)'; then
NEW_VERSION=$(cz bump --dry-run)
else
NEW_VERSION=$(cz bump --increment PATCH --dry-run)
fi
echo "New version would be: $NEW_VERSION"
echo "::set-output name=new_version::$NEW_VERSION"
- name: Comment PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: 'When merged, this PR will bump the version to: ${{ steps.preview.outputs.new_version }}'
})
bump-version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
name: "Bump version and create changelog with commitizen"
name: "Bump version and create changelog"
steps:
- name: Check out
uses: actions/checkout@v2
Expand Down

0 comments on commit 0820bd4

Please sign in to comment.