Skip to content

Commit 11f6b03

Browse files
committed
chore: Automate maven release (#4)
* chore: Automate Maven Release
1 parent f9d067e commit 11f6b03

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

.github/workflows/maven_release.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 'Release to Maven'
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
ubuntu-latest-aurora-release-to-maven:
10+
name: 'Build And Release to Maven'
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: 'Clone Repository'
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 50
17+
- name: 'Set up JDK 8'
18+
uses: actions/setup-java@v1
19+
with:
20+
java-version: 8
21+
- name: 'Build Driver'
22+
run: |
23+
./gradlew --no-parallel --no-daemon -x test assemble
24+
- name: "Decode Key Ring"
25+
run: |
26+
echo "${{secrets.GPG_SECRET_KEY_FILE}}" > ~/.gradle/secring.gpg.b64
27+
base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg
28+
- name: 'Install GPG Secret Key'
29+
id: import_gpg
30+
uses: crazy-max/ghaction-import-gpg@v4
31+
with:
32+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
33+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
34+
- name: 'Publish to Maven'
35+
run: |
36+
./gradlew --no-parallel --no-daemon publishAllPublicationsToOSSRHRepository -Psigning.keyId=${{secrets.GPG_KEY_ID}} -Psigning.password=${{secrets.GPG_PASSPHRASE}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg)
37+
env:
38+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
39+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

.github/workflows/release.yml renamed to .github/workflows/release_draft.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: 'Release Driver'
1+
name: 'Release Draft'
22

33
on:
44
push:
55
tags:
6-
- '*'
6+
- '[0-9]+.[0-9]+.[0-9]+'
77

88
permissions:
99
actions: write
@@ -29,7 +29,7 @@ jobs:
2929
S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
3030
with:
3131
job-id: jdk8
32-
arguments: --no-parallel --no-daemon jandex -x test build
32+
arguments: --no-parallel --no-daemon jandex -x test assemble
3333
- name: 'Set Version Env Variable'
3434
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
3535
- name: 'Get Release Details'

build.gradle.kts

+29-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import org.postgresql.buildtools.JavaCommentPreprocessorTask
1818

1919
plugins {
2020
publishing
21+
signing
2122
// Verification
2223
checkstyle
2324
jacoco
@@ -287,7 +288,7 @@ allprojects {
287288
// Some of the projects might fail to create a file (e.g. no tests or no coverage),
288289
// So we check for file existence. Otherwise JacocoMerge would fail
289290
val execFiles =
290-
files(testTasks, javaExecTasks).filter { it.exists() && it.name.endsWith(".exec") }
291+
files(testTasks, javaExecTasks).filter { it.exists() && it.name.endsWith(".exec") }
291292
executionData(execFiles)
292293
}
293294

@@ -550,8 +551,8 @@ allprojects {
550551
}
551552
}
552553
for (p in listOf("server", "port", "database", "username", "password",
553-
"privilegedUser", "privilegedPassword",
554-
"simpleProtocolOnly", "enable_ssl_tests")) {
554+
"privilegedUser", "privilegedPassword",
555+
"simpleProtocolOnly", "enable_ssl_tests")) {
555556
passProperty(p)
556557
}
557558
}
@@ -610,13 +611,25 @@ allprojects {
610611
forEach { artifact(it) }
611612
}
612613
}
614+
615+
apply(plugin = "signing")
616+
signing {
617+
if (project.hasProperty("signing.keyId") &&
618+
project.property("signing.keyId") != "" &&
619+
project.hasProperty("signing.password") &&
620+
project.property("signing.password") != "" &&
621+
project.hasProperty("signing.secretKeyRingFile") &&
622+
project.property("signing.secretKeyRingFile") != "") {
623+
sign(publishing.publications[project.name])
624+
}
625+
}
613626
}
614627
// </editor-fold>
615628
// <editor-fold defaultstate="collapsed" desc="Configuration of the published pom.xml">
616629
create<MavenPublication>(project.name) {
617630
groupId = "software.aws.rds"
618631
artifactId = "aws-postgresql-jdbc"
619-
version = "0.1.0"
632+
version = buildVersion
620633
from(components["java"])
621634

622635
// Gradle feature variants can't be mapped to Maven's pom
@@ -654,6 +667,18 @@ allprojects {
654667
}
655668
// </editor-fold>
656669
}
670+
repositories {
671+
maven {
672+
name = "OSSRH"
673+
url = uri("https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/")
674+
credentials {
675+
username = System.getenv("MAVEN_USERNAME")
676+
password = System.getenv("MAVEN_PASSWORD")
677+
}
678+
}
679+
680+
mavenLocal()
681+
}
657682
}
658683
}
659684
}

pgjdbc/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ tasks.shadowJar {
210210

211211
tasks.register<Jar>("cleanShadowJar") {
212212

213-
archiveClassifier.set("all")
214213
dependsOn("shadowJar")
215214
includeEmptyDirs = false
216215

0 commit comments

Comments
 (0)