Skip to content

Add version bump automation #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Bump Version

on:
release:
types: [ published ]
workflow_dispatch:

jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Bump version
run: sh ${GITHUB_WORKSPACE}/utils/bump-version.sh
19 changes: 19 additions & 0 deletions utils/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -ex

version_file="policy_sentry/bin/version.py"
# https://github.com/bridgecrewio/checkov/blob/master/.github/workflows/build.yml#L87-L132

git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git pull
git fetch --tags
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "latest tag: $latest_tag"
new_tag=$(echo $latest_tag | awk -F. -v a="$1" -v b="$2" -v c="$3" '{printf("%d.%d.%d", $1+a, $2+b , $3+1)}')
echo "new tag: $new_tag"

echo "# pylint: disable=missing-module-docstring\n__version__ = '$new_tag'""" > $version_file

git commit -m "Bump to ${new_tag}" $version_file || echo "No changes to commit"
git push origin