From 31e882116ddd72adbcc8272ea5ecfe5d708ac266 Mon Sep 17 00:00:00 2001 From: Reece Como Date: Fri, 20 Sep 2019 14:44:45 +0800 Subject: [PATCH 1/6] Skip version bump if commit already tagged --- entrypoint.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 78f86482..59604df1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,26 +1,36 @@ #!/bin/bash +# config +default_semvar_bump=${DEFAULT_BUMP:-minor} + # get latest tag -t=$(git describe --tags `git rev-list --tags --max-count=1`) +tag=$(git describe --tags `git rev-list --tags --max-count=1`) +tag_commit=commit=$(git rev-list -n 1 $tagag) # get current commit hash for tag commit=$(git rev-parse HEAD) +if [ "$tag_commit" == "$commit" ]; then + echo "No new commits since previous tag. Skipping..." + exit 0 +fi + # if there are none, start tags at 0.0.0 -if [ -z "$t" ] +if [ -z "$tag" ] then log=$(git log --pretty=oneline) - t=0.0.0 + tag=0.0.0 else - log=$(git log $t..HEAD --pretty=oneline) + log=$(git log $tag..HEAD --pretty=oneline) fi # get commit logs and determine home to bump the version # supports #major, #minor, #patch (anything else will be 'minor') case "$log" in - *#major* ) new=$(semver bump major $t);; - *#patch* ) new=$(semver bump patch $t);; - * ) new=$(semver bump minor $t);; + *#major* ) new=$(semver bump major $tag);; + *#minor* ) new=$(semver bump minor $tag);; + *#patch* ) new=$(semver bump patch $tag);; + * ) new=$(semver bump `$default_semvar_bump` $tag);; esac echo $new From 854782fd7ebcf7f19945ed327bf2dd9ec774b38f Mon Sep 17 00:00:00 2001 From: Reece Como Date: Sat, 21 Sep 2019 14:46:22 +0800 Subject: [PATCH 2/6] Fix typos on tag_commit line --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 59604df1..43f15a11 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,7 +5,7 @@ default_semvar_bump=${DEFAULT_BUMP:-minor} # get latest tag tag=$(git describe --tags `git rev-list --tags --max-count=1`) -tag_commit=commit=$(git rev-list -n 1 $tagag) +tag_commit=$(git rev-list -n 1 $tag) # get current commit hash for tag commit=$(git rev-parse HEAD) From 4d8caca80c0d3e48d4a2d55df84280af9f63c67f Mon Sep 17 00:00:00 2001 From: Reece Como Date: Sat, 21 Sep 2019 14:53:53 +0800 Subject: [PATCH 3/6] Update README.md --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0d388380..0f03b46b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # github-tag-action -A Github Action to automatically bump and tag master, on merge, with the latest semver formatted version. +A Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. [![Build Status](https://github.com/anothrNick/github-tag-action/workflows/Bump%20version/badge.svg)](https://github.com/anothrNick/github-tag-action/workflows/Bump%20version/badge.svg) [![Stable Version](https://img.shields.io/github/v/tag/anothrNick/github-tag-action)](https://img.shields.io/github/v/tag/anothrNick/github-tag-action) @@ -30,13 +30,17 @@ jobs: REPO_OWNER: anothrNick ``` -Be sure to set the *REPO_OWNER* environment variable so that the action tags your repo. +#### Options + +* **REPO_OWNER** ***(required)*** - Required so the action knows which repo to tag. +* **GITHUB_TOKEN** ***(required)*** - Required for permission permissions. +* **DEFAULT_BUMP** *(optional)* - (default: `minor`) Which type of SemVar bump to use if none provided. *NOTE:* This creates a [lightweight tag](https://developer.github.com/v3/git/refs/#create-a-reference) ### Bumping -Any commit message with `#major`, `#minor`, or `patch` will trigger the respective version bump. +Any commit message with `#major`, `#minor`, or `#patch` will trigger the respective version bump. If two or more are present, the biggest one will take preference. ### Workflow From 1be67823e973d704bd359864e17c807fd7b79621 Mon Sep 17 00:00:00 2001 From: Reece Como Date: Sat, 21 Sep 2019 14:59:09 +0800 Subject: [PATCH 4/6] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0f03b46b..ffbc0b99 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ jobs: #### Options -* **REPO_OWNER** ***(required)*** - Required so the action knows which repo to tag. -* **GITHUB_TOKEN** ***(required)*** - Required for permission permissions. -* **DEFAULT_BUMP** *(optional)* - (default: `minor`) Which type of SemVar bump to use if none provided. +* **GITHUB_TOKEN** ***(required)*** - Required for permission to tag the repo. +* **REPO_OWNER** ***(required)*** - Required to target the repo to tag. +* **DEFAULT_BUMP** *(optional)* - Which type of bump to use when none explicitly provided (default: `minor`). *NOTE:* This creates a [lightweight tag](https://developer.github.com/v3/git/refs/#create-a-reference) @@ -42,6 +42,8 @@ jobs: Any commit message with `#major`, `#minor`, or `#patch` will trigger the respective version bump. If two or more are present, the biggest one will take preference. +This **will not** attempt to tag a commit that has already has a tag. + ### Workflow * Add this action to your repo From a7a940fb40b54dcdd99b94c78a6243777aff656f Mon Sep 17 00:00:00 2001 From: Reece Como Date: Sat, 21 Sep 2019 15:09:05 +0800 Subject: [PATCH 5/6] Update README.md --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ffbc0b99..88f86601 100644 --- a/README.md +++ b/README.md @@ -36,20 +36,22 @@ jobs: * **REPO_OWNER** ***(required)*** - Required to target the repo to tag. * **DEFAULT_BUMP** *(optional)* - Which type of bump to use when none explicitly provided (default: `minor`). -*NOTE:* This creates a [lightweight tag](https://developer.github.com/v3/git/refs/#create-a-reference) +> ***Note:*** This action creates a [lightweight tag](https://developer.github.com/v3/git/refs/#create-a-reference). ### Bumping -Any commit message with `#major`, `#minor`, or `#patch` will trigger the respective version bump. If two or more are present, the biggest one will take preference. +**Manual Bumping:** Any commit message that includes `#major`, `#minor`, or `#patch` will trigger the respective version bump. If two or more are present, the highest-ranking one will take precedence. -This **will not** attempt to tag a commit that has already has a tag. +**Automatic Bumping:** If no `#major`, `#minor` or `#patch` tag is contained in the commit messages, it will bump whichever `DEFAULT_BUMP` is set to (which is `minor` by default). + +> ***Note:*** This action **will not** bump the tag if the `HEAD` commit has already been tagged. ### Workflow * Add this action to your repo * Commit some changes * Either push to master or open a PR -* On push(or merge) to master, Action will: +* On push (or merge) to `master`, the action will: * Get latest tag * Bump tag with minor version unless any commit message contains `#major` or `#patch` * Pushes tag to github From 7a2ab9e1d6a23b488b94b0fdc2063e77dce5d38b Mon Sep 17 00:00:00 2001 From: Reece Como Date: Mon, 23 Sep 2019 16:04:51 +0800 Subject: [PATCH 6/6] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 43f15a11..f067277a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,7 +30,7 @@ case "$log" in *#major* ) new=$(semver bump major $tag);; *#minor* ) new=$(semver bump minor $tag);; *#patch* ) new=$(semver bump patch $tag);; - * ) new=$(semver bump `$default_semvar_bump` $tag);; + * ) new=$(semver bump `echo $default_semvar_bump` $tag);; esac echo $new