From 153c67d2ac79ad680448fb0c8306c736960c7810 Mon Sep 17 00:00:00 2001 From: Oleksii PELYKH Date: Wed, 19 Jun 2024 14:09:53 +0200 Subject: [PATCH] (chore) ci: publish from main to GitHub Packages --- .github/workflows/push.yaml | 6 ++++++ api/build.gradle.kts | 18 ++++++++++++++++-- ffm/build.gradle.kts | 18 ++++++++++++++++-- jna/build.gradle.kts | 18 ++++++++++++++++-- lib/build.gradle.kts | 18 ++++++++++++++++-- 5 files changed, 70 insertions(+), 8 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 23bf98e..97dac22 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -55,3 +55,9 @@ jobs: - name: Run tests (Ubuntu) if: ${{ matrix.os == 'ubuntu-latest' }} run: ./gradlew test -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu + + - name: Publish + if: ${{ matrix.os == 'ubuntu-latest' && matrix.java-distribution == 'temurin' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew publishAllPublicationsToGitHubPackagesRepository -Dpcre4j.version=main-SNAPSHOT diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 5312e60..d6fe669 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -63,8 +63,13 @@ publishing { create("mavenJava") { from(components["java"]) - artifact(tasks.named("sourcesJar")) - artifact(tasks.named("javadocJar")) + artifact(tasks.named("sourcesJar")) { + classifier = "sources" + } + + artifact(tasks.named("javadocJar")) { + classifier = "javadoc" + } groupId = "org.pcre4j" artifactId = project.name @@ -73,6 +78,15 @@ publishing { } repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/" + System.getenv("GITHUB_REPOSITORY")) + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + mavenCentral { credentials { username = findProperty("pcre4j.mavenCentral.user") as String? ?: "" diff --git a/ffm/build.gradle.kts b/ffm/build.gradle.kts index 32ff7af..ca897a6 100644 --- a/ffm/build.gradle.kts +++ b/ffm/build.gradle.kts @@ -84,8 +84,13 @@ publishing { create("mavenJava") { from(components["java"]) - artifact(tasks.named("sourcesJar")) - artifact(tasks.named("javadocJar")) + artifact(tasks.named("sourcesJar")) { + classifier = "sources" + } + + artifact(tasks.named("javadocJar")) { + classifier = "javadoc" + } groupId = "org.pcre4j" artifactId = project.name @@ -94,6 +99,15 @@ publishing { } repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/" + System.getenv("GITHUB_REPOSITORY")) + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + mavenCentral { credentials { username = findProperty("pcre4j.mavenCentral.user") as String? ?: "" diff --git a/jna/build.gradle.kts b/jna/build.gradle.kts index 0d7c61f..5cd87a4 100644 --- a/jna/build.gradle.kts +++ b/jna/build.gradle.kts @@ -67,8 +67,13 @@ publishing { create("mavenJava") { from(components["java"]) - artifact(tasks.named("sourcesJar")) - artifact(tasks.named("javadocJar")) + artifact(tasks.named("sourcesJar")) { + classifier = "sources" + } + + artifact(tasks.named("javadocJar")) { + classifier = "javadoc" + } groupId = "org.pcre4j" artifactId = project.name @@ -77,6 +82,15 @@ publishing { } repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/" + System.getenv("GITHUB_REPOSITORY")) + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + mavenCentral { credentials { username = findProperty("pcre4j.mavenCentral.user") as String? ?: "" diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 7074000..09c3b2a 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -64,8 +64,13 @@ publishing { create("mavenJava") { from(components["java"]) - artifact(tasks.named("sourcesJar")) - artifact(tasks.named("javadocJar")) + artifact(tasks.named("sourcesJar")) { + classifier = "sources" + } + + artifact(tasks.named("javadocJar")) { + classifier = "javadoc" + } groupId = "org.pcre4j" artifactId = project.name @@ -74,6 +79,15 @@ publishing { } repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/" + System.getenv("GITHUB_REPOSITORY")) + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + mavenCentral { credentials { username = findProperty("pcre4j.mavenCentral.user") as String? ?: ""