Skip to content

Commit f1acae4

Browse files
authored
feat: release gradle plugin (#975)
* feat: release gradle plugin * change comment * specify version in build.gradle * setup maven-publish plugin * change working dir for gradle plugin * change gradle command * export gpg_key_id
1 parent 6b7c42a commit f1acae4

File tree

8 files changed

+64
-12
lines changed

8 files changed

+64
-12
lines changed

.kokoro/common.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ setup_environment_secrets() {
2525
mkdir "${GPG_HOMEDIR}"
2626
mv "${KOKORO_KEYSTORE_DIR}"/70247_maven-gpg-pubkeyring "${GPG_HOMEDIR}"/pubring.gpg
2727
mv "${KOKORO_KEYSTORE_DIR}"/70247_maven-gpg-keyring "${GPG_HOMEDIR}"/secring.gpg
28+
GPG_KEY_ID=$(echo -n "$(gpg --with-colons "${GPG_HOMEDIR}"/pubring.gpg | awk -F':' '/pub/{ print $5 }')")
29+
export GPG_KEY_ID
2830
SONATYPE_USERNAME=$(cat "${KOKORO_KEYSTORE_DIR}"/70247_sonatype-credentials | cut -f1 -d'|')
2931
export SONATYPE_USERNAME
3032
SONATYPE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}"/70247_sonatype-credentials | cut -f2 -d'|')
@@ -52,3 +54,14 @@ create_settings_xml_file() {
5254
</servers>
5355
</settings>" > "$1"
5456
}
57+
58+
create_gradle_properties_file() {
59+
echo "
60+
signing.gnupg.executable=gpg
61+
signing.gnupg.homeDir=${GPG_HOMEDIR}
62+
signing.gnupg.keyName=${GPG_KEY_ID}
63+
signing.gnupg.passphrase=${GPG_PASSPHRASE}
64+
65+
ossrhUsername=${SONATYPE_USERNAME}
66+
ossrhPassword=${SONATYPE_PASSWORD}" > $1
67+
}

.kokoro/release_build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ mvn -Prelease -B -U verify -Dtest=!FilePermissionsTest -Dorg.slf4j.simpleLogger.
1717
ARTIFACT_ID=$(mvn -B help:evaluate -Dexpression=project.artifactId 2>/dev/null | grep -v "^\[")
1818
PROJECT_VERSION=$(mvn -B help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[")
1919
cp pom.xml target/${ARTIFACT_ID}-${PROJECT_VERSION}.pom
20-

.kokoro/stage.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,15 @@ else
6464
echo "AUTORELEASE_PR environment variable is not set (probably testing something). Not promoting the staged repository."
6565
fi
6666

67-
popd
67+
# release app-gradle-plugin
68+
GRADLE_SETTING_FILE=$(realpath .)/app-gradle-plugin/gradle.properties
69+
create_gradle_properties_file "${GRADLE_SETTING_FILE}"
70+
pushd app-gradle-plugin
71+
if [[ -n "${AUTORELEASE_PR}" ]]; then
72+
./gradlew publishMavenJavaPublicationToMavenRepository
73+
echo "Successfully finished './gradlew publishMavenJavaPublicationToMavenRepository'"
74+
else
75+
./gradlew publishMavenJavaPublicationToMavenLocal
76+
fi
77+
popd # app-gradle-plugin
78+
popd # repository root

app-gradle-plugin/build.gradle.kts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import net.researchgate.release.GitAdapter.GitConfig
22
import java.util.Date
33
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
4+
import java.beans.EventHandler.create
45

56
/*
67
* Copyright 2022 Google LLC. All Rights Reserved.
@@ -19,6 +20,9 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
1920
*
2021
*/
2122

23+
group = "com.google.cloud.tools"
24+
version = "2.5.2-SNAPSHOT" // {x-version-update:app-gradle-plugin:current}
25+
2226
plugins {
2327
id("java")
2428
id("maven")
@@ -27,6 +31,8 @@ plugins {
2731
id("com.github.sherter.google-java-format") version "0.9"
2832
id("checkstyle")
2933
id("jacoco")
34+
id("maven-publish")
35+
id("signing")
3036
}
3137

3238
repositories {
@@ -39,20 +45,17 @@ java {
3945
targetCompatibility = JavaVersion.VERSION_1_8
4046
}
4147

42-
group = "com.google.cloud.tools"
43-
4448
dependencies {
4549
implementation(localGroovy())
4650
implementation(gradleApi())
47-
api("com.google.cloud.tools:appengine-plugins-core:0.10.1") // {x-version-update:appengine-plugins-core:current}
51+
api("com.google.cloud.tools:appengine-plugins-core:0.10.2-SNAPSHOT") // {x-version-update:appengine-plugins-core:current}
4852

4953
testImplementation("commons-io:commons-io:2.11.0")
5054
testImplementation("junit:junit:4.13.2")
5155
testImplementation("org.hamcrest:hamcrest-library:2.2")
5256
testImplementation("org.mockito:mockito-core:4.11.0")
5357
}
5458

55-
5659
tasks.wrapper {
5760
gradleVersion = "6.9"
5861
}
@@ -194,6 +197,32 @@ release {
194197
requireBranch = """^release-v\d+.*$""" //regex
195198
}
196199
}
200+
201+
publishing {
202+
publications {
203+
create<MavenPublication>("mavenJava") {
204+
artifactId = "appengine-gradle-plugin"
205+
from(components["java"])
206+
}
207+
}
208+
repositories {
209+
maven {
210+
url = uri("https://google.oss.sonatype.org/service/local/staging/deploy/maven2/")
211+
credentials {
212+
username = findProperty("ossrhUsername").toString()
213+
password = findProperty("ossrhPassword").toString()
214+
}
215+
}
216+
}
217+
}
218+
219+
signing {
220+
setRequired({ gradle.taskGraph.hasTask(":${name}:publishMavenJavaPublicationToMavenRepository") })
221+
if (project.hasProperty("signing.gnupg.executable")) {
222+
useGpgCmd()
223+
}
224+
sign(publishing.publications["mavenJava"])
225+
}
197226
/* RELEASING */
198227

199228
/* FORMATTING */

app-gradle-plugin/gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

app-maven-plugin/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.google.cloud.tools</groupId>
66
<artifactId>appengine-maven-plugin</artifactId>
7-
<version>2.5.1</version><!-- {x-version-update:app-maven-plugin:current} -->
7+
<version>2.5.2-SNAPSHOT</version><!-- {x-version-update:app-maven-plugin:current} -->
88
<packaging>maven-plugin</packaging>
99

1010
<name>App Engine Maven Plugin</name>
@@ -92,7 +92,7 @@
9292
<dependency>
9393
<groupId>com.google.cloud.tools</groupId>
9494
<artifactId>appengine-plugins-core</artifactId>
95-
<version>0.10.1</version><!-- {x-version-update:appengine-plugins-core:current} -->
95+
<version>0.10.2-SNAPSHOT</version><!-- {x-version-update:appengine-plugins-core:current} -->
9696
</dependency>
9797

9898
<dependency>

appengine-plugins-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.google.cloud.tools</groupId>
66
<artifactId>appengine-plugins-core</artifactId>
7-
<version>0.10.1</version><!-- {x-version-update:appengine-plugins-core:current} -->
7+
<version>0.10.2-SNAPSHOT</version><!-- {x-version-update:appengine-plugins-core:current} -->
88

99
<name>App Engine Plugins Core Library</name>
1010
<description>

versions.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Format:
22
# module:released-version:current-version
33

4-
appengine-plugins-core:0.10.0:0.10.1
5-
app-maven-plugin:2.5.0:2.5.1
4+
appengine-plugins-core:0.10.1:0.10.2-SNAPSHOT
5+
app-maven-plugin:2.5.1:2.5.2-SNAPSHOT
6+
app-gradle-plugin:2.5.0:2.5.2-SNAPSHOT

0 commit comments

Comments
 (0)