From 8a23be4b32ffb90ffb63e74b5063134bced62d01 Mon Sep 17 00:00:00 2001 From: Ross Smith II Date: Thu, 13 Mar 2025 08:29:02 -0700 Subject: [PATCH 01/11] docs: Update README.md per #354 See #354 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e49f1f..f2c909e 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ The following is an extended example with all available options. # Optional commit user and author settings commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]" commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com" - commit_author: Author # defaults to "username ", where "username" belongs to the author of the commit that triggered the run + commit_author: Author # defaults to "username ", where "numeric_id" and "username" belong to the author of the commit that triggered the run # Optional. Tag name being created in the local repository and # pushed to remote repository and defined branch. From 4db797a96155206d562625b4ad7a08dca23f1bf4 Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:01:31 +0200 Subject: [PATCH 02/11] Update entrypoint.sh --- entrypoint.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index bff98e0..03931e7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,8 +30,12 @@ _main() { _check_if_git_is_available _switch_to_repository - - if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then + if _git_tag_only; then + _log "debug" "git tag only."; + _set_github_output "git_tag_only" "true" + _tag_commit + _push_to_github + elif _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then _set_github_output "changes_detected" "true" From 2ac10431a86a5b997e9573eb6c9651f2382a437a Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:02:49 +0200 Subject: [PATCH 03/11] Update action.yml --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index fe8bfb3..2b8ea38 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,10 @@ description: 'Automatically commits files which have been changed during the wor author: Stefan Zweifel inputs: + git_tag_only: + description: Perform a clean git tag and push, without commiting anything + required: false + default: false commit_message: description: Commit message required: false From 12e100dacb907a92e0dc82346eaf871f83e7847a Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:05:01 +0200 Subject: [PATCH 04/11] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 03931e7..ee26146 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,7 +30,7 @@ _main() { _check_if_git_is_available _switch_to_repository - if _git_tag_only; then + if "$INPUT_GIT_TAG_ONLY"; then _log "debug" "git tag only."; _set_github_output "git_tag_only" "true" _tag_commit From 19379b46c9475e7b57e9a487de999197e859098a Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:05:21 +0200 Subject: [PATCH 05/11] Update git-auto-commit.bats --- tests/git-auto-commit.bats | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index d08597c..43e2c14 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -21,6 +21,7 @@ setup() { export FAKE_DEFAULT_BRANCH=$(git config init.defaultBranch) # Set default INPUT variables used by the GitHub Action + export INPUT_GIT_TAG_ONLY=true export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}" export INPUT_COMMIT_MESSAGE="Commit Message" export INPUT_BRANCH="${FAKE_DEFAULT_BRANCH}" From cfd6ac4a3bab2e8adaa26e0374379af334adfc43 Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:14:41 +0200 Subject: [PATCH 06/11] Update git-auto-commit.bats --- tests/git-auto-commit.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index 43e2c14..26f6de3 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -21,7 +21,7 @@ setup() { export FAKE_DEFAULT_BRANCH=$(git config init.defaultBranch) # Set default INPUT variables used by the GitHub Action - export INPUT_GIT_TAG_ONLY=true + export INPUT_GIT_TAG_ONLY=false export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}" export INPUT_COMMIT_MESSAGE="Commit Message" export INPUT_BRANCH="${FAKE_DEFAULT_BRANCH}" From 35d037abf5810698ff3d047321be58dda3323986 Mon Sep 17 00:00:00 2001 From: Lior Dux Date: Sun, 23 Mar 2025 22:33:45 +0200 Subject: [PATCH 07/11] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index f2c909e..5eef900 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,10 @@ The following is an extended example with all available options. ```yaml - uses: stefanzweifel/git-auto-commit-action@v5 with: + # Perform a clean git tag and push, without commiting anything + # Default to false + git_tag_only: false + # Optional. Commit message for the created commit. # Defaults to "Apply automatic changes" commit_message: Automated Change From 4f8f3ad16ec3c524651ccc9ca4eb5f40cec44525 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 19 Apr 2025 09:38:21 +0200 Subject: [PATCH 08/11] Rename Input and add output --- README.md | 8 ++++---- action.yml | 10 ++++++---- entrypoint.sh | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5eef900..60071bb 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,6 @@ The following is an extended example with all available options. ```yaml - uses: stefanzweifel/git-auto-commit-action@v5 with: - # Perform a clean git tag and push, without commiting anything - # Default to false - git_tag_only: false - # Optional. Commit message for the created commit. # Defaults to "Apply automatic changes" commit_message: Automated Change @@ -122,6 +118,10 @@ The following is an extended example with all available options. # Optional. Create given branch name in local and remote repository. create_branch: true + + # Perform a clean git tag and push, without commiting anything + # Default to false + create_git_tag_only: false ``` Please note that the Action depends on `bash`. If you're using the Action in a job in combination with a custom Docker container, make sure that `bash` is installed. diff --git a/action.yml b/action.yml index 2b8ea38..caf8237 100644 --- a/action.yml +++ b/action.yml @@ -4,10 +4,6 @@ description: 'Automatically commits files which have been changed during the wor author: Stefan Zweifel inputs: - git_tag_only: - description: Perform a clean git tag and push, without commiting anything - required: false - default: false commit_message: description: Commit message required: false @@ -74,6 +70,10 @@ inputs: create_branch: description: Create new branch with the name of `branch`-input in local and remote repository, if it doesn't exist yet. default: false + create_git_tag_only: + description: Perform a clean git tag and push, without commiting anything + required: false + default: false internal_git_binary: description: Internal use only! Path to git binary used to check if git is available. (Don't change this!) default: git @@ -83,6 +83,8 @@ outputs: description: Value is "true", if the repository was dirty and file changes have been detected. Value is "false", if no changes have been detected. commit_hash: description: Full hash of the created commit. Only present if the "changes_detected" output is "true". + create_git_tag_only: + description: runs: using: 'node20' diff --git a/entrypoint.sh b/entrypoint.sh index ee26146..22098df 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,9 +30,9 @@ _main() { _check_if_git_is_available _switch_to_repository - if "$INPUT_GIT_TAG_ONLY"; then - _log "debug" "git tag only."; - _set_github_output "git_tag_only" "true" + if "$INPUT_CREATE_GIT_TAG_ONLY"; then + _log "debug" "Create git tag only"; + _set_github_output "create_git_tag_only" "true" _tag_commit _push_to_github elif _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then From 8480c68cbb7b1813d49aecb1164b935d6a72b726 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 19 Apr 2025 10:17:54 +0200 Subject: [PATCH 09/11] Add Tests --- tests/git-auto-commit.bats | 53 +++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index 26f6de3..f1fb4b8 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -21,7 +21,7 @@ setup() { export FAKE_DEFAULT_BRANCH=$(git config init.defaultBranch) # Set default INPUT variables used by the GitHub Action - export INPUT_GIT_TAG_ONLY=false + export INPUT_CREATE_GIT_TAG_ONLY=false export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}" export INPUT_COMMIT_MESSAGE="Commit Message" export INPUT_BRANCH="${FAKE_DEFAULT_BRANCH}" @@ -1126,3 +1126,54 @@ END assert_failure; assert_line "::error::git-status failed with:" } + +@test "it creates a tag if create_git_tag_only is set to true and a message has been supplied" { + INPUT_CREATE_GIT_TAG_ONLY=true + INPUT_TAGGING_MESSAGE=v1.0.0 + + run git_auto_commit + + assert_success + + assert_line "::debug::Create git tag only" + + assert_line "::debug::Create tag v1.0.0" + refute_line "No tagging message supplied. No tag will be added." + + assert_line "::debug::Apply push options " + assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}" + + run cat_github_output + assert_line "create_git_tag_only=true" + refute_line "changes_detected=false" + refute_line -e "commit_hash=[0-9a-f]{40}$" + + # Assert a tag v1.0.0 has been created + run git tag + assert_output v1.0.0 + + run git ls-remote --tags --refs + assert_output --partial refs/tags/v1.0.0 +} + +@test "it output no tagging message supplied if no tagging message is set but create_git_tag_only is set to true" { + INPUT_CREATE_GIT_TAG_ONLY=true + INPUT_TAGGING_MESSAGE="" + + run git_auto_commit + + assert_success + + assert_line "INPUT_TAGGING_MESSAGE: " + assert_line "No tagging message supplied. No tag will be added." + assert_line "::debug::Create git tag only" + + run cat_github_output + assert_line "create_git_tag_only=true" + refute_line "changes_detected=false" + refute_line -e "commit_hash=[0-9a-f]{40}$" + + # Assert no tag has been created + run git tag + assert_output "" +} From adb37b5a29cc6a129145d9d032185cb98f85158c Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 19 Apr 2025 10:32:21 +0200 Subject: [PATCH 10/11] Update README --- README.md | 5 +++-- action.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 60071bb..4e9b319 100644 --- a/README.md +++ b/README.md @@ -119,8 +119,8 @@ The following is an extended example with all available options. # Optional. Create given branch name in local and remote repository. create_branch: true - # Perform a clean git tag and push, without commiting anything - # Default to false + # Optional. Creates a new tag and pushes it to remote without creating a commit. + # Skips dirty check and changed files. Must be used with `tagging_message`. create_git_tag_only: false ``` @@ -173,6 +173,7 @@ You can use these outputs to trigger other Actions in your Workflow run based on - `changes_detected`: Returns either "true" or "false" if the repository was dirty and files have changed. - `commit_hash`: Returns the full hash of the commit if one was created. +- `create_git_tag_only`: Returns either "true" or "false" if a tag was created, when `create_git_tag_only` was used. **⚠️ When using outputs, the step needs to be given an id. See example below.** diff --git a/action.yml b/action.yml index caf8237..c57a508 100644 --- a/action.yml +++ b/action.yml @@ -84,7 +84,7 @@ outputs: commit_hash: description: Full hash of the created commit. Only present if the "changes_detected" output is "true". create_git_tag_only: - description: + description: Value is "true", if a git tag was created using the `create_git_tag_only`-input. runs: using: 'node20' From af302a9c635adb759442b1ffd153700cc7729cc4 Mon Sep 17 00:00:00 2001 From: stefanzweifel <1080923+stefanzweifel@users.noreply.github.com> Date: Sat, 19 Apr 2025 08:40:01 +0000 Subject: [PATCH 11/11] Update CHANGELOG --- CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb8f436..cb4de23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.1.0...HEAD) +## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.2.0...HEAD) > TBD +## [v5.2.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.1.0...v5.2.0) - 2025-04-19 + +### Added + +- Add `create_git_tag_only` option to skip commiting and always create a git-tag. ([#364](https://github.com/stefanzweifel/git-auto-commit-action/pull/364)) [@zMynxx](https://github.com/@zMynxx) +- Add Test for `create_git_tag_only` feature ([#367](https://github.com/stefanzweifel/git-auto-commit-action/pull/367)) [@stefanzweifel](https://github.com/@stefanzweifel) + +### Fixed + +- docs: Update README.md per #354 ([#361](https://github.com/stefanzweifel/git-auto-commit-action/pull/361)) [@rasa](https://github.com/@rasa) + ## [v5.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.1...v5.1.0) - 2025-01-11 ### Changed