Skip to content

Commit 8a754ad

Browse files
authored
Merge pull request #357 from kmcquade/add-version-bump-automation
Add version bump automation
2 parents 44f0a00 + cd4f9d5 commit 8a754ad

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.github/workflows/bump-version.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Bump Version
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
bump-version:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Bump version
15+
run: sh ${GITHUB_WORKSPACE}/utils/bump-version.sh

utils/bump-version.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
version_file="policy_sentry/bin/version.py"
5+
# https://github.com/bridgecrewio/checkov/blob/master/.github/workflows/build.yml#L87-L132
6+
7+
git config --local user.email "[email protected]"
8+
git config --local user.name "GitHub Action"
9+
git pull
10+
git fetch --tags
11+
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
12+
echo "latest tag: $latest_tag"
13+
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)}')
14+
echo "new tag: $new_tag"
15+
16+
echo "# pylint: disable=missing-module-docstring\n__version__ = '$new_tag'""" > $version_file
17+
18+
git commit -m "Bump to ${new_tag}" $version_file || echo "No changes to commit"
19+
git push origin

0 commit comments

Comments
 (0)