From 86a1c3ab9c36f9067b55cdbc43e570b82bda35d2 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Sun, 10 Oct 2021 14:26:44 +0300 Subject: [PATCH 1/3] GitLab CI --- .gitlab-ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..3378d7d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,11 @@ +image: gradle:6.7.0-jdk8 +variables: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" +before_script: + - export GRADLE_USER_HOME=`pwd`/.gradle + +build: + stage: build + only: + - dev/ci + script: gradle --console=plain compileJava From f923f477655865c94633351946c6c9dac2ddab57 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Thu, 21 Oct 2021 18:33:16 +0300 Subject: [PATCH 2/3] 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 From 2b055062a34567336f99bf12a9a189e2032b1490 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Thu, 21 Oct 2021 22:24:23 +0300 Subject: [PATCH 3/3] GitLab CI: publish by job --- .gitignore | 3 --- .gitlab-ci.yml | 2 +- build.gradle | 7 ++----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index cbb7093..90ae4d1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,3 @@ out/ .gradle/ build/ publish.gradle - -# OTHER # -secrets.properties diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3378d7d..ea343c2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,4 +8,4 @@ build: stage: build only: - dev/ci - script: gradle --console=plain compileJava + script: gradle --console=plain publish diff --git a/build.gradle b/build.gradle index d7eb09c..375738a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,9 +4,6 @@ plugins { id 'maven-publish' } -def secrets = new Properties() -file("secrets.properties").withInputStream { secrets.load(it) } - project.group = projectGroup project.version = projectVersion @@ -94,8 +91,8 @@ publishing { maven { url "https://gitlab.com/api/v4/projects/${project.property('gitlab.projectid')}/packages/maven" credentials(HttpHeaderCredentials) { - name = 'Private-Token' - value = secrets.getProperty('gitlab.privateToken') + name = 'Job-Token' + value = System.getenv('CI_JOB_TOKEN') } authentication { header(HttpHeaderAuthentication)