From f923f477655865c94633351946c6c9dac2ddab57 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Thu, 21 Oct 2021 18:33:16 +0300 Subject: [PATCH] GitLab CI: manual publish --- .gitignore | 3 +++ build.gradle | 36 +++++++++++++++++++++++++++++++----- gradle.properties | 4 +++- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 90ae4d1..cbb7093 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ out/ .gradle/ build/ publish.gradle + +# OTHER # +secrets.properties diff --git a/build.gradle b/build.gradle index bc0e549..d7eb09c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ +//file:noinspection GroovyAssignabilityCheck plugins { id 'java' + id 'maven-publish' } -def publishScript = file(rootProject.getProjectDir().getPath() + '/publish.gradle') -if (publishScript.exists()) { - apply from: publishScript.path -} +def secrets = new Properties() +file("secrets.properties").withInputStream { secrets.load(it) } project.group = projectGroup project.version = projectVersion @@ -15,6 +15,7 @@ repositories { mavenCentral() maven { url 'https://hub.spigotmc.org/nexus/content/groups/public' } maven { url 'https://dmx-mc-project.gitlab.io/maven-repository/' } + maven { url "https://gitlab.com/api/v4/projects/${project.property('gitlab.projectid')}/packages/maven" } } ext { @@ -76,4 +77,29 @@ dependencies { test { useJUnitPlatform() -} \ No newline at end of file +} + +publishing { + publications { + mavenBinary(MavenPublication) { + groupId = project.property('projectGroup') + artifactId = project.property('projectName') + version = project.property('projectVersion') + + from components.java + } + } + + repositories { + maven { + url "https://gitlab.com/api/v4/projects/${project.property('gitlab.projectid')}/packages/maven" + credentials(HttpHeaderCredentials) { + name = 'Private-Token' + value = secrets.getProperty('gitlab.privateToken') + } + authentication { + header(HttpHeaderAuthentication) + } + } + } +} diff --git a/gradle.properties b/gradle.properties index 645012a..94ef319 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,5 @@ projectGroup=ghast projectName=ghast-tools -projectVersion=1.12.1 \ No newline at end of file +projectVersion=1.12.1 + +gitlab.projectid=23328133 \ No newline at end of file