• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jreleaser / jreleaser / #558

08 Dec 2025 02:56PM UTC coverage: 48.239% (+0.02%) from 48.215%
#558

push

github

aalmiray
feat(core): warn when a name template cannot be resolved

Closes #1960

Closes #1961

299 of 573 new or added lines in 133 files covered. (52.18%)

4 existing lines in 4 files now uncovered.

26047 of 53996 relevant lines covered (48.24%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/sdks/jreleaser-git-java-sdk/src/main/java/org/jreleaser/sdk/git/release/ReleaseUtils.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.sdk.git.release;
19

20
import org.eclipse.jgit.api.Git;
21
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
22
import org.jreleaser.bundle.RB;
23
import org.jreleaser.model.internal.JReleaserContext;
24
import org.jreleaser.model.internal.release.BaseReleaser;
25
import org.jreleaser.model.spi.release.ReleaseException;
26
import org.jreleaser.model.spi.release.Repository;
27
import org.jreleaser.sdk.git.GitSdk;
28

29
import java.io.IOException;
30

31
/**
32
 * @author Andres Almiray
33
 * @since 0.7.0
34
 */
35
@org.jreleaser.infra.nativeimage.annotations.NativeImage
36
public final class ReleaseUtils {
37
    private ReleaseUtils() {
38
        // noop
39
    }
40

41
    public static void createTag(JReleaserContext context) throws ReleaseException {
42
        BaseReleaser<?, ?> service = context.getModel().getRelease().getReleaser();
×
43

44
        try {
45
            GitSdk git = GitSdk.of(context);
×
46
            Repository repository = git.getRemote();
×
47

48
            context.getLogger().info(RB.$("git.tag"), repository.getHttpUrl());
×
NEW
49
            String tagName = service.getEffectiveTagName(context);
×
50

51
            context.getLogger().debug(RB.$("git.tag.lookup"), tagName);
×
52
            boolean tagged = git.findTag(tagName);
×
53
            boolean snapshot = context.getModel().getProject().isSnapshot();
×
54
            if (tagged) {
×
55
                context.getLogger().debug(RB.$("git.tag.exists"), tagName);
×
56
                if (service.isOverwrite() || snapshot) {
×
57
                    context.getLogger().debug(RB.$("git.tag.release"), tagName);
×
58
                    tagRelease(context, repository, tagName);
×
59
                } else if (!context.isDryrun()) {
×
60
                    throw new IllegalStateException(RB.$("ERROR_git_release_existing_tag", tagName));
×
61
                }
62
            } else {
63
                context.getLogger().debug(RB.$("git.tag.not.exist"), tagName);
×
64
                context.getLogger().debug(RB.$("git.tag.release"), tagName);
×
65
                tagRelease(context, repository, tagName);
×
66
            }
67
        } catch (IOException | IllegalStateException e) {
×
68
            context.getLogger().trace(e);
×
69
            throw new ReleaseException(e);
×
70
        }
×
71
    }
×
72

73
    private static void tagRelease(JReleaserContext context, Repository repository, String tagName) throws ReleaseException {
74
        try {
75
            GitSdk gitSdk = GitSdk.of(context);
×
76
            gitSdk.tag(tagName, true, context);
×
77

78
            context.getLogger().info(RB.$("git.push.release"), repository.getHttpUrl());
×
79
            context.getLogger().debug(RB.$("git.push.tag"), context.isDryrun());
×
80

81
            UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(
×
82
                context.getModel().getRelease().getReleaser().getUsername(),
×
83
                context.getModel().getRelease().getReleaser().getToken());
×
84

85
            try (Git git = gitSdk.open()) {
×
86
                git.push()
×
87
                    .setDryRun(context.isDryrun())
×
88
                    .setPushTags()
×
89
                    .setCredentialsProvider(credentialsProvider)
×
90
                    .call();
×
91
            }
92
        } catch (Exception e) {
×
93
            context.getLogger().trace(e);
×
94
            throw new ReleaseException(e);
×
95
        }
×
96
    }
×
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc