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

jreleaser / jreleaser / #510

27 Jul 2025 12:31PM UTC coverage: 45.783% (-3.6%) from 49.39%
#510

push

github

aalmiray
feat(packagers): Stage distribution publication in a fixed directory

Closes #1943

12 of 25 new or added lines in 4 files covered. (48.0%)

2208 existing lines in 190 files now uncovered.

23924 of 52255 relevant lines covered (45.78%)

0.46 hits per line

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

0.0
/sdks/jreleaser-github-java-sdk/src/main/java/org/jreleaser/sdk/github/DiscussionsAnnouncer.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.github;
19

20
import org.jreleaser.bundle.RB;
21
import org.jreleaser.model.internal.JReleaserContext;
22
import org.jreleaser.model.internal.release.GithubReleaser;
23
import org.jreleaser.model.spi.announce.AnnounceException;
24
import org.jreleaser.model.spi.announce.Announcer;
25
import org.jreleaser.mustache.TemplateContext;
26

27
import static org.jreleaser.util.StringUtils.isNotBlank;
28

29
/**
30
 * @author Andres Almiray
31
 * @since 0.1.0
32
 */
33
@org.jreleaser.infra.nativeimage.annotations.NativeImage
34
public class DiscussionsAnnouncer implements Announcer<org.jreleaser.model.api.announce.DiscussionsAnnouncer> {
35
    private final JReleaserContext context;
36
    private final org.jreleaser.model.internal.announce.DiscussionsAnnouncer discussions;
37

UNCOV
38
    public DiscussionsAnnouncer(JReleaserContext context) {
×
UNCOV
39
        this.context = context;
×
UNCOV
40
        this.discussions = context.getModel().getAnnounce().getDiscussions();
×
UNCOV
41
    }
×
42

43
    @Override
44
    public org.jreleaser.model.api.announce.DiscussionsAnnouncer getAnnouncer() {
UNCOV
45
        return discussions.asImmutable();
×
46
    }
47

48
    @Override
49
    public String getName() {
UNCOV
50
        return org.jreleaser.model.api.announce.DiscussionsAnnouncer.TYPE;
×
51
    }
52

53
    @Override
54
    public boolean isEnabled() {
UNCOV
55
        return discussions.isEnabled();
×
56
    }
57

58
    @Override
59
    public void announce() throws AnnounceException {
UNCOV
60
        GithubReleaser github = context.getModel().getRelease().getGithub();
×
61

UNCOV
62
        String message = "";
×
UNCOV
63
        if (isNotBlank(discussions.getMessage())) {
×
64
            message = discussions.getResolvedMessage(context);
×
65
        } else {
UNCOV
66
            TemplateContext props = new TemplateContext();
×
UNCOV
67
            context.getModel().getRelease().getReleaser().fillProps(props, context.getModel());
×
UNCOV
68
            message = discussions.getResolvedMessageTemplate(context, props);
×
69
        }
70

UNCOV
71
        String title = discussions.getResolvedTitle(context);
×
UNCOV
72
        context.getLogger().info("title: {}", title);
×
UNCOV
73
        context.getLogger().debug("message: {}", message);
×
74

UNCOV
75
        if (context.isDryrun()) return;
×
76

77
        try {
78
            Github api = new Github(context.asImmutable(),
×
79
                github.getApiEndpoint(),
×
80
                github.getToken(),
×
81
                discussions.getConnectTimeout(),
×
82
                discussions.getReadTimeout());
×
83

84
            if (api.findDiscussion(discussions.getOrganization(), discussions.getTeam(), title).isPresent()) {
×
85
                throw new IllegalStateException(RB.$("ERROR_git_discussion_duplicate",
×
86
                    title, discussions.getOrganization(), discussions.getTeam()));
×
87
            }
88

89
            api.createDiscussion(discussions.getOrganization(), discussions.getTeam(), title, message);
×
90
        } catch (IllegalStateException e) {
×
91
            context.getLogger().trace(e);
×
92
            throw new AnnounceException(e);
×
93
        }
×
94
    }
×
95
}
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