Skip to content

Commit 4b19168

Browse files
authored
ci: backport codebuild release from 2.x (#229)
1 parent 156e801 commit 4b19168

8 files changed

+276
-0
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
### Maintenance
55
* Upgrade AWS SDK
66
* Upgrade build dependencies
7+
* Partially automate release process
78

89
## 1.15.1 -- 2021-02-12
910
Fixes released jar files to ensure JDK 8 compatibility.

Diff for: buildspec.yml

+5
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ batch:
2323
env:
2424
env:
2525
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
26+
- identifier: static_analysis
27+
buildspec: codebuild/static-analysis.yml
28+
env:
29+
env:
30+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

Diff for: codebuild/release/release-prod.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
version: 0.2
2+
# 'release-prod' is an AWS::CodeBuild::BuildSpec that Releases to Sonatype and then validates the release with 'validate-prod'
3+
# Command to trigger this codebuild from an authorized command line.
4+
# aws codebuild start-build-batch \
5+
# --region us-west-2 \
6+
# --project-name java-ddb-ec-release \
7+
# --environment-variables-override name=VERSION,value=<INSERT_VERSION>,type=PLAINTEXT name=COMMIT_ID,value=<INSERT_COMMIT_ID>,type=PLAINTEXT"
8+
9+
env:
10+
secrets-manager:
11+
GPG_KEY: Maven-GPG-Keys-Credentials:Keyname
12+
GPG_PASS: Maven-GPG-Keys-Credentials:Passphrase
13+
SONA_USERNAME: Sonatype-Team-Account:Username
14+
SONA_PASSWORD: Sonatype-Team-Account:Password
15+
16+
phases:
17+
install:
18+
runtime-versions:
19+
java: openjdk8
20+
pre_build:
21+
commands:
22+
- git checkout $COMMIT_ID
23+
- FOUND_VERSION=$(grep version sdk1/pom.xml | head -n 2 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
24+
- |
25+
if expr ${FOUND_VERSION} != ${VERSION}; then
26+
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
27+
exit 1;
28+
fi
29+
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
30+
- aws secretsmanager get-secret-value --region us-west-2 --secret-id Maven-GPG-Keys --query SecretBinary --output text | base64 -d > ~/mvn_gpg.tgz
31+
- tar -xvf ~/mvn_gpg.tgz -C ~
32+
build:
33+
commands:
34+
- |
35+
mvn deploy \
36+
-Ppublishing \
37+
-DperformRelease \
38+
-Dgpg.homedir="$HOME/mvn_gpg" \
39+
-DautoReleaseAfterClose=true \
40+
-Dgpg.keyname="$GPG_KEY" \
41+
-Dgpg.passphrase="$GPG_PASS" \
42+
-Dsonatype.username="$SONA_USERNAME" \
43+
-Dsonatype.password="$SONA_PASSWORD" \
44+
-s $SETTINGS_FILE
45+
46+
47+
batch:
48+
fast-fail: false
49+
build-graph:
50+
- identifier: release_to_prod
51+
- identifier: validate_prod_release_openjdk8
52+
depend-on:
53+
- release_to_prod
54+
buildspec: codebuild/release/validate-prod.yml
55+
env:
56+
variables:
57+
JAVA_ENV_VERSION: openjdk8
58+
JAVA_NUMERIC_VERSION: 8
59+
image: aws/codebuild/standard:3.0
60+
- identifier: validate_prod_release_openjdk11
61+
depend-on:
62+
- release_to_prod
63+
buildspec: codebuild/release/validate-prod.yml
64+
env:
65+
variables:
66+
JAVA_ENV_VERSION: openjdk11
67+
JAVA_NUMERIC_VERSION: 11
68+
image: aws/codebuild/standard:3.0
69+
- identifier: validate_prod_release_corretto8
70+
depend-on:
71+
- release_to_prod
72+
buildspec: codebuild/release/validate-prod.yml
73+
env:
74+
variables:
75+
JAVA_ENV_VERSION: corretto8
76+
JAVA_NUMERIC_VERSION: 8
77+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
78+
- identifier: validate_prod_release_corretto11
79+
depend-on:
80+
- release_to_prod
81+
buildspec: codebuild/release/validate-prod.yml
82+
env:
83+
variables:
84+
JAVA_ENV_VERSION: corretto11
85+
JAVA_NUMERIC_VERSION: 11
86+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

Diff for: codebuild/release/release-staging.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
version: 0.2
2+
# 'release-staging' is an AWS::CodeBuild::BuildSpec that Stages a release on CodeArtifact and validates the staging using 'validate-staging'
3+
# Command to trigger this codebuild from an authorized command line.
4+
# aws codebuild start-build-batch \
5+
# --region us-west-2 \
6+
# --project-name java-ddb-ec-test-release \
7+
# --environment-variables-override name=VERSION,value=<INSERT_VERSION>,type=PLAINTEXT name=COMMIT_ID,value=<INSERT_COMMIT_ID>,type=PLAINTEXT
8+
9+
env:
10+
variables:
11+
REGION: us-east-1
12+
DOMAIN: crypto-tools-internal
13+
REPOSITORY: java-ddbec-staging
14+
parameter-store:
15+
ACCOUNT: /CodeBuild/AccountId
16+
secrets-manager:
17+
GPG_KEY: Maven-GPG-Keys-Credentials:Keyname
18+
GPG_PASS: Maven-GPG-Keys-Credentials:Passphrase
19+
20+
phases:
21+
install:
22+
runtime-versions:
23+
java: openjdk8
24+
pre_build:
25+
commands:
26+
- git checkout $COMMIT_ID
27+
- FOUND_VERSION=$(grep version sdk1/pom.xml | head -n 2 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
28+
- |
29+
if expr ${FOUND_VERSION} != ${VERSION}; then
30+
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
31+
exit 1;
32+
fi
33+
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
34+
- export CODEARTIFACT_TOKEN=$(aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $ACCOUNT --query authorizationToken --output text --region ${REGION})
35+
- export CODEARTIFACT_REPO_URL=https://${DOMAIN}-${ACCOUNT}.d.codeartifact.${REGION}.amazonaws.com/maven/${REPOSITORY}
36+
- aws secretsmanager get-secret-value --region us-west-2 --secret-id Maven-GPG-Keys --query SecretBinary --output text | base64 -d > ~/mvn_gpg.tgz
37+
- tar -xvf ~/mvn_gpg.tgz -C ~
38+
build:
39+
commands:
40+
- |
41+
mvn deploy \
42+
-PpublishingCodeArtifact \
43+
-DperformRelease \
44+
-Dgpg.homedir="$HOME/mvn_gpg" \
45+
-DautoReleaseAfterClose=true \
46+
-Dgpg.keyname="$GPG_KEY" \
47+
-Dgpg.passphrase="$GPG_PASS" \
48+
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
49+
-DaltDeploymentRepository=codeartifact::default::$CODEARTIFACT_REPO_URL \
50+
-s $SETTINGS_FILE
51+
52+
batch:
53+
fast-fail: false
54+
build-graph:
55+
- identifier: release_to_staging
56+
- identifier: validate_staging_release_openjdk8
57+
depend-on:
58+
- release_to_staging
59+
buildspec: codebuild/release/validate-staging.yml
60+
env:
61+
variables:
62+
JAVA_ENV_VERSION: openjdk8
63+
JAVA_NUMERIC_VERSION: 8
64+
image: aws/codebuild/standard:3.0
65+
- identifier: validate_staging_release_openjdk11
66+
depend-on:
67+
- release_to_staging
68+
buildspec: codebuild/release/validate-staging.yml
69+
env:
70+
variables:
71+
JAVA_ENV_VERSION: openjdk11
72+
JAVA_NUMERIC_VERSION: 11
73+
image: aws/codebuild/standard:3.0
74+
- identifier: validate_staging_release_corretto8
75+
depend-on:
76+
- release_to_staging
77+
buildspec: codebuild/release/validate-staging.yml
78+
env:
79+
variables:
80+
JAVA_ENV_VERSION: corretto8
81+
JAVA_NUMERIC_VERSION: 8
82+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
83+
- identifier: validate_staging_release_corretto11
84+
depend-on:
85+
- release_to_staging
86+
buildspec: codebuild/release/validate-staging.yml
87+
env:
88+
variables:
89+
JAVA_ENV_VERSION: corretto11
90+
JAVA_NUMERIC_VERSION: 11
91+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

Diff for: codebuild/release/settings.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
4+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
5+
<servers>
6+
<server>
7+
<id>codeartifact</id>
8+
<username>aws</username>
9+
<password>${codeartifact.token}</password>
10+
</server>
11+
<server>
12+
<id>sonatype-nexus-staging</id>
13+
<username>${sonatype.username}</username>
14+
<password>${sonatype.password}</password>
15+
</server>
16+
</servers>
17+
18+
<profiles>
19+
<profile>
20+
<id>codeartifact</id>
21+
<repositories>
22+
<repository>
23+
<id>codeartifact</id>
24+
<name>codeartifact</name>
25+
<url>${codeartifact.url}</url> <!-- passed via command line to avoid hardcoding it here -->
26+
</repository>
27+
</repositories>
28+
</profile>
29+
</profiles>
30+
31+
</settings>

Diff for: codebuild/release/validate-prod.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 0.2
2+
# 'validate-prod' is an AWS::CodeBuild::BuildSpec that validates a Sonatype release against the examples
3+
4+
phases:
5+
install:
6+
runtime-versions:
7+
java: $JAVA_ENV_VERSION
8+
pre_build:
9+
commands:
10+
- cd examples
11+
build:
12+
commands:
13+
- |
14+
mvn verify \
15+
-Dcheckstyle.skip \
16+
-Dddbec.version=$VERSION \
17+
-Dmaven.compiler.target=$JAVA_NUMERIC_VERSION \
18+
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION

Diff for: codebuild/release/validate-staging.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 0.2
2+
# 'validate-staging' is an AWS::CodeBuild::BuildSpec that validates artifacts from CodeArtifact against the examples
3+
4+
env:
5+
variables:
6+
REGION: us-east-1
7+
DOMAIN: crypto-tools-internal
8+
REPOSITORY: java-ddbec-staging
9+
parameter-store:
10+
ACCOUNT: /CodeBuild/AccountId
11+
12+
phases:
13+
install:
14+
commands:
15+
- pip install awscli
16+
runtime-versions:
17+
java: $JAVA_ENV_VERSION
18+
pre_build:
19+
commands:
20+
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
21+
- export CODEARTIFACT_TOKEN=$(aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $ACCOUNT --query authorizationToken --output text --region ${REGION})
22+
- export CODEARTIFACT_REPO_URL=https://${DOMAIN}-${ACCOUNT}.d.codeartifact.${REGION}.amazonaws.com/maven/${REPOSITORY}
23+
- cd examples
24+
build:
25+
commands:
26+
- |
27+
mvn verify \
28+
-Pcodeartifact \
29+
-Dcheckstyle.skip \
30+
-Dddbec.version=$VERSION \
31+
-Dmaven.compiler.target=$JAVA_NUMERIC_VERSION \
32+
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION \
33+
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
34+
-Dcodeartifact.url=$CODEARTIFACT_REPO_URL \
35+
-s $SETTINGS_FILE

Diff for: codebuild/static-analysis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
java: corretto11
7+
build:
8+
commands:
9+
- mvn com.coveo:fmt-maven-plugin:check

0 commit comments

Comments
 (0)