Skip to content

chore: Automate staging and production release using CodeBuild as well #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions codebuild/release/release-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ version: 0.2

env:
secrets-manager:
GPG_KEY: Maven-GPG-Keys-Credentials:Keyname
GPG_PASS: Maven-GPG-Keys-Credentials:Passphrase
SONA_USERNAME: Sonatype-Team-Account:Username
SONA_PASS: Sonatype-Team-Account:Password
SONA_PASSWORD: Sonatype-Team-Account:Password

phases:
install:
runtime-versions:
java: openjdk8
java: openjdk11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity, per offline discussion: since the validation in these release steps is testing against all supported versions of Java (8 and 11, corretto and openjdk), bumping to 11 for the actual building of artifacts is a reasonable update.

pre_build:
commands:
- git checkout $COMMIT_ID
Expand All @@ -18,9 +20,23 @@ phases:
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
exit 1;
fi
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
- aws secretsmanager get-secret-value --region us-west-2 --secret-id Maven-GPG-Keys --query SecretBinary --output text | base64 -d > ~/mvn_gpg.tgz
- tar -xvf ~/mvn_gpg.tgz -C ~
build:
commands:
- echo "Doing nothing, release step is currently a no-op"
- |
mvn deploy \
-Ppublishing \
-Pfast-tests-only \
-DperformRelease \
-Dgpg.homedir="$HOME/mvn_gpg" \
-DautoReleaseAfterClose=true \
-Dgpg.keyname="$GPG_KEY" \
-Dgpg.passphrase="$GPG_PASS" \
-Dsonatype.username="$SONA_USERNAME" \
-Dsonatype.password="$SONA_PASSWORD" \
-s $SETTINGS_FILE


batch:
Expand Down
31 changes: 26 additions & 5 deletions codebuild/release/release-staging.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
version: 0.2

env:
variables:
REGION: us-east-1
DOMAIN: crypto-tools-internal
REPOSITORY: java-esdk-staging
parameter-store:
ACCOUNT: /CodeBuild/AccountId
secrets-manager:
SONA_USERNAME: Sonatype-Team-Account:Username
SONA_PASS: Sonatype-Team-Account:Password
GPG_KEY: Maven-GPG-Keys-Credentials:Keyname
GPG_PASS: Maven-GPG-Keys-Credentials:Passphrase

phases:
install:
runtime-versions:
java: openjdk8
java: openjdk11
pre_build:
commands:
- git checkout $COMMIT_ID
Expand All @@ -18,10 +24,25 @@ phases:
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
exit 1;
fi
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
- export CODEARTIFACT_TOKEN=$(aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $ACCOUNT --query authorizationToken --output text --region ${REGION})
- export CODEARTIFACT_REPO_URL=https://${DOMAIN}-${ACCOUNT}.d.codeartifact.${REGION}.amazonaws.com/maven/${REPOSITORY}
- aws secretsmanager get-secret-value --region us-west-2 --secret-id Maven-GPG-Keys --query SecretBinary --output text | base64 -d > ~/mvn_gpg.tgz
- tar -xvf ~/mvn_gpg.tgz -C ~
build:
commands:
- echo "Doing nothing, release step is currently a no-op"

- |
mvn deploy \
-PpublishingCodeArtifact \
-Pfast-tests-only \
-DperformRelease \
-Dgpg.homedir="$HOME/mvn_gpg" \
-DautoReleaseAfterClose=true \
-Dgpg.keyname="$GPG_KEY" \
-Dgpg.passphrase="$GPG_PASS" \
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
-DaltDeploymentRepository=codeartifact::default::$CODEARTIFACT_REPO_URL \
-s $SETTINGS_FILE

batch:
fast-fail: false
Expand Down
5 changes: 5 additions & 0 deletions codebuild/release/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<username>aws</username>
<password>${codeartifact.token}</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>${sonatype.username}</username>
<password>${sonatype.password}</password>
</server>
</servers>

<profiles>
Expand Down