Skip to content

Commit 739fd03

Browse files
committed
Merge branch 'master' into v6-next
2 parents ed295bd + af302a9 commit 739fd03

File tree

5 files changed

+82
-3
lines changed

5 files changed

+82
-3
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.1.0...HEAD)
8+
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.2.0...HEAD)
99

1010
> TBD
1111
12+
## [v5.2.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.1.0...v5.2.0) - 2025-04-19
13+
14+
### Added
15+
16+
- 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)
17+
- Add Test for `create_git_tag_only` feature ([#367](https://github.com/stefanzweifel/git-auto-commit-action/pull/367)) [@stefanzweifel](https://github.com/@stefanzweifel)
18+
19+
### Fixed
20+
21+
- docs: Update README.md per #354 ([#361](https://github.com/stefanzweifel/git-auto-commit-action/pull/361)) [@rasa](https://github.com/@rasa)
22+
1223
## [v5.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.1...v5.1.0) - 2025-01-11
1324

1425
### Changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ The following is an extended example with all available options.
8484
# Optional commit user and author settings
8585
commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]"
8686
commit_user_email: [email protected] # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
87-
commit_author: Author <[email protected]> # defaults to "username <[email protected]>", where "username" belongs to the author of the commit that triggered the run
87+
commit_author: Author <[email protected]> # defaults to "username <numeric_id+[email protected]>", where "numeric_id" and "username" belong to the author of the commit that triggered the run
8888

8989
# Optional. Tag name being created in the local repository and
9090
# pushed to remote repository and defined branch.
@@ -108,6 +108,10 @@ The following is an extended example with all available options.
108108
# Optional. Prevents the shell from expanding filenames.
109109
# Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
110110
disable_globbing: true
111+
112+
# Optional. Creates a new tag and pushes it to remote without creating a commit.
113+
# Skips dirty check and changed files. Must be used with `tagging_message`.
114+
create_git_tag_only: false
111115
```
112116
113117
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.
@@ -159,6 +163,7 @@ You can use these outputs to trigger other Actions in your Workflow run based on
159163

160164
- `changes_detected`: Returns either "true" or "false" if the repository was dirty and files have changed.
161165
- `commit_hash`: Returns the full hash of the commit if one was created.
166+
- `create_git_tag_only`: Returns either "true" or "false" if a tag was created, when `create_git_tag_only` was used.
162167

163168
**⚠️ When using outputs, the step needs to be given an id. See example below.**
164169

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ inputs:
5959
disable_globbing:
6060
description: Stop the shell from expanding filenames (https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html)
6161
default: false
62+
create_git_tag_only:
63+
description: Perform a clean git tag and push, without commiting anything
64+
required: false
65+
default: false
6266
internal_git_binary:
6367
description: Internal use only! Path to git binary used to check if git is available. (Don't change this!)
6468
default: git
@@ -68,6 +72,8 @@ outputs:
6872
description: Value is "true", if the repository was dirty and file changes have been detected. Value is "false", if no changes have been detected.
6973
commit_hash:
7074
description: Full hash of the created commit. Only present if the "changes_detected" output is "true".
75+
create_git_tag_only:
76+
description: Value is "true", if a git tag was created using the `create_git_tag_only`-input.
7177

7278
runs:
7379
using: 'node20'

entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ _main() {
3535

3636
_check_if_repository_is_in_detached_state
3737

38-
if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
38+
if "$INPUT_CREATE_GIT_TAG_ONLY"; then
39+
_log "debug" "Create git tag only";
40+
_set_github_output "create_git_tag_only" "true"
41+
_tag_commit
42+
_push_to_github
43+
elif _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
3944

4045
_set_github_output "changes_detected" "true"
4146

tests/git-auto-commit.bats

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ setup() {
2121
export FAKE_DEFAULT_BRANCH=$(git config init.defaultBranch)
2222

2323
# Set default INPUT variables used by the GitHub Action
24+
export INPUT_CREATE_GIT_TAG_ONLY=false
2425
export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}"
2526
export INPUT_COMMIT_MESSAGE="Commit Message"
2627
export INPUT_BRANCH="${FAKE_DEFAULT_BRANCH}"
@@ -1109,3 +1110,54 @@ END
11091110
assert_failure;
11101111
assert_line "::error::Repository is in detached HEAD state. Please make sure you check out a branch. Adjust the `ref` input accordingly."
11111112
}
1113+
1114+
@test "it creates a tag if create_git_tag_only is set to true and a message has been supplied" {
1115+
INPUT_CREATE_GIT_TAG_ONLY=true
1116+
INPUT_TAGGING_MESSAGE=v1.0.0
1117+
1118+
run git_auto_commit
1119+
1120+
assert_success
1121+
1122+
assert_line "::debug::Create git tag only"
1123+
1124+
assert_line "::debug::Create tag v1.0.0"
1125+
refute_line "No tagging message supplied. No tag will be added."
1126+
1127+
assert_line "::debug::Apply push options "
1128+
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
1129+
1130+
run cat_github_output
1131+
assert_line "create_git_tag_only=true"
1132+
refute_line "changes_detected=false"
1133+
refute_line -e "commit_hash=[0-9a-f]{40}$"
1134+
1135+
# Assert a tag v1.0.0 has been created
1136+
run git tag
1137+
assert_output v1.0.0
1138+
1139+
run git ls-remote --tags --refs
1140+
assert_output --partial refs/tags/v1.0.0
1141+
}
1142+
1143+
@test "it output no tagging message supplied if no tagging message is set but create_git_tag_only is set to true" {
1144+
INPUT_CREATE_GIT_TAG_ONLY=true
1145+
INPUT_TAGGING_MESSAGE=""
1146+
1147+
run git_auto_commit
1148+
1149+
assert_success
1150+
1151+
assert_line "INPUT_TAGGING_MESSAGE: "
1152+
assert_line "No tagging message supplied. No tag will be added."
1153+
assert_line "::debug::Create git tag only"
1154+
1155+
run cat_github_output
1156+
assert_line "create_git_tag_only=true"
1157+
refute_line "changes_detected=false"
1158+
refute_line -e "commit_hash=[0-9a-f]{40}$"
1159+
1160+
# Assert no tag has been created
1161+
run git tag
1162+
assert_output ""
1163+
}

0 commit comments

Comments
 (0)