-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from tawanda-kembo/feat/automate-versioning
chore: update GitHub Actions workflow and add contribution guidelines
- Loading branch information
Showing
2 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,28 +8,27 @@ on: | |
jobs: | ||
tag: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Git | ||
run: | | ||
git config --global user.name "github-actions" | ||
git config --global user.email "[email protected]" | ||
- name: Bump version and push tag | ||
id: tag | ||
uses: anothrNick/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tag_prefix: "v" | ||
release_branches: main | ||
custom_tag: | | ||
if [[ ${{ github.event.head_commit.message }} =~ ^(feat|fix|perf|refactor|BREAKING CHANGE|build|ci|chore|docs|style|test): ]]; then | ||
echo "::set-output name=custom_tag::${{ steps.tag.outputs.tag_name }}" | ||
fi | ||
env: | ||
DEFAULT_BUMP: minor | ||
run: ./bump_version.sh | ||
|
||
- name: Create Release | ||
if: steps.tag.outputs.tag_name != '' | ||
if: success() | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ steps.tag.outputs.tag_name }} | ||
release_name: Release ${{ steps.tag.outputs.tag_name }} | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: | | ||
See [CHANGELOG](https://github.com/tawanda-kembo/code-collator/blob/main/CHANGELOG.md) for details. | ||
draft: false | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Default bump type | ||
DEFAULT_BUMP=${DEFAULT_BUMP:-minor} | ||
|
||
# Get the current version | ||
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0") | ||
|
||
# Split the version into parts | ||
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" | ||
MAJOR="${VERSION_PARTS[0]}" | ||
MINOR="${VERSION_PARTS[1]}" | ||
PATCH="${VERSION_PARTS[2]}" | ||
|
||
# Bump the version | ||
case $DEFAULT_BUMP in | ||
major) | ||
MAJOR=$((MAJOR + 1)) | ||
MINOR=0 | ||
PATCH=0 | ||
;; | ||
minor) | ||
MINOR=$((MINOR + 1)) | ||
PATCH=0 | ||
;; | ||
patch) | ||
PATCH=$((PATCH + 1)) | ||
;; | ||
*) | ||
echo "Unknown bump type: $DEFAULT_BUMP" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
NEW_VERSION="$MAJOR.$MINOR.$PATCH" | ||
|
||
# Create a new tag | ||
git tag "v$NEW_VERSION" | ||
git push origin "v$NEW_VERSION" |