Skip to content

Commit c56363e

Browse files
authored
Merge pull request #213 from glucazeau/master
Add option to sign Git tags
2 parents a04e72f + 889216b commit c56363e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ Below are some properties of the Release Plugin Convention that are specific to
159159
<td>{empty}</td>
160160
<td>Defines an array of options to add to the git adapter during a push. This could be useful to have the vc hooks skipped during a release. Example `pushOptions = ["--no-verify"]`</td>
161161
</tr>
162+
<tr>
163+
<td>Git</td>
164+
<td>signTag</td>
165+
<td>false</td>
166+
<td>Adds `-s` parameter to the tag command</td>
167+
</tr>
162168
</table>
163169

164170
To set any of these properties to false, add a "release" configuration to your project's ```build.gradle``` file. Eg. To ignore un-versioned files, you would add the following to your ```build.gradle``` file:
@@ -206,6 +212,7 @@ release {
206212
pushToRemote = 'origin'
207213
pushToBranchPrefix = ''
208214
commitVersionFileOnly = false
215+
signTag = false
209216
}
210217
211218
svn {

src/main/groovy/net/researchgate/release/GitAdapter.groovy

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class GitAdapter extends BaseScmAdapter {
3030
String requireBranch = 'master'
3131
def pushToRemote = 'origin' // needs to be def as can be boolean or string
3232
def pushOptions = []
33+
boolean signTag = false
3334

3435
/** @deprecated Remove in version 3.0 */
3536
@Deprecated
@@ -108,7 +109,11 @@ class GitAdapter extends BaseScmAdapter {
108109
@Override
109110
void createReleaseTag(String message) {
110111
def tagName = tagName()
111-
exec(['git', 'tag', '-a', tagName, '-m', message], directory: workingDirectory, errorMessage: "Duplicate tag [$tagName]", errorPatterns: ['already exists'])
112+
def params = ['git', 'tag', '-a', tagName, '-m', message]
113+
if (extension.git.signTag) {
114+
params.add('-s')
115+
}
116+
exec(params, directory: workingDirectory, errorMessage: "Duplicate tag [$tagName]", errorPatterns: ['already exists'])
112117
if (shouldPush()) {
113118
exec(['git', 'push', '--porcelain', extension.git.pushToRemote, tagName] + extension.git.pushOptions, directory: workingDirectory, errorMessage: "Failed to push tag [$tagName] to remote", errorPatterns: ['[rejected]', 'error: ', 'fatal: '])
114119
}

0 commit comments

Comments
 (0)