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

jreleaser / jreleaser / #480

08 Apr 2025 02:28PM UTC coverage: 47.827% (-0.7%) from 48.516%
#480

push

github

aalmiray
feat(release): Let github.release.makeLatest be specified as input

Closes #1847

17 of 29 new or added lines in 6 files covered. (58.62%)

374 existing lines in 32 files now uncovered.

24810 of 51874 relevant lines covered (47.83%)

0.48 hits per line

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

38.26
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/release/GithubReleaser.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.model.internal.release;
19

20
import com.fasterxml.jackson.annotation.JsonIgnore;
21
import org.jreleaser.model.Active;
22
import org.jreleaser.model.internal.common.AbstractModelObject;
23
import org.jreleaser.model.internal.common.Domain;
24
import org.jreleaser.model.internal.common.EnabledAware;
25

26
import java.util.LinkedHashMap;
27
import java.util.Map;
28

29
import static java.util.Collections.unmodifiableMap;
30

31
/**
32
 * @author Andres Almiray
33
 * @since 0.1.0
34
 */
35
public final class GithubReleaser extends BaseReleaser<org.jreleaser.model.api.release.GithubReleaser, GithubReleaser> {
36
    private static final long serialVersionUID = 8444833889157237176L;
37

38
    private final ReleaseNotes releaseNotes = new ReleaseNotes();
1✔
39

40
    private Boolean draft;
41
    private String discussionCategoryName;
42
    private org.jreleaser.model.api.release.GithubReleaser.MakeLatest makeLatest;
43

44
    @JsonIgnore
1✔
45
    private final org.jreleaser.model.api.release.GithubReleaser immutable = new org.jreleaser.model.api.release.GithubReleaser() {
1✔
46
        private static final long serialVersionUID = -9123016069637288447L;
47

48
        @Override
49
        public boolean isPrerelease() {
50
            return GithubReleaser.this.isPrerelease();
×
51
        }
52

53
        @Override
54
        public boolean isDraft() {
55
            return GithubReleaser.this.isDraft();
×
56
        }
57

58
        @Override
59
        public MakeLatest getMakeLatest() {
NEW
60
            return makeLatest;
×
61
        }
62

63
        @Override
64
        public String getDiscussionCategoryName() {
65
            return discussionCategoryName;
×
66
        }
67

68
        @Override
69
        public ReleaseNotes getReleaseNotes() {
70
            return releaseNotes.asImmutable();
×
71
        }
72

73
        @Override
74
        public String getServiceName() {
75
            return GithubReleaser.this.getServiceName();
×
76
        }
77

78
        @Override
79
        public boolean isReleaseSupported() {
80
            return GithubReleaser.this.isReleaseSupported();
×
81
        }
82

83
        @Override
84
        public String getCanonicalRepoName() {
85
            return GithubReleaser.this.getCanonicalRepoName();
×
86
        }
87

88
        @Override
89
        public String getReverseRepoHost() {
90
            return GithubReleaser.this.getReverseRepoHost();
×
91
        }
92

93
        @Override
94
        public boolean isMatch() {
95
            return GithubReleaser.this.isMatch();
×
96
        }
97

98
        @Override
99
        public String getHost() {
100
            return GithubReleaser.this.getHost();
×
101
        }
102

103
        @Override
104
        public String getName() {
105
            return GithubReleaser.this.getName();
×
106
        }
107

108
        @Override
109
        public String getRepoUrl() {
110
            return GithubReleaser.this.getRepoUrl();
×
111
        }
112

113
        @Override
114
        public String getRepoCloneUrl() {
115
            return GithubReleaser.this.getRepoCloneUrl();
×
116
        }
117

118
        @Override
119
        public String getCommitUrl() {
120
            return GithubReleaser.this.getCommitUrl();
×
121
        }
122

123
        @Override
124
        public String getSrcUrl() {
125
            return GithubReleaser.this.getSrcUrl();
×
126
        }
127

128
        @Override
129
        public String getDownloadUrl() {
130
            return GithubReleaser.this.getDownloadUrl();
×
131
        }
132

133
        @Override
134
        public String getReleaseNotesUrl() {
135
            return GithubReleaser.this.getReleaseNotesUrl();
×
136
        }
137

138
        @Override
139
        public String getLatestReleaseUrl() {
140
            return GithubReleaser.this.getLatestReleaseUrl();
×
141
        }
142

143
        @Override
144
        public String getIssueTrackerUrl() {
145
            return GithubReleaser.this.getIssueTrackerUrl();
×
146
        }
147

148
        @Override
149
        public String getUsername() {
150
            return GithubReleaser.this.getUsername();
×
151
        }
152

153
        @Override
154
        public String getToken() {
155
            return GithubReleaser.this.getToken();
×
156
        }
157

158
        @Override
159
        public String getTagName() {
160
            return GithubReleaser.this.getTagName();
×
161
        }
162

163
        @Override
164
        public String getPreviousTagName() {
165
            return GithubReleaser.this.getPreviousTagName();
×
166
        }
167

168
        @Override
169
        public String getReleaseName() {
170
            return GithubReleaser.this.getReleaseName();
×
171
        }
172

173
        @Override
174
        public String getBranch() {
175
            return GithubReleaser.this.getBranch();
×
176
        }
177

178
        @Override
179
        public String getBranchPush() {
180
            return GithubReleaser.this.getBranchPush();
×
181
        }
182

183
        @Override
184
        public Prerelease getPrerelease() {
185
            return GithubReleaser.this.getPrerelease().asImmutable();
×
186
        }
187

188
        @Override
189
        public boolean isSign() {
190
            return GithubReleaser.this.isSign();
×
191
        }
192

193
        @Override
194
        public org.jreleaser.model.api.release.Changelog getChangelog() {
195
            return GithubReleaser.this.getChangelog().asImmutable();
×
196
        }
197

198
        @Override
199
        public Milestone getMilestone() {
200
            return GithubReleaser.this.getMilestone().asImmutable();
×
201
        }
202

203
        @Override
204
        public Issues getIssues() {
205
            return GithubReleaser.this.getIssues().asImmutable();
×
206
        }
207

208
        @Override
209
        public boolean isSkipTag() {
210
            return GithubReleaser.this.isSkipTag();
×
211
        }
212

213
        @Override
214
        public boolean isSkipRelease() {
215
            return GithubReleaser.this.isSkipRelease();
×
216
        }
217

218
        @Override
219
        public boolean isOverwrite() {
220
            return GithubReleaser.this.isOverwrite();
×
221
        }
222

223
        @Override
224
        public Update getUpdate() {
225
            return GithubReleaser.this.getUpdate().asImmutable();
×
226
        }
227

228
        @Override
229
        public String getApiEndpoint() {
230
            return GithubReleaser.this.getApiEndpoint();
×
231
        }
232

233
        @Override
234
        public boolean isArtifacts() {
235
            return GithubReleaser.this.isArtifacts();
×
236
        }
237

238
        @Override
239
        public boolean isFiles() {
240
            return GithubReleaser.this.isFiles();
×
241
        }
242

243
        @Override
244
        public boolean isChecksums() {
245
            return GithubReleaser.this.isChecksums();
×
246
        }
247

248
        @Override
249
        public boolean isCatalogs() {
250
            return GithubReleaser.this.isCatalogs();
×
251
        }
252

253
        @Override
254
        public boolean isSignatures() {
255
            return GithubReleaser.this.isSignatures();
×
256
        }
257

258
        @Override
259
        public Active getUploadAssets() {
260
            return GithubReleaser.this.getUploadAssets();
×
261
        }
262

263
        @Override
264
        public org.jreleaser.model.api.common.CommitAuthor getCommitAuthor() {
265
            return GithubReleaser.this.getCommitAuthor().asImmutable();
×
266
        }
267

268
        @Override
269
        public Map<String, Object> asMap(boolean full) {
270
            return unmodifiableMap(GithubReleaser.this.asMap(full));
×
271
        }
272

273
        @Override
274
        public boolean isEnabled() {
275
            return GithubReleaser.this.isEnabled();
×
276
        }
277

278
        @Override
279
        public String getOwner() {
280
            return GithubReleaser.this.getOwner();
×
281
        }
282

283
        @Override
284
        public Integer getConnectTimeout() {
285
            return GithubReleaser.this.getConnectTimeout();
×
286
        }
287

288
        @Override
289
        public Integer getReadTimeout() {
290
            return GithubReleaser.this.getReadTimeout();
×
291
        }
292
    };
293

294
    public GithubReleaser() {
295
        super(org.jreleaser.model.api.release.GithubReleaser.TYPE, true);
1✔
296
        setHost("github.com");
1✔
297
        setApiEndpoint("https://api.github.com");
1✔
298
        setRepoUrl("https://{{repoHost}}/{{repoOwner}}/{{repoName}}");
1✔
299
        setRepoCloneUrl("https://{{repoHost}}/{{repoOwner}}/{{repoName}}.git");
1✔
300
        setCommitUrl("https://{{repoHost}}/{{repoOwner}}/{{repoName}}/commits");
1✔
301
        setSrcUrl("https://{{repoHost}}/{{repoOwner}}/{{repoName}}/blob/{{repoBranch}}");
1✔
302
        setDownloadUrl("https://{{repoHost}}/{{repoOwner}}/{{repoName}}/releases/download/{{tagName}}/{{artifactFile}}");
1✔
303
        setReleaseNotesUrl("https://{{repoHost}}/{{repoOwner}}/{{repoName}}/releases/tag/{{tagName}}");
1✔
304
        setLatestReleaseUrl("https://{{repoHost}}/{{repoOwner}}/{{repoName}}/releases/latest");
1✔
305
        setIssueTrackerUrl("https://{{repoHost}}/{{repoOwner}}/{{repoName}}/issues");
1✔
306
    }
1✔
307

308
    @Override
309
    public org.jreleaser.model.api.release.GithubReleaser asImmutable() {
310
        return immutable;
1✔
311
    }
312

313
    @Override
314
    public void merge(GithubReleaser source) {
315
        super.merge(source);
×
316
        this.draft = merge(this.draft, source.draft);
×
NEW
317
        this.makeLatest = merge(this.makeLatest, source.makeLatest);
×
318
        this.discussionCategoryName = merge(this.discussionCategoryName, source.discussionCategoryName);
×
319
        setReleaseNotes(source.releaseNotes);
×
320
    }
×
321

322
    public org.jreleaser.model.api.release.GithubReleaser.MakeLatest getMakeLatest() {
323
        return makeLatest;
1✔
324
    }
325

326
    public void setMakeLatest(org.jreleaser.model.api.release.GithubReleaser.MakeLatest makeLatest) {
327
        this.makeLatest = makeLatest;
1✔
328
    }
1✔
329

330
    public void setMakeLatest(String makeLatest) {
331
        if (null != makeLatest) {
1✔
332
            setMakeLatest(org.jreleaser.model.api.release.GithubReleaser.MakeLatest.of(makeLatest.trim()));
1✔
333
        }
334
    }
1✔
335

336
    public boolean isDraft() {
337
        return null != draft && draft;
1✔
338
    }
339

340
    public void setDraft(Boolean draft) {
341
        this.draft = draft;
1✔
342
    }
1✔
343

344
    public boolean isDraftSet() {
345
        return null != draft;
1✔
346
    }
347

348
    public String getDiscussionCategoryName() {
349
        return discussionCategoryName;
×
350
    }
351

352
    public void setDiscussionCategoryName(String discussionCategoryName) {
353
        this.discussionCategoryName = discussionCategoryName;
1✔
354
    }
1✔
355

356
    public ReleaseNotes getReleaseNotes() {
357
        return releaseNotes;
1✔
358
    }
359

360
    public void setReleaseNotes(ReleaseNotes releaseNotes) {
361
        this.releaseNotes.merge(releaseNotes);
×
362
    }
×
363

364
    @Override
365
    public String getReverseRepoHost() {
366
        return "com.github";
1✔
367
    }
368

369
    @Override
370
    public Map<String, Object> asMap(boolean full) {
371
        Map<String, Object> map = super.asMap(full);
1✔
372
        map.put("draft", isDraft());
1✔
373
        map.put("discussionCategoryName", discussionCategoryName);
1✔
374
        map.put("releaseNotes", releaseNotes.asMap(full));
1✔
375
        map.put("makeLatest", null != makeLatest ? makeLatest.formatted() : null);
1✔
376
        return map;
1✔
377
    }
378

379
    public static final class ReleaseNotes extends AbstractModelObject<ReleaseNotes> implements Domain, EnabledAware {
1✔
380
        private static final long serialVersionUID = -1029998017479730113L;
381

382
        private Boolean enabled;
383
        private String configurationFile;
384

385
        @JsonIgnore
1✔
386
        private final org.jreleaser.model.api.release.GithubReleaser.ReleaseNotes immutable = new org.jreleaser.model.api.release.GithubReleaser.ReleaseNotes() {
1✔
387
            private static final long serialVersionUID = -301461478911447433L;
388

389
            @Override
390
            public String getConfigurationFile() {
391
                return configurationFile;
×
392
            }
393

394
            @Override
395
            public Map<String, Object> asMap(boolean full) {
396
                return unmodifiableMap(ReleaseNotes.this.asMap(full));
×
397
            }
398

399
            @Override
400
            public boolean isEnabled() {
401
                return ReleaseNotes.this.isEnabled();
×
402
            }
403
        };
404

405
        public org.jreleaser.model.api.release.GithubReleaser.ReleaseNotes asImmutable() {
406
            return immutable;
×
407
        }
408

409
        @Override
410
        public void merge(ReleaseNotes source) {
411
            this.enabled = merge(this.enabled, source.enabled);
×
412
            this.configurationFile = merge(this.configurationFile, source.configurationFile);
×
413
        }
×
414

415
        @Override
416
        public boolean isEnabled() {
417
            return null != enabled && enabled;
1✔
418
        }
419

420
        @Override
421
        public void setEnabled(Boolean enabled) {
422
            this.enabled = enabled;
×
423
        }
×
424

425
        @Override
426
        public boolean isEnabledSet() {
427
            return null != enabled;
×
428
        }
429

430
        public String getConfigurationFile() {
431
            return configurationFile;
×
432
        }
433

434
        public void setConfigurationFile(String configurationFile) {
435
            this.configurationFile = configurationFile;
×
436
        }
×
437

438
        @Override
439
        public Map<String, Object> asMap(boolean full) {
440
            Map<String, Object> map = new LinkedHashMap<>();
1✔
441
            map.put("enabled", isEnabled());
1✔
442
            map.put("configurationFile", configurationFile);
1✔
443
            return map;
1✔
444
        }
445
    }
446
}
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