From d4a53f1779c17cd626c3df64a6aa6abf37abe6d9 Mon Sep 17 00:00:00 2001
From: Stefan Zweifel <hello@stefanzweifel.io>
Date: Thu, 5 Mar 2020 20:28:38 +0100
Subject: [PATCH 1/5] Push Tags to Remote Repository

---
 entrypoint.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index 45c4d13..d85c1c0 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -62,9 +62,9 @@ _local_commit() {
 _push_to_github() {
     if [ -z "$INPUT_BRANCH" ]
     then
-        git push origin
+        git push origin --tags
     else
-        git push --set-upstream origin "HEAD:$INPUT_BRANCH"
+        git push --set-upstream origin "HEAD:$INPUT_BRANCH" --tags
     fi
 }
 

From 3387b2f267bf1c15997eb84adfb1c18c4db1092c Mon Sep 17 00:00:00 2001
From: Stefan Zweifel <hello@stefanzweifel.io>
Date: Thu, 5 Mar 2020 20:31:06 +0100
Subject: [PATCH 2/5] Add tagging_message input option

---
 README.md     |  3 +++
 action.yml    |  4 ++++
 entrypoint.sh | 11 +++++++++++
 3 files changed, 18 insertions(+)

diff --git a/README.md b/README.md
index e6cbc07..958ea0f 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,9 @@ Add the following step at the end of your job.
     commit_user_name: My GitHub Actions Bot
     commit_user_email: my-github-actions-bot@example.org
     commit_author: Author <actions@gitub.com>
+
+    # Optional. If value is set, the commit will be tagged with the given value
+    tagging_message: 'v1.0.0'
 ```
 
 The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!
diff --git a/action.yml b/action.yml
index 477de4f..fd60cb1 100644
--- a/action.yml
+++ b/action.yml
@@ -34,6 +34,10 @@ inputs:
     description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
     required: false
     default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
+  tagging_message:
+    description: Value used for a git tag. Keep it empty to not tag the commit.
+    required: false
+    default: ''
 
 outputs:
   changes_detected:
diff --git a/entrypoint.sh b/entrypoint.sh
index d85c1c0..b197bbc 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -17,6 +17,8 @@ _main() {
 
         _local_commit
 
+        _tag_commit
+
         _push_to_github
     else
 
@@ -59,6 +61,15 @@ _local_commit() {
     git commit -m "$INPUT_COMMIT_MESSAGE" --author="$INPUT_COMMIT_AUTHOR" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
 }
 
+_tag_commit() {
+    if [ -z "$INPUT_TAGGING_MESSAGE" ]
+    then
+        # No tag name given. Do nothing.
+    else
+        git tag -a "$INPUT_TAGGING_MESSAGE" -m "$INPUT_TAGGING_MESSAGE"
+    fi
+}
+
 _push_to_github() {
     if [ -z "$INPUT_BRANCH" ]
     then

From 0ad4c8ce73dbc2e59d0f4c5ca4790497f78226de Mon Sep 17 00:00:00 2001
From: Stefan Zweifel <hello@stefanzweifel.io>
Date: Thu, 5 Mar 2020 20:35:32 +0100
Subject: [PATCH 3/5] Fix _tag_commit

---
 entrypoint.sh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index b197bbc..32b9c4e 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -62,10 +62,8 @@ _local_commit() {
 }
 
 _tag_commit() {
-    if [ -z "$INPUT_TAGGING_MESSAGE" ]
+    if [ -n "$INPUT_TAGGING_MESSAGE" ]
     then
-        # No tag name given. Do nothing.
-    else
         git tag -a "$INPUT_TAGGING_MESSAGE" -m "$INPUT_TAGGING_MESSAGE"
     fi
 }

From ce08dda6b3307026af6af56601ab0c57aa3372e6 Mon Sep 17 00:00:00 2001
From: Stefan Zweifel <hello@stefanzweifel.io>
Date: Thu, 5 Mar 2020 20:48:00 +0100
Subject: [PATCH 4/5] Update Wording

---
 README.md  | 2 +-
 action.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 958ea0f..d49972f 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ Add the following step at the end of your job.
     commit_user_email: my-github-actions-bot@example.org
     commit_author: Author <actions@gitub.com>
 
-    # Optional. If value is set, the commit will be tagged with the given value
+    # Optional tag message. Will create and push a new tag to the remote repository
     tagging_message: 'v1.0.0'
 ```
 
diff --git a/action.yml b/action.yml
index fd60cb1..2ca3947 100644
--- a/action.yml
+++ b/action.yml
@@ -35,7 +35,7 @@ inputs:
     required: false
     default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
   tagging_message:
-    description: Value used for a git tag. Keep it empty to not tag the commit.
+    description: Message used to create a new git tag with the commit. Keep this empty, if no tag should be created.
     required: false
     default: ''
 

From 844c808726a7f2afaf7bd06f65e0c06e1e6aa393 Mon Sep 17 00:00:00 2001
From: Stefan Zweifel <hello@stefanzweifel.io>
Date: Thu, 5 Mar 2020 20:48:15 +0100
Subject: [PATCH 5/5] Echo out the tagging message

---
 entrypoint.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/entrypoint.sh b/entrypoint.sh
index 32b9c4e..8372817 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -62,6 +62,8 @@ _local_commit() {
 }
 
 _tag_commit() {
+    echo "INPUT_TAGGING_MESSAGE: ${INPUT_TAGGING_MESSAGE}"
+
     if [ -n "$INPUT_TAGGING_MESSAGE" ]
     then
         git tag -a "$INPUT_TAGGING_MESSAGE" -m "$INPUT_TAGGING_MESSAGE"