Skip to content

Commit 5a68941

Browse files
committed
sync workflows
1 parent 2bade5f commit 5a68941

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

.github/workflows/publish-sdk.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,39 @@ on:
55
types: [published]
66

77
env:
8-
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
9-
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
108
CI: true
119

1210
jobs:
1311
publish:
1412
runs-on: ubuntu-latest
13+
env:
14+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
15+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
16+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
17+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
18+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
19+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1520
steps:
1621
- uses: actions/checkout@v4
1722
with:
1823
fetch-depth: 0
1924

20-
- name: Set up Maven Central Repository
25+
- name: Set up JDK 8
2126
uses: actions/setup-java@v4
2227
with:
2328
java-version: '8'
2429
distribution: 'temurin'
25-
server-id: ossrh
2630
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
2731
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
2832

2933
- name: Download test data
3034
run: make test-data
3135

32-
- name: Publish package to Maven Central
33-
run: ./gradlew check publish --no-daemon
34-
env:
35-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
36-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
36+
- name: Test
37+
run: ./gradlew check
38+
39+
- name: Stage artifacts
40+
run: ./gradlew clean publish -Prelease
41+
42+
- name: Deploy to Maven Central
43+
run: ./gradlew jreleaserDeploy

.github/workflows/publish-snapshot.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,20 @@ jobs:
2424
with:
2525
fetch-depth: 0
2626

27-
- name: Set up JDK 17
27+
- name: Set up JDK 8
2828
uses: actions/setup-java@v4
2929
with:
3030
java-version: 17
3131
distribution: 'adopt'
3232
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
3333
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
3434

35-
- name: Set up JDK 8
36-
uses: actions/setup-java@v4
37-
with:
38-
java-version: '8'
39-
distribution: 'temurin'
40-
4135
- name: Download test data
4236
run: make test-data
4337

4438
- name: Test
4539
run: ./gradlew check
4640

47-
- name: Verify JReleaser
48-
run: ./gradlew jreleaserConfig
49-
5041
- name: Stage artifacts
5142
run: ./gradlew clean publish -Psnapshot
5243

build.gradle

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ java {
1111
}
1212

1313
group = 'cloud.eppo'
14-
version = '5.2.1-SNAPSHOT'
14+
version = '5.2.1'
1515
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
1616

1717
import org.apache.tools.ant.filters.ReplaceTokens
@@ -161,6 +161,29 @@ jreleaser {
161161
}
162162
}
163163

164+
165+
// Custom task to ensure we can conditionally publish either a release or snapshot artifact
166+
// based on a command line switch. See github workflow files for more details on usage.
167+
tasks.register('checkVersion') {
168+
doLast {
169+
if (!project.hasProperty('release') && !project.hasProperty('snapshot')) {
170+
throw new GradleException("You must specify either -Prelease or -Psnapshot")
171+
}
172+
if (project.hasProperty('release') && project.version.endsWith('SNAPSHOT')) {
173+
throw new GradleException("You cannot specify -Prelease with a SNAPSHOT version")
174+
}
175+
if (project.hasProperty('snapshot') && !project.version.endsWith('SNAPSHOT')) {
176+
throw new GradleException("You cannot specify -Psnapshot with a non-SNAPSHOT version")
177+
}
178+
project.ext.shouldPublish = true
179+
}
180+
}
181+
182+
// Ensure checkVersion runs before publishing
183+
tasks.named('publish').configure {
184+
dependsOn checkVersion
185+
}
186+
164187
javadoc {
165188
if (JavaVersion.current().isJava9Compatible()) {
166189
options.addBooleanOption('html5', true)

0 commit comments

Comments
 (0)