|
1 | 1 | #!/bin/bash |
2 | 2 |
|
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 | +} |
5 | 41 |
|
| 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" |
6 | 47 | 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