Skip to content

Commit 0845a1c

Browse files
feat: Maven central
1 parent 96ab650 commit 0845a1c

2 files changed

Lines changed: 39 additions & 44 deletions

File tree

.github/workflows/publish.yml

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
1-
name: Publish
2-
1+
name: "Release"
32
on:
43
release:
5-
types: [created]
6-
4+
types:
5+
- "released"
76
jobs:
8-
publish:
9-
runs-on: ubuntu-latest
10-
permissions:
11-
contents: read
12-
packages: write
13-
7+
build:
8+
name: "Release"
9+
runs-on: "ubuntu-latest"
1410
steps:
15-
- name: Checkout Code
16-
uses: actions/checkout@v4
11+
- uses: "actions/checkout@master"
1712

18-
- name: Set up JDK
19-
uses: actions/setup-java@v4
13+
- uses: "graalvm/setup-graalvm@v1"
2014
with:
21-
java-version: '21'
22-
distribution: 'temurin'
23-
24-
- name: Extract version from tag
25-
id: extract_version
26-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
15+
java-version: "21"
16+
distribution: "graalvm-community"
17+
github-token: ${{ secrets.GITHUB_TOKEN }}
18+
cache: "gradle"
2719

28-
- name: Publish to GitHub Packages
29-
uses: gradle/gradle-build-action@v2
20+
- uses: "actions/cache@master"
3021
with:
31-
arguments: publish
22+
path: |
23+
~/.gradle/caches
24+
~/.gradle/wrapper
25+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle.kts') }}
26+
restore-keys: |
27+
${{ runner.os }}-gradle-
28+
- name: Publish
3229
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
30+
GPG_KEY: ${{ secrets.GPG_KEY }}
31+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
32+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
33+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
34+
run: |
35+
[[ "${{ github.event.release.tag_name }}" =~ ^[0-9]+(\.[0-9]+)*$ ]] || exit -1
36+
chmod +x gradlew
37+
./gradlew publishToCentralPortal -Pversion="${{ github.event.release.tag_name }}"

build.gradle.kts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import net.thebugmc.gradle.sonatypepublisher.PublishingType
12

23
plugins {
34
id("studio.o7.remora") version "0.0.9"
5+
id("net.thebugmc.gradle.sonatype-central-portal-publisher") version "1.2.4"
46
}
57

68
remora {
@@ -21,24 +23,14 @@ dependencies {
2123

2224
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
2325

24-
publishing {
25-
publications {
26-
create<MavenPublication>("gpr") {
27-
from(components["java"])
28-
groupId = "studio.o7"
29-
artifactId = "agones-sdk"
30-
version = System.getenv("RELEASE_VERSION") ?: "unspecified"
31-
}
32-
}
26+
centralPortal {
27+
username = System.getenv("SONATYPE_USERNAME")
28+
password = System.getenv("SONATYPE_PASSWORD")
29+
name = remora.artifactId
30+
publishingType = PublishingType.USER_MANAGED
31+
}
3332

34-
repositories {
35-
maven {
36-
name = "GitHubPackages"
37-
url = uri("https://maven.pkg.github.com/o7studios/agones-java-sdk")
38-
credentials {
39-
username = System.getenv("GITHUB_ACTOR")
40-
password = System.getenv("GITHUB_TOKEN")
41-
}
42-
}
43-
}
33+
signing {
34+
useInMemoryPgpKeys(System.getenv("GPG_KEY"), System.getenv("GPG_PASSPHRASE"))
35+
sign(publishing.publications)
4436
}

0 commit comments

Comments
 (0)