Search in sources :

Example 1 with GtMilestone

use of org.jreleaser.sdk.gitea.api.GtMilestone in project jreleaser by jreleaser.

the class GiteaReleaser method createRelease.

private void createRelease(Gitea api, String tagName, String changelog, boolean deleteTags) throws IOException {
    org.jreleaser.model.Gitea gitea = resolveGiteaFromModel();
    if (context.isDryrun()) {
        for (Asset asset : assets) {
            if (0 == Files.size(asset.getPath()) || !Files.exists(asset.getPath())) {
                // do not upload empty or non existent files
                continue;
            }
            context.getLogger().info(" " + RB.$("git.upload.asset"), asset.getFilename());
        }
        return;
    }
    if (deleteTags) {
        deleteTags(api, gitea.getOwner(), gitea.getName(), tagName);
    }
    // local tag
    if (deleteTags || !gitea.isSkipTag()) {
        context.getLogger().debug(RB.$("git.releaser.repository.tag"), tagName);
        GitSdk.of(context).tag(tagName, true, context);
    }
    // remote tag/release
    GtRelease release = new GtRelease();
    release.setName(gitea.getEffectiveReleaseName());
    release.setTagName(tagName);
    release.setTargetCommitish(gitea.getBranch());
    release.setBody(changelog);
    release = api.createRelease(gitea.getOwner(), gitea.getName(), release);
    api.uploadAssets(gitea.getOwner(), gitea.getName(), release, assets);
    if (gitea.getMilestone().isClose() && !context.getModel().getProject().isSnapshot()) {
        Optional<GtMilestone> milestone = api.findMilestoneByName(gitea.getOwner(), gitea.getName(), gitea.getMilestone().getEffectiveName());
        if (milestone.isPresent()) {
            api.closeMilestone(gitea.getOwner(), gitea.getName(), milestone.get());
        }
    }
}
Also used : GtRelease(org.jreleaser.sdk.gitea.api.GtRelease) GtMilestone(org.jreleaser.sdk.gitea.api.GtMilestone) Asset(org.jreleaser.model.releaser.spi.Asset)

Aggregations

Asset (org.jreleaser.model.releaser.spi.Asset)1 GtMilestone (org.jreleaser.sdk.gitea.api.GtMilestone)1 GtRelease (org.jreleaser.sdk.gitea.api.GtRelease)1