mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
[core] Support releasing to Codeberg. Resolves #122
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jreleaser.engine.context;
|
||||
|
||||
import org.jreleaser.model.Active;
|
||||
import org.jreleaser.model.Artifact;
|
||||
import org.jreleaser.model.Codeberg;
|
||||
import org.jreleaser.model.GitService;
|
||||
import org.jreleaser.model.Github;
|
||||
import org.jreleaser.model.Gitlab;
|
||||
@@ -259,6 +260,12 @@ public class ModelAutoConfigurer {
|
||||
service = new Gitlab();
|
||||
model.getRelease().setGitlab((Gitlab) service);
|
||||
break;
|
||||
case CODEBERG:
|
||||
service = new Codeberg();
|
||||
model.getRelease().setCodeberg((Codeberg) service);
|
||||
((Codeberg) service).setPrerelease(prerelease);
|
||||
((Codeberg) service).setDraft(draft);
|
||||
break;
|
||||
default:
|
||||
throw new JReleaserException("Auto configuration does not support " + repository.getHttpUrl());
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jreleaser.engine.context;
|
||||
|
||||
import org.jreleaser.model.Codeberg;
|
||||
import org.jreleaser.model.GitService;
|
||||
import org.jreleaser.model.Github;
|
||||
import org.jreleaser.model.Gitlab;
|
||||
@@ -66,6 +67,9 @@ public class ModelConfigurer {
|
||||
case GITLAB:
|
||||
autoConfigureGitlab(context, repository);
|
||||
break;
|
||||
case CODEBERG:
|
||||
autoConfigureCodeberg(context, repository);
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -143,6 +147,30 @@ public class ModelConfigurer {
|
||||
fillGitProperties(gitlab, repository, context.getModel().getCommit());
|
||||
}
|
||||
|
||||
private static void autoConfigureCodeberg(JReleaserContext context, Repository repository) {
|
||||
GitService service = context.getModel().getRelease().getGitService();
|
||||
Codeberg codeberg = context.getModel().getRelease().getCodeberg();
|
||||
|
||||
if (service != null) {
|
||||
if (service != codeberg) {
|
||||
context.getLogger().warn("Auto configure detected codeberg but project has " +
|
||||
service.getServiceName() + " configured");
|
||||
|
||||
if (isBlank(Env.resolve(BRANCH, service.getBranch()))) {
|
||||
service.setBranch(context.getModel().getCommit().getRefName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (null == codeberg) {
|
||||
codeberg = new Codeberg();
|
||||
context.getModel().getRelease().setCodeberg(codeberg);
|
||||
}
|
||||
|
||||
fillGitProperties(codeberg, repository, context.getModel().getCommit());
|
||||
}
|
||||
|
||||
private static void fillGitProperties(GitService service, Repository repository, Commit head) {
|
||||
if (isBlank(service.getOwner())) {
|
||||
service.setOwner(repository.getOwner());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jreleaser.engine.release;
|
||||
|
||||
import org.jreleaser.model.Codeberg;
|
||||
import org.jreleaser.model.Gitea;
|
||||
import org.jreleaser.model.Github;
|
||||
import org.jreleaser.model.Gitlab;
|
||||
@@ -61,6 +62,9 @@ public class Releasers {
|
||||
if (null != context.getModel().getRelease().getGitea()) {
|
||||
return (RB) builders.get(Gitea.NAME);
|
||||
}
|
||||
if (null != context.getModel().getRelease().getCodeberg()) {
|
||||
return (RB) builders.get(Codeberg.NAME);
|
||||
}
|
||||
|
||||
throw new JReleaserException("No suitable git releaser has been configured");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.model;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public class Codeberg extends Gitea {
|
||||
public static final String NAME = "codeberg";
|
||||
|
||||
public Codeberg() {
|
||||
super(NAME);
|
||||
setHost("codeberg.org");
|
||||
setApiEndpoint("https://codeberg.org");
|
||||
}
|
||||
|
||||
void setAll(Codeberg service) {
|
||||
super.setAll(service);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,11 @@ public class Gitea extends GitService {
|
||||
private Boolean prerelease;
|
||||
|
||||
public Gitea() {
|
||||
super(NAME);
|
||||
this(NAME);
|
||||
}
|
||||
|
||||
Gitea(String name) {
|
||||
super(name);
|
||||
setRepoUrlFormat("https://{{repoHost}}/{{repoOwner}}/{{repoName}}");
|
||||
setRepoCloneUrlFormat("https://{{repoHost}}/{{repoOwner}}/{{repoName}}.git");
|
||||
setCommitUrlFormat("https://{{repoHost}}/{{repoOwner}}/{{repoName}}/commits");
|
||||
|
||||
@@ -28,11 +28,13 @@ public class Release implements Domain {
|
||||
private Github github;
|
||||
private Gitlab gitlab;
|
||||
private Gitea gitea;
|
||||
private Codeberg codeberg;
|
||||
|
||||
void setAll(Release release) {
|
||||
this.github = release.github;
|
||||
this.gitlab = release.gitlab;
|
||||
this.gitea = release.gitea;
|
||||
this.codeberg = release.codeberg;
|
||||
}
|
||||
|
||||
public Github getGithub() {
|
||||
@@ -59,10 +61,19 @@ public class Release implements Domain {
|
||||
this.gitea = gitea;
|
||||
}
|
||||
|
||||
public Codeberg getCodeberg() {
|
||||
return codeberg;
|
||||
}
|
||||
|
||||
public void setCodeberg(Codeberg codeberg) {
|
||||
this.codeberg = codeberg;
|
||||
}
|
||||
|
||||
public GitService getGitService() {
|
||||
if (null != github) return github;
|
||||
if (null != gitlab) return gitlab;
|
||||
return gitea;
|
||||
if (null != gitea) return gitea;
|
||||
return codeberg;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,6 +82,7 @@ public class Release implements Domain {
|
||||
if (null != github) map.put(Github.NAME, github.asMap(full));
|
||||
if (null != gitlab) map.put(Gitlab.NAME, gitlab.asMap(full));
|
||||
if (null != gitea) map.put(Gitea.NAME, gitea.asMap(full));
|
||||
if (null != codeberg) map.put(Codeberg.NAME, codeberg.asMap(full));
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public class Repository {
|
||||
public enum Kind {
|
||||
GITHUB,
|
||||
GITLAB,
|
||||
CODEBERG,
|
||||
OTHER
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.model.validation;
|
||||
|
||||
import org.jreleaser.model.Codeberg;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.util.Errors;
|
||||
|
||||
import static org.jreleaser.model.GitService.DRAFT;
|
||||
import static org.jreleaser.model.GitService.PRERELEASE;
|
||||
import static org.jreleaser.util.StringUtils.isBlank;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract class CodebergValidator extends GitServiceValidator {
|
||||
public static boolean validateCodeberg(JReleaserContext context, JReleaserContext.Mode mode, Codeberg codeberg, Errors errors) {
|
||||
if (null == codeberg) return false;
|
||||
context.getLogger().debug("release.codeberg");
|
||||
|
||||
validateGitService(context, mode, codeberg, errors);
|
||||
|
||||
if (context.getModel().getProject().isSnapshot()) {
|
||||
codeberg.setPrerelease(true);
|
||||
}
|
||||
|
||||
if (!codeberg.isPrereleaseSet()) {
|
||||
codeberg.setPrerelease(
|
||||
checkProperty(context.getModel().getEnvironment(),
|
||||
PRERELEASE,
|
||||
"codeberg.prerelease",
|
||||
null,
|
||||
false));
|
||||
}
|
||||
|
||||
if (!codeberg.isDraftSet()) {
|
||||
codeberg.setDraft(
|
||||
checkProperty(context.getModel().getEnvironment(),
|
||||
DRAFT,
|
||||
"codeberg.draft",
|
||||
null,
|
||||
false));
|
||||
}
|
||||
|
||||
if (codeberg.isDraft()) {
|
||||
codeberg.getMilestone().setClose(false);
|
||||
}
|
||||
|
||||
return codeberg.isEnabled();
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.model.Release;
|
||||
import org.jreleaser.util.Errors;
|
||||
|
||||
import static org.jreleaser.model.validation.CodebergValidator.validateCodeberg;
|
||||
import static org.jreleaser.model.validation.GiteaValidator.validateGitea;
|
||||
import static org.jreleaser.model.validation.GithubValidator.validateGithub;
|
||||
import static org.jreleaser.model.validation.GitlabValidator.validateGitlab;
|
||||
@@ -38,6 +39,7 @@ public abstract class ReleaseValidator extends Validator {
|
||||
if (validateGithub(context, mode, release.getGithub(), errors)) count++;
|
||||
if (validateGitlab(context, mode, release.getGitlab(), errors)) count++;
|
||||
if (validateGitea(context, mode, release.getGitea(), errors)) count++;
|
||||
if (validateCodeberg(context, mode, release.getCodeberg(), errors)) count++;
|
||||
|
||||
if (0 == count) {
|
||||
errors.configuration("No release provider has been configured");
|
||||
|
||||
@@ -30,6 +30,7 @@ dependencies {
|
||||
api project(':github-java-sdk')
|
||||
api project(':gitlab-java-sdk')
|
||||
api project(':gitea-java-sdk')
|
||||
api project(':codeberg-java-sdk')
|
||||
// tools
|
||||
api project(':jreleaser-tools')
|
||||
api project(':jreleaser-assemblers')
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.gradle.plugin.dsl
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import org.gradle.api.provider.Property
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Andres Almiray
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@CompileStatic
|
||||
interface Codeberg extends Gitea {
|
||||
Property<Boolean> getDraft()
|
||||
|
||||
Property<Boolean> getPrerelease()
|
||||
}
|
||||
@@ -33,9 +33,13 @@ interface Release {
|
||||
|
||||
Gitea getGitea()
|
||||
|
||||
Codeberg getCodeberg()
|
||||
|
||||
void github(Action<? super Github> action)
|
||||
|
||||
void gitlab(Action<? super Gitlab> action)
|
||||
|
||||
void gitea(Action<? super Gitea> action)
|
||||
|
||||
void codeberg(Action<? super Codeberg> action)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.gradle.plugin.internal.dsl
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import org.gradle.api.internal.provider.Providers
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.jreleaser.gradle.plugin.dsl.Codeberg
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Andres Almiray
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@CompileStatic
|
||||
class CodebergImpl extends AbstractGitService implements Codeberg {
|
||||
final Property<Boolean> draft
|
||||
final Property<Boolean> prerelease
|
||||
final ChangelogImpl changelog
|
||||
final MilestoneImpl milestone
|
||||
final CommitAuthorImpl commitAuthor
|
||||
|
||||
@Inject
|
||||
CodebergImpl(ObjectFactory objects) {
|
||||
super(objects)
|
||||
draft = objects.property(Boolean).convention(Providers.notDefined())
|
||||
prerelease = objects.property(Boolean).convention(Providers.notDefined())
|
||||
|
||||
changelog = objects.newInstance(ChangelogImpl, objects)
|
||||
milestone = objects.newInstance(MilestoneImpl, objects)
|
||||
commitAuthor = objects.newInstance(CommitAuthorImpl, objects)
|
||||
}
|
||||
|
||||
@Override
|
||||
@Internal
|
||||
boolean isSet() {
|
||||
super.isSet() ||
|
||||
draft.present ||
|
||||
prerelease.present ||
|
||||
changelog.isSet() ||
|
||||
milestone.isSet() ||
|
||||
commitAuthor.isSet()
|
||||
}
|
||||
|
||||
org.jreleaser.model.Codeberg toModel() {
|
||||
org.jreleaser.model.Codeberg service = new org.jreleaser.model.Codeberg()
|
||||
toModel(service)
|
||||
service.draft = draft.getOrElse(false)
|
||||
service.prerelease = prerelease.getOrElse(false)
|
||||
if (changelog.isSet()) service.changelog = changelog.toModel()
|
||||
if (milestone.isSet()) service.milestone = milestone.toModel()
|
||||
if (commitAuthor.isSet()) service.commitAuthor = commitAuthor.toModel()
|
||||
service
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package org.jreleaser.gradle.plugin.internal.dsl
|
||||
import groovy.transform.CompileStatic
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.jreleaser.gradle.plugin.dsl.Codeberg
|
||||
import org.jreleaser.gradle.plugin.dsl.Gitea
|
||||
import org.jreleaser.gradle.plugin.dsl.Github
|
||||
import org.jreleaser.gradle.plugin.dsl.Gitlab
|
||||
@@ -37,12 +38,14 @@ class ReleaseImpl implements Release {
|
||||
final GithubImpl github
|
||||
final GitlabImpl gitlab
|
||||
final GiteaImpl gitea
|
||||
final CodebergImpl codeberg
|
||||
|
||||
@Inject
|
||||
ReleaseImpl(ObjectFactory objects) {
|
||||
github = objects.newInstance(GithubImpl, objects)
|
||||
gitlab = objects.newInstance(GitlabImpl, objects)
|
||||
gitea = objects.newInstance(GiteaImpl, objects)
|
||||
codeberg = objects.newInstance(CodebergImpl, objects)
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,11 +63,17 @@ class ReleaseImpl implements Release {
|
||||
action.execute(gitea)
|
||||
}
|
||||
|
||||
@Override
|
||||
void codeberg(Action<? super Codeberg> action) {
|
||||
action.execute(codeberg)
|
||||
}
|
||||
|
||||
org.jreleaser.model.Release toModel() {
|
||||
org.jreleaser.model.Release release = new org.jreleaser.model.Release()
|
||||
if (github.isSet()) release.github = github.toModel()
|
||||
if (gitlab.isSet()) release.gitlab = gitlab.toModel()
|
||||
if (gitea.isSet()) release.gitea = gitea.toModel()
|
||||
if (codeberg.isSet()) release.codeberg = codeberg.toModel()
|
||||
release
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.maven.plugin;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public class Codeberg extends Gitea {
|
||||
public Codeberg() {
|
||||
super();
|
||||
setHost("codeberg.org");
|
||||
}
|
||||
|
||||
void setAll(Codeberg service) {
|
||||
super.setAll(service);
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,13 @@ public class Release {
|
||||
private Github github;
|
||||
private Gitlab gitlab;
|
||||
private Gitea gitea;
|
||||
private Codeberg codeberg;
|
||||
|
||||
void setAll(Release release) {
|
||||
this.github = release.github;
|
||||
this.gitlab = release.gitlab;
|
||||
this.gitea = release.gitea;
|
||||
this.codeberg = release.codeberg;
|
||||
}
|
||||
|
||||
public Github getGithub() {
|
||||
@@ -56,9 +58,18 @@ public class Release {
|
||||
this.gitea = gitea;
|
||||
}
|
||||
|
||||
public Codeberg getCodeberg() {
|
||||
return codeberg;
|
||||
}
|
||||
|
||||
public void setCodeberg(Codeberg codeberg) {
|
||||
this.codeberg = codeberg;
|
||||
}
|
||||
|
||||
public GitService getGitService() {
|
||||
if (null != github) return github;
|
||||
if (null != gitlab) return gitlab;
|
||||
return gitea;
|
||||
if (null != gitea) return gitea;
|
||||
return codeberg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jreleaser.maven.plugin.Bucket;
|
||||
import org.jreleaser.maven.plugin.Catalog;
|
||||
import org.jreleaser.maven.plugin.Changelog;
|
||||
import org.jreleaser.maven.plugin.Chocolatey;
|
||||
import org.jreleaser.maven.plugin.Codeberg;
|
||||
import org.jreleaser.maven.plugin.CommitAuthor;
|
||||
import org.jreleaser.maven.plugin.Discord;
|
||||
import org.jreleaser.maven.plugin.Discussions;
|
||||
@@ -142,6 +143,7 @@ public final class JReleaserModelConverter {
|
||||
r.setGithub(convertGithub(release.getGithub()));
|
||||
r.setGitlab(convertGitlab(release.getGitlab()));
|
||||
r.setGitea(convertGitea(release.getGitea()));
|
||||
r.setCodeberg(convertCodeberg(release.getCodeberg()));
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -170,6 +172,15 @@ public final class JReleaserModelConverter {
|
||||
return g;
|
||||
}
|
||||
|
||||
private static org.jreleaser.model.Codeberg convertCodeberg(Codeberg codeberg) {
|
||||
if (null == codeberg) return null;
|
||||
org.jreleaser.model.Codeberg g = new org.jreleaser.model.Codeberg();
|
||||
convertGitService(codeberg, g);
|
||||
g.setDraft(codeberg.isDraft());
|
||||
if (codeberg.isPrereleaseSet()) g.setPrerelease(codeberg.isPrerelease());
|
||||
return g;
|
||||
}
|
||||
|
||||
private static void convertGitService(GitService service, org.jreleaser.model.GitService s) {
|
||||
s.setOwner(service.getOwner());
|
||||
s.setName(service.getName());
|
||||
|
||||
23
sdks/codeberg-java-sdk/codeberg-java-sdk.gradle
Normal file
23
sdks/codeberg-java-sdk/codeberg-java-sdk.gradle
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
dependencies {
|
||||
compileOnly "org.kordamp.jipsy:jipsy-annotations:${jipsyVersion}"
|
||||
annotationProcessor "org.kordamp.jipsy:jipsy-processor:${jipsyVersion}"
|
||||
|
||||
api project(':gitea-java-sdk')
|
||||
}
|
||||
19
sdks/codeberg-java-sdk/gradle.properties
Normal file
19
sdks/codeberg-java-sdk/gradle.properties
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Copyright 2020-2021 Andres Almiray.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
project_description = Java SDK for Codeberg
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.sdk.codeberg;
|
||||
|
||||
import org.jreleaser.model.Gitea;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.model.releaser.spi.Repository;
|
||||
import org.jreleaser.sdk.gitea.GiteaReleaser;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public class CodebergReleaser extends GiteaReleaser {
|
||||
public CodebergReleaser(JReleaserContext context, List<Path> assets) {
|
||||
super(context, assets);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Gitea resolveGiteaFromModel() {
|
||||
return context.getModel().getRelease().getCodeberg();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Repository.Kind resolveRepositoryKind() {
|
||||
return Repository.Kind.CODEBERG;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.sdk.codeberg;
|
||||
|
||||
import org.jreleaser.model.releaser.spi.AbstractReleaserBuilder;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.4.0
|
||||
*/
|
||||
public class CodebergReleaserBuilder extends AbstractReleaserBuilder<CodebergReleaser> {
|
||||
@Override
|
||||
public CodebergReleaser build() {
|
||||
validate();
|
||||
|
||||
return new CodebergReleaser(context, assets);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright 2020-2021 Andres Almiray.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.sdk.codeberg;
|
||||
|
||||
import org.jreleaser.model.releaser.spi.ReleaserBuilderFactory;
|
||||
import org.kordamp.jipsy.annotations.ServiceProviderFor;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ServiceProviderFor(ReleaserBuilderFactory.class)
|
||||
public class CodebergReleaserBuilderFactory implements ReleaserBuilderFactory<CodebergReleaser, CodebergReleaserBuilder> {
|
||||
@Override
|
||||
public String getName() {
|
||||
return org.jreleaser.model.Codeberg.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodebergReleaserBuilder getBuilder() {
|
||||
return new CodebergReleaserBuilder();
|
||||
}
|
||||
}
|
||||
@@ -73,10 +73,16 @@ public class GitSdk {
|
||||
URIish uri = uris.get(0);
|
||||
|
||||
Repository.Kind kind = Repository.Kind.OTHER;
|
||||
if (uri.getHost().equals("github.com")) {
|
||||
kind = Repository.Kind.GITHUB;
|
||||
} else if (uri.getHost().equals("gitlab.com")) {
|
||||
kind = Repository.Kind.GITLAB;
|
||||
switch (uri.getHost()) {
|
||||
case "github.com":
|
||||
kind = Repository.Kind.GITHUB;
|
||||
break;
|
||||
case "gitlab.com":
|
||||
kind = Repository.Kind.GITLAB;
|
||||
break;
|
||||
case "codeberg.org":
|
||||
kind = Repository.Kind.CODEBERG;
|
||||
break;
|
||||
}
|
||||
|
||||
String[] parts = uri.getPath().split("/");
|
||||
|
||||
@@ -34,21 +34,31 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.jreleaser.util.StringUtils.capitalize;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class GiteaReleaser implements Releaser {
|
||||
private final JReleaserContext context;
|
||||
private final List<Path> assets = new ArrayList<>();
|
||||
protected final JReleaserContext context;
|
||||
protected final List<Path> assets = new ArrayList<>();
|
||||
|
||||
GiteaReleaser(JReleaserContext context, List<Path> assets) {
|
||||
public GiteaReleaser(JReleaserContext context, List<Path> assets) {
|
||||
this.context = context;
|
||||
this.assets.addAll(assets);
|
||||
}
|
||||
|
||||
protected org.jreleaser.model.Gitea resolveGiteaFromModel() {
|
||||
return context.getModel().getRelease().getGitea();
|
||||
}
|
||||
|
||||
protected Repository.Kind resolveRepositoryKind() {
|
||||
return Repository.Kind.OTHER;
|
||||
}
|
||||
|
||||
public void release() throws ReleaseException {
|
||||
org.jreleaser.model.Gitea gitea = context.getModel().getRelease().getGitea();
|
||||
org.jreleaser.model.Gitea gitea = resolveGiteaFromModel();
|
||||
context.getLogger().info("Releasing to {}", gitea.getResolvedRepoUrl(context.getModel()));
|
||||
String tagName = gitea.getEffectiveTagName(context.getModel());
|
||||
|
||||
@@ -79,7 +89,7 @@ public class GiteaReleaser implements Releaser {
|
||||
api.uploadAssets(gitea.getOwner(), gitea.getName(), release, assets);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Gitea release failed because release " +
|
||||
throw new IllegalStateException(capitalize(gitea.getServiceName()) + " release failed because release " +
|
||||
tagName + " already exists. overwrite = false; update = false");
|
||||
}
|
||||
} else {
|
||||
@@ -95,7 +105,7 @@ public class GiteaReleaser implements Releaser {
|
||||
|
||||
@Override
|
||||
public Repository maybeCreateRepository(String owner, String repo, String password) throws IOException {
|
||||
org.jreleaser.model.Gitea gitea = context.getModel().getRelease().getGitea();
|
||||
org.jreleaser.model.Gitea gitea = resolveGiteaFromModel();
|
||||
context.getLogger().debug("looking up {}/{}", owner, repo);
|
||||
|
||||
Gitea api = new Gitea(context.getLogger(),
|
||||
@@ -109,7 +119,7 @@ public class GiteaReleaser implements Releaser {
|
||||
}
|
||||
|
||||
return new Repository(
|
||||
Repository.Kind.OTHER,
|
||||
resolveRepositoryKind(),
|
||||
owner,
|
||||
repo,
|
||||
repository.getHtmlUrl(),
|
||||
@@ -117,7 +127,7 @@ public class GiteaReleaser implements Releaser {
|
||||
}
|
||||
|
||||
private void createRelease(Gitea api, String tagName, String changelog, boolean deleteTags) throws IOException {
|
||||
org.jreleaser.model.Gitea gitea = context.getModel().getRelease().getGitea();
|
||||
org.jreleaser.model.Gitea gitea = resolveGiteaFromModel();
|
||||
|
||||
if (context.isDryrun()) {
|
||||
for (Path asset : assets) {
|
||||
|
||||
Reference in New Issue
Block a user