Skip to content

Commit

Permalink
(chore) sign; publish on release
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-pelykh committed Jun 19, 2024
1 parent 4e2e79f commit 852474a
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ jobs:

- name: Publish
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository -Ppcre4j.version=main-SNAPSHOT
86 changes: 86 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release

on:
release:
types:
- published

jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest ]
java-distribution:
- temurin
- zulu
- adopt-hotspot
- adopt-openj9
- liberica
- microsoft
- corretto
- semeru
- oracle
- dragonwell
fail-fast: false

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up "${{ matrix.java-distribution }}" JDK 21
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.java-distribution }}
java-version: 21

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}

- name: Install PCRE (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install -y libpcre2-8-0

- name: Build with Gradle (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: ./gradlew build -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu

- name: Run tests (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: ./gradlew test -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu

publish:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

needs:
- build

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- name: Publish
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
run: ./gradlew publish -Ppcre4j.version=${{ github.event.release.tag_name }}
17 changes: 14 additions & 3 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
plugins {
`java-library`
`maven-publish`
`signing`
}

repositories {
Expand Down Expand Up @@ -79,11 +80,21 @@ publishing {
}
}

mavenCentral {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = findProperty("pcre4j.mavenCentral.user") as String? ?: ""
password = findProperty("pcre4j.mavenCentral.password") as String? ?: ""
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PASSPHRASE")
)
sign(publishing.publications["mavenJava"])
}
17 changes: 14 additions & 3 deletions ffm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
plugins {
`java-library`
`maven-publish`
`signing`
}

repositories {
Expand Down Expand Up @@ -100,11 +101,21 @@ publishing {
}
}

mavenCentral {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = findProperty("pcre4j.mavenCentral.user") as String? ?: ""
password = findProperty("pcre4j.mavenCentral.password") as String? ?: ""
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PASSPHRASE")
)
sign(publishing.publications["mavenJava"])
}
17 changes: 14 additions & 3 deletions jna/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
plugins {
`java-library`
`maven-publish`
`signing`
}

repositories {
Expand Down Expand Up @@ -83,11 +84,21 @@ publishing {
}
}

mavenCentral {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = findProperty("pcre4j.mavenCentral.user") as String? ?: ""
password = findProperty("pcre4j.mavenCentral.password") as String? ?: ""
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PASSPHRASE")
)
sign(publishing.publications["mavenJava"])
}
17 changes: 14 additions & 3 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
plugins {
`java-library`
`maven-publish`
`signing`
}

repositories {
Expand Down Expand Up @@ -80,11 +81,21 @@ publishing {
}
}

mavenCentral {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = findProperty("pcre4j.mavenCentral.user") as String? ?: ""
password = findProperty("pcre4j.mavenCentral.password") as String? ?: ""
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PASSPHRASE")
)
sign(publishing.publications["mavenJava"])
}

0 comments on commit 852474a

Please sign in to comment.