Skip to content

Commit 8cd30fb

Browse files
committed
Add flags -s and -u for signed tags
1 parent a6a1754 commit 8cd30fb

File tree

5 files changed

+63
-4
lines changed

5 files changed

+63
-4
lines changed

bin/git-release

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ if test $# -gt 0; then
3434
-c) need_changelog=true;;
3535
-r) remote=$2; shift ;;
3636
-m) msg=$2; shift ;;
37+
-s)
38+
test -n "$keyid" &&
39+
exit_with_msg "Please use '-s' OR '-u'"
40+
sign=true
41+
;;
42+
-u)
43+
test -n "$sign" &&
44+
exit_with_msg "Please use '-s' OR '-u'"
45+
keyid=$2
46+
shift
47+
;;
3748
--semver)
3849
test -z "$2" &&
3950
exit_with_msg "major/minor/patch required for --semver option"
@@ -101,8 +112,17 @@ if test $# -gt 0; then
101112
git commit -a -m "$msg" --allow-empty
102113
fi
103114

115+
declare -a sign_args
116+
if [ "$sign" == true ]; then
117+
sign_args=("-s")
118+
fi
119+
120+
if [ -n "$keyid" ]; then
121+
sign_args=("-u" "$keyid")
122+
fi
123+
104124
# shellcheck disable=SC2086
105-
git tag $version -a -m "$msg" \
125+
git tag "${sign_args[@]}" $version -a -m "$msg" \
106126
&& git push $remote --tags \
107127
&& git push $remote \
108128
&& hook post-release $hook_args \

etc/git-extras-completion.zsh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,17 @@ _git-summary() {
429429
__gitex_commits
430430
}
431431

432+
_git-release() {
433+
_arguments -C \
434+
'-c[Generates/populates the changelog with all commit message since the last tag.]'
435+
'-r[The "remote" repository that is destination of a push operation.]'
436+
'-m[use the custom commit information instead of the default message.]'
437+
'-s[Create a signed and annotated tag.]'
438+
'-u[Create a tag, annotated and signed with the given key.]'
439+
'--semver[If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag.]'
440+
'--no-empty-commit[Avoid creating empty commit if nothing could be committed.]'
441+
'--[The arguments listed after "--" separator will be passed to pre/post-release hook.]'
442+
}
432443

433444
_git-undo(){
434445
_arguments -C \

man/git-release.1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
\fBgit\-release\fR \- Commit, tag and push changes to the repository
88
.
99
.SH "SYNOPSIS"
10-
\fBgit\-release\fR [<tagname> | \-\-semver <name>] [\-r <remote>] [\-m <commit info>] [\-\-no\-empty\-commit] [\-c] [[\-\-] <hook arguments\.\.\.>]
10+
\fBgit\-release\fR [<tagname> | \-\-semver <name>] [\-r <remote>] [\-m <commit info>] [\-\-no\-empty\-commit] [\-c] [\-s] [\-u <key-id>] [[\-\-] <hook arguments\.\.\.>]
1111
.
1212
.SH "DESCRIPTION"
1313
Commits changes with message "Release <tagname>" or custom commit information, tags with the given <tagname> and pushes the branch / tags\.
@@ -58,6 +58,18 @@ Avoid creating empty commit if nothing could be committed\.
5858
Generates or populates the changelog with all commit message since the last tag\. For more info see git\-changelog\.\.
5959
.
6060
.P
61+
\-s
62+
.
63+
.P
64+
Create a signed and annotated tag\.
65+
.
66+
.P
67+
\-u <key ID>
68+
.
69+
.P
70+
Create a tag, annotated and signed with the given key\.
71+
.
72+
.P
6173
[\-\-] hook arguments\.\.\.
6274
.
6375
.P

man/git-release.html

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git-release.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ git-release(1) -- Commit, tag and push changes to the repository
33

44
## SYNOPSIS
55

6-
`git-release` [&lt;tagname&gt; | --semver &lt;name&gt;] [-r &lt;remote&gt;] [-m &lt;commit info&gt;] [--no-empty-commit] [-c] [[--] &lt;hook arguments...&gt;]
6+
`git-release` [&lt;tagname&gt; | --semver &lt;name&gt;] [-r &lt;remote&gt;] [-m &lt;commit info&gt;] [--no-empty-commit] [-c] [-s] [-u &lt;key-id&gt;] [[--] &lt;hook arguments...&gt;]
77

88
## DESCRIPTION
99

@@ -43,6 +43,14 @@ git-release(1) -- Commit, tag and push changes to the repository
4343

4444
Generates or populates the changelog with all commit message since the last tag. For more info see git-changelog..
4545

46+
-s
47+
48+
Create a signed and annotated tag.
49+
50+
-u &lt;key-id&gt;
51+
52+
Create a tag, annotated and signed with the given key.
53+
4654
[--] hook arguments...
4755

4856
The arguments listed after "--" separator will be passed to pre/post-release hook following the `tagname`.

0 commit comments

Comments
 (0)