From 6b705fa3a4a08c3b552237694be500ce07840082 Mon Sep 17 00:00:00 2001 From: ToMe25 <38815969+ToMe25@users.noreply.github.com> Date: Sat, 16 May 2020 18:30:49 +0200 Subject: [PATCH 1/7] Add tagging support --- README.md | 4 ++++ action.yml | 4 ++++ src/entrypoint.sh | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 265cc5c9..af6dc24b 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,10 @@ Add a step like this to your workflow: # Default: '' remove: "./dir/old_file.js" + # Name of the tag to add to the new commit. Use an empty string to disable tagging. + # Default: '' + tag: "v1.0.0" + env: # This is necessary in order to push a commit to the repo GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged diff --git a/action.yml b/action.yml index 32074c05..7242b96b 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,10 @@ inputs: description: Arguments for the git rm command required: false default: "" + tag: + description: The name of the tag to add to the new commit + required: false + default: "" runs: using: node12 diff --git a/src/entrypoint.sh b/src/entrypoint.sh index db6963f0..ab21a452 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -31,6 +31,10 @@ remove() { if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi } +tag() { + if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi +} + # This is needed to make the check work for untracked files echo "Staging files..." add @@ -68,6 +72,9 @@ if ! git diff --cached --quiet --exit-code; then echo "Creating commit..." git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" + echo "Tagging commit..." + tag + echo "Pushing to repo..." git push --set-upstream origin "$INPUT_REF" From c902408157e4e4bc8467688a780560201c226d01 Mon Sep 17 00:00:00 2001 From: ToMe25 <38815969+ToMe25@users.noreply.github.com> Date: Sat, 16 May 2020 19:16:43 +0200 Subject: [PATCH 2/7] Add missing push arg --- src/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index ab21a452..c44cd78b 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -76,7 +76,7 @@ if ! git diff --cached --quiet --exit-code; then tag echo "Pushing to repo..." - git push --set-upstream origin "$INPUT_REF" + git push --set-upstream origin --tags "$INPUT_REF" echo "::endgroup::" echo "Task completed." From f0a1d2598aecf23b2c6a32dd64a1aa1fb10fd7e9 Mon Sep 17 00:00:00 2001 From: ToMe25 <38815969+ToMe25@users.noreply.github.com> Date: Sat, 16 May 2020 17:17:36 +0000 Subject: [PATCH 3/7] [auto] Update compiled version --- lib/entrypoint.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh index db6963f0..c44cd78b 100755 --- a/lib/entrypoint.sh +++ b/lib/entrypoint.sh @@ -31,6 +31,10 @@ remove() { if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi } +tag() { + if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi +} + # This is needed to make the check work for untracked files echo "Staging files..." add @@ -68,8 +72,11 @@ if ! git diff --cached --quiet --exit-code; then echo "Creating commit..." git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" + echo "Tagging commit..." + tag + echo "Pushing to repo..." - git push --set-upstream origin "$INPUT_REF" + git push --set-upstream origin --tags "$INPUT_REF" echo "::endgroup::" echo "Task completed." From 83761c7e8ee766db3e870f1f0b7a54cccf2df89e Mon Sep 17 00:00:00 2001 From: ToMe25 <38815969+ToMe25@users.noreply.github.com> Date: Sat, 16 May 2020 19:44:48 +0200 Subject: [PATCH 4/7] Hopefully fix wrong commit getting tagged --- src/entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index c44cd78b..f327aea1 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -32,7 +32,10 @@ remove() { } tag() { - if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi + if [ -n "$INPUT_TAG" ]; then + git tag $INPUT_TAG + git push origin refs/tags/$INPUT_TAG + fi } # This is needed to make the check work for untracked files @@ -76,7 +79,7 @@ if ! git diff --cached --quiet --exit-code; then tag echo "Pushing to repo..." - git push --set-upstream origin --tags "$INPUT_REF" + git push --set-upstream origin "$INPUT_REF" echo "::endgroup::" echo "Task completed." From 46569f991f64ef990c4c9fa1022ad1adb62b9460 Mon Sep 17 00:00:00 2001 From: ToMe25 <38815969+ToMe25@users.noreply.github.com> Date: Sat, 16 May 2020 17:45:45 +0000 Subject: [PATCH 5/7] [auto] Update compiled version --- lib/entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh index c44cd78b..f327aea1 100755 --- a/lib/entrypoint.sh +++ b/lib/entrypoint.sh @@ -32,7 +32,10 @@ remove() { } tag() { - if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi + if [ -n "$INPUT_TAG" ]; then + git tag $INPUT_TAG + git push origin refs/tags/$INPUT_TAG + fi } # This is needed to make the check work for untracked files @@ -76,7 +79,7 @@ if ! git diff --cached --quiet --exit-code; then tag echo "Pushing to repo..." - git push --set-upstream origin --tags "$INPUT_REF" + git push --set-upstream origin "$INPUT_REF" echo "::endgroup::" echo "Task completed." From d4aeb9335d162b453af99680d81436de9e18e32e Mon Sep 17 00:00:00 2001 From: ToMe25 <38815969+ToMe25@users.noreply.github.com> Date: Sat, 16 May 2020 19:53:34 +0200 Subject: [PATCH 6/7] Hopefully this time fix which commit gets tagged --- src/entrypoint.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index f327aea1..5295b147 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -32,10 +32,7 @@ remove() { } tag() { - if [ -n "$INPUT_TAG" ]; then - git tag $INPUT_TAG - git push origin refs/tags/$INPUT_TAG - fi + if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi } # This is needed to make the check work for untracked files @@ -79,7 +76,7 @@ if ! git diff --cached --quiet --exit-code; then tag echo "Pushing to repo..." - git push --set-upstream origin "$INPUT_REF" + git push --set-upstream origin "$INPUT_REF" --tags echo "::endgroup::" echo "Task completed." From 22cdfa345a327a5ac1c0dc6e6c3aa329748e1def Mon Sep 17 00:00:00 2001 From: ToMe25 <38815969+ToMe25@users.noreply.github.com> Date: Sat, 16 May 2020 17:54:55 +0000 Subject: [PATCH 7/7] [auto] Update compiled version --- lib/entrypoint.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh index f327aea1..5295b147 100755 --- a/lib/entrypoint.sh +++ b/lib/entrypoint.sh @@ -32,10 +32,7 @@ remove() { } tag() { - if [ -n "$INPUT_TAG" ]; then - git tag $INPUT_TAG - git push origin refs/tags/$INPUT_TAG - fi + if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi } # This is needed to make the check work for untracked files @@ -79,7 +76,7 @@ if ! git diff --cached --quiet --exit-code; then tag echo "Pushing to repo..." - git push --set-upstream origin "$INPUT_REF" + git push --set-upstream origin "$INPUT_REF" --tags echo "::endgroup::" echo "Task completed."