Skip to content

Commit 58222ee

Browse files
authored
chore: Update kokoro build script to push to Maven (#157)
* chore: update build script to push to Maven * print out the current dir * comment on the gpg keybox file * add more mvn flags
1 parent 1845551 commit 58222ee

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

.kokoro/release.cfg

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ build_file: "functions-framework-java/.kokoro/release.sh"
22

33
before_action {
44
fetch_keystore {
5+
keystore_resource {
6+
keystore_config_id: 75669
7+
keyname: "functions-framework-java-release-bot-gpg-pubring"
8+
}
59
keystore_resource {
610
keystore_config_id: 75669
711
keyname: "functions-framework-java-release-bot-gpg-passphrase"
@@ -11,4 +15,4 @@ before_action {
1115
keyname: "functions-framework-java-release-bot-sonatype-password"
1216
}
1317
}
14-
}
18+
}

.kokoro/release.sh

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,65 @@
11
#!/bin/bash
22

3-
# Make sure `JAVA_HOME` is set.
4-
echo "JAVA_HOME=$JAVA_HOME"
3+
# Get secrets from keystore and set and environment variables.
4+
setup_environment_secrets() {
5+
export SONATYPE_USERNAME=functions-framework-release-bot
6+
export SONATYPE_PASSWORD=$(cat ${KOKORO_KEYSTORE_DIR}/75669_functions-framework-java-release-bot-sonatype-password)
7+
export GPG_PASSPHRASE=$(cat ${KOKORO_KEYSTORE_DIR}/75669_functions-framework-java-release-bot-gpg-passphrase)
8+
9+
# Add the keybox file to $GNUPGHOME to verify the GPG credentials.
10+
export GNUPGHOME=/tmp/gpg
11+
mkdir $GNUPGHOME
12+
mv ${KOKORO_KEYSTORE_DIR}/75669_functions-framework-java-release-bot-gpg-pubring $GNUPGHOME/pubring.kbx
13+
}
14+
15+
create_settings_xml_file() {
16+
echo "<settings>
17+
<profiles>
18+
<profile>
19+
<activation>
20+
<activeByDefault>true</activeByDefault>
21+
</activation>
22+
<properties>
23+
<gpg.passphrase>${GPG_PASSPHRASE}</gpg.passphrase>
24+
</properties>
25+
</profile>
26+
</profiles>
27+
<servers>
28+
<server>
29+
<id>sonatype-nexus-staging</id>
30+
<username>${SONATYPE_USERNAME}</username>
31+
<password>${SONATYPE_PASSWORD}</password>
32+
</server>
33+
<server>
34+
<id>sonatype-nexus-snapshots</id>
35+
<username>${SONATYPE_USERNAME}</username>
36+
<password>${SONATYPE_PASSWORD}</password>
37+
</server>
38+
</servers>
39+
</settings>" > $1
40+
}
541

42+
setup_environment_secrets
43+
44+
# Pick the right package to release based on the Kokoro job name.
45+
cd ${KOKORO_ARTIFACTS_DIR}/github/functions-framework-java
46+
create_settings_xml_file "settings.xml"
647
echo "KOKORO_JOB_NAME=${KOKORO_JOB_NAME}"
48+
if [[ $KOKORO_JOB_NAME == *"function-maven-plugin"* ]]; then
49+
cd function-maven-plugin
50+
elif [[ $KOKORO_JOB_NAME == *"functions-framework-api"* ]]; then
51+
cd functions-framework-api
52+
else
53+
cd invoker
54+
fi
55+
echo "pwd=$(pwd)"
56+
57+
# Make sure `JAVA_HOME` is set and using jdk11.
58+
sudo update-java-alternatives --set java-1.11.0-openjdk-amd64
59+
echo "JAVA_HOME=$JAVA_HOME"
60+
mvn clean deploy -B \
61+
-P sonatype-oss-release \
62+
--settings=../settings.xml \
63+
-Dgpg.executable=gpg \
64+
-Dgpg.passphrase=${GPG_PASSPHRASE} \
65+
-Dgpg.homedir=${GNUPGHOME}

0 commit comments

Comments
 (0)