diff --git a/bin/git-release b/bin/git-release index a2abb71..194876e 100755 --- a/bin/git-release +++ b/bin/git-release @@ -34,6 +34,17 @@ if test $# -gt 0; then -c) need_changelog=true;; -r) remote=$2; shift ;; -m) msg=$2; shift ;; + -s) + test -n "$keyid" && + exit_with_msg "Please use '-s' OR '-u'" + sign=true + ;; + -u) + test -n "$sign" && + exit_with_msg "Please use '-s' OR '-u'" + keyid=$2 + shift + ;; --semver) test -z "$2" && exit_with_msg "major/minor/patch required for --semver option" @@ -101,8 +112,17 @@ if test $# -gt 0; then git commit -a -m "$msg" --allow-empty fi + declare -a sign_args + if [ "$sign" == true ]; then + sign_args=("-s") + fi + + if [ -n "$keyid" ]; then + sign_args=("-u" "$keyid") + fi + # shellcheck disable=SC2086 - git tag $version -a -m "$msg" \ + git tag "${sign_args[@]}" $version -a -m "$msg" \ && git push $remote --tags \ && git push $remote \ && hook post-release $hook_args \ diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index d6c8d1e..f115f47 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -429,6 +429,17 @@ _git-summary() { __gitex_commits } +_git-release() { + _arguments -C \ + '-c[Generates/populates the changelog with all commit message since the last tag.]' + '-r[The "remote" repository that is destination of a push operation.]' + '-m[use the custom commit information instead of the default message.]' + '-s[Create a signed and annotated tag.]' + '-u[Create a tag, annotated and signed with the given key.]' + '--semver[If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag.]' + '--no-empty-commit[Avoid creating empty commit if nothing could be committed.]' + '--[The arguments listed after "--" separator will be passed to pre/post-release hook.]' +} _git-undo(){ _arguments -C \ diff --git a/man/git-release.1 b/man/git-release.1 index 8a9b40f..a070a20 100644 --- a/man/git-release.1 +++ b/man/git-release.1 @@ -7,7 +7,7 @@ \fBgit\-release\fR \- Commit, tag and push changes to the repository . .SH "SYNOPSIS" -\fBgit\-release\fR [ | \-\-semver ] [\-r ] [\-m ] [\-\-no\-empty\-commit] [\-c] [[\-\-] ] +\fBgit\-release\fR [ | \-\-semver ] [\-r ] [\-m ] [\-\-no\-empty\-commit] [\-c] [\-s] [\-u ] [[\-\-] ] . .SH "DESCRIPTION" Commits changes with message "Release " or custom commit information, tags with the given and pushes the branch / tags\. @@ -58,6 +58,18 @@ Avoid creating empty commit if nothing could be committed\. Generates or populates the changelog with all commit message since the last tag\. For more info see git\-changelog\.\. . .P +\-s +. +.P +Create a signed and annotated tag\. +. +.P +\-u +. +.P +Create a tag, annotated and signed with the given key\. +. +.P [\-\-] hook arguments\.\.\. . .P diff --git a/man/git-release.html b/man/git-release.html index 8598e2b..3e30b88 100644 --- a/man/git-release.html +++ b/man/git-release.html @@ -76,7 +76,7 @@

SYNOPSIS

-

git-release [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [[--] <hook arguments...>]

+

git-release [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [-s] [-u <key-id>] [[--] <hook arguments...>]

DESCRIPTION

@@ -116,6 +116,14 @@

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

+

-s

+ +

Create a signed and annotated tag.

+ +

-u <key-id>

+ +

Create a tag, annotated and signed with the given key.

+

[--] hook arguments...

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

diff --git a/man/git-release.md b/man/git-release.md index 593b653..0e7b2f4 100644 --- a/man/git-release.md +++ b/man/git-release.md @@ -3,7 +3,7 @@ git-release(1) -- Commit, tag and push changes to the repository ## SYNOPSIS -`git-release` [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [[--] <hook arguments...>] +`git-release` [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [-s] [-u <key-id>] [[--] <hook arguments...>] ## DESCRIPTION @@ -43,6 +43,14 @@ git-release(1) -- Commit, tag and push changes to the repository Generates or populates the changelog with all commit message since the last tag. For more info see git-changelog.. + -s + + Create a signed and annotated tag. + + -u <key-id> + + Create a tag, annotated and signed with the given key. + [--] hook arguments... The arguments listed after "--" separator will be passed to pre/post-release hook following the `tagname`.