mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
[release] Allow customizing which parts of a release should be updated. Resolves #204
This commit is contained in:
@@ -223,6 +223,14 @@ class Gitlab {
|
||||
api.createRelease(release, project.getId());
|
||||
}
|
||||
|
||||
void updateRelease(String owner, String repoName, String identifier, Release release) throws RestAPIException {
|
||||
logger.debug("creating release on {}/{} with tag {}", owner, repoName, release.getTagName());
|
||||
|
||||
Project project = getProject(repoName, identifier);
|
||||
|
||||
api.updateRelease(release, project.getId());
|
||||
}
|
||||
|
||||
List<FileUpload> uploadAssets(String owner, String repoName, String identifier, List<Path> assets) throws IOException, RestAPIException {
|
||||
logger.debug("uploading assets to {}/{}", owner, repoName);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.jreleaser.sdk.gitlab;
|
||||
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.model.UpdateSection;
|
||||
import org.jreleaser.model.releaser.spi.ReleaseException;
|
||||
import org.jreleaser.model.releaser.spi.Releaser;
|
||||
import org.jreleaser.model.releaser.spi.Repository;
|
||||
@@ -77,8 +78,26 @@ public class GitlabReleaser implements Releaser {
|
||||
} else if (gitlab.isUpdate()) {
|
||||
context.getLogger().debug("updating release {}", tagName);
|
||||
if (!context.isDryrun()) {
|
||||
List<FileUpload> uploads = api.uploadAssets(gitlab.getOwner(), gitlab.getName(), gitlab.getIdentifier(), assets);
|
||||
api.linkAssets(gitlab.getOwner(), gitlab.getName(), release, gitlab.getIdentifier(), uploads);
|
||||
boolean update = false;
|
||||
Release updater = new Release();
|
||||
if (gitlab.getUpdateSections().contains(UpdateSection.TITLE)) {
|
||||
update = true;
|
||||
context.getLogger().info("updating release title to {}", gitlab.getEffectiveReleaseName());
|
||||
updater.setName(gitlab.getEffectiveReleaseName());
|
||||
}
|
||||
if (gitlab.getUpdateSections().contains(UpdateSection.BODY)) {
|
||||
update = true;
|
||||
context.getLogger().info("updating release body");
|
||||
updater.setDescription(changelog);
|
||||
}
|
||||
if (update) {
|
||||
api.updateRelease(gitlab.getOwner(), gitlab.getName(), gitlab.getIdentifier(), updater);
|
||||
}
|
||||
|
||||
if (gitlab.getUpdateSections().contains(UpdateSection.ASSETS)) {
|
||||
List<FileUpload> uploads = api.uploadAssets(gitlab.getOwner(), gitlab.getName(), gitlab.getIdentifier(), assets);
|
||||
api.linkAssets(gitlab.getOwner(), gitlab.getName(), release, gitlab.getIdentifier(), uploads);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Gitlab release failed because release " +
|
||||
@@ -172,9 +191,9 @@ public class GitlabReleaser implements Releaser {
|
||||
gitlab.getMilestone().getEffectiveName());
|
||||
if (milestone.isPresent()) {
|
||||
api.closeMilestone(gitlab.getOwner(),
|
||||
gitlab.getName(),
|
||||
gitlab.getIdentifier(),
|
||||
milestone.get());
|
||||
gitlab.getName(),
|
||||
gitlab.getIdentifier(),
|
||||
milestone.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,10 @@ public interface GitlabAPI {
|
||||
@Headers("Content-Type: application/json")
|
||||
void createRelease(Release release, @Param("projectId") Integer projectId);
|
||||
|
||||
@RequestLine("PUT /projects/{projectId}/releases/{tagName}")
|
||||
@Headers("Content-Type: application/json")
|
||||
void updateRelease(Release release, @Param("projectId") Integer projectId);
|
||||
|
||||
@RequestLine("POST /projects/{projectId}/uploads")
|
||||
@Headers("Content-Type: multipart/form-data")
|
||||
FileUpload uploadFile(@Param("projectId") Integer projectId, @Param("file") FormData file);
|
||||
|
||||
Reference in New Issue
Block a user