Skip to content

Commit ffd69c5

Browse files
chore: Add initial codebuild specs for automating release (#243)
For now, these specs only deal with validation. However, I'm using the structure that includes a place for the release itself (currently a no-op) so that we can easily add that once we're ready.
1 parent 79f0b63 commit ffd69c5

File tree

5 files changed

+210
-0
lines changed

5 files changed

+210
-0
lines changed

codebuild/release/release-prod.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: 0.2
2+
3+
env:
4+
secrets-manager:
5+
SONA_USERNAME: Sonatype-Team-Account:Username
6+
SONA_PASS: Sonatype-Team-Account:Password
7+
8+
phases:
9+
install:
10+
runtime-versions:
11+
java: openjdk8
12+
pre_build:
13+
commands:
14+
- git checkout $COMMIT_ID
15+
- FOUND_VERSION=$(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
16+
- |
17+
if expr ${FOUND_VERSION} != ${VERSION}; then
18+
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
19+
exit 1;
20+
fi
21+
build:
22+
commands:
23+
- echo "Doing nothing, release step is currently a no-op"
24+
25+
26+
batch:
27+
fast-fail: false
28+
build-graph:
29+
- identifier: release_to_prod
30+
- identifier: validate_prod_release_openjdk8
31+
depend-on:
32+
- release_to_prod
33+
buildspec: codebuild/release/validate-prod.yml
34+
env:
35+
variables:
36+
JAVA_ENV_VERSION: openjdk8
37+
JAVA_NUMERIC_VERSION: 8
38+
image: aws/codebuild/standard:3.0
39+
- identifier: validate_prod_release_openjdk11
40+
depend-on:
41+
- release_to_prod
42+
buildspec: codebuild/release/validate-prod.yml
43+
env:
44+
variables:
45+
JAVA_ENV_VERSION: openjdk11
46+
JAVA_NUMERIC_VERSION: 11
47+
image: aws/codebuild/standard:3.0
48+
- identifier: validate_prod_release_corretto8
49+
depend-on:
50+
- release_to_prod
51+
buildspec: codebuild/release/validate-prod.yml
52+
env:
53+
variables:
54+
JAVA_ENV_VERSION: corretto8
55+
JAVA_NUMERIC_VERSION: 8
56+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
57+
- identifier: validate_prod_release_corretto11
58+
depend-on:
59+
- release_to_prod
60+
buildspec: codebuild/release/validate-prod.yml
61+
env:
62+
variables:
63+
JAVA_ENV_VERSION: corretto11
64+
JAVA_NUMERIC_VERSION: 11
65+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

codebuild/release/release-staging.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: 0.2
2+
3+
env:
4+
secrets-manager:
5+
SONA_USERNAME: Sonatype-Team-Account:Username
6+
SONA_PASS: Sonatype-Team-Account:Password
7+
8+
phases:
9+
install:
10+
runtime-versions:
11+
java: openjdk8
12+
pre_build:
13+
commands:
14+
- git checkout $COMMIT_ID
15+
- FOUND_VERSION=$(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
16+
- |
17+
if expr ${FOUND_VERSION} != ${VERSION}; then
18+
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
19+
exit 1;
20+
fi
21+
build:
22+
commands:
23+
- echo "Doing nothing, release step is currently a no-op"
24+
25+
26+
batch:
27+
fast-fail: false
28+
build-graph:
29+
- identifier: release_to_staging
30+
- identifier: validate_staging_release_openjdk8
31+
depend-on:
32+
- release_to_staging
33+
buildspec: codebuild/release/validate-staging.yml
34+
env:
35+
variables:
36+
JAVA_ENV_VERSION: openjdk8
37+
JAVA_NUMERIC_VERSION: 8
38+
image: aws/codebuild/standard:3.0
39+
- identifier: validate_staging_release_openjdk11
40+
depend-on:
41+
- release_to_staging
42+
buildspec: codebuild/release/validate-staging.yml
43+
env:
44+
variables:
45+
JAVA_ENV_VERSION: openjdk11
46+
JAVA_NUMERIC_VERSION: 11
47+
image: aws/codebuild/standard:3.0
48+
- identifier: validate_staging_release_corretto8
49+
depend-on:
50+
- release_to_staging
51+
buildspec: codebuild/release/validate-staging.yml
52+
env:
53+
variables:
54+
JAVA_ENV_VERSION: corretto8
55+
JAVA_NUMERIC_VERSION: 8
56+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
57+
- identifier: validate_staging_release_corretto11
58+
depend-on:
59+
- release_to_staging
60+
buildspec: codebuild/release/validate-staging.yml
61+
env:
62+
variables:
63+
JAVA_ENV_VERSION: corretto11
64+
JAVA_NUMERIC_VERSION: 11
65+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

codebuild/release/settings.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
</servers>
12+
13+
<profiles>
14+
<profile>
15+
<id>codeartifact</id>
16+
<repositories>
17+
<repository>
18+
<id>codeartifact</id>
19+
<name>codeartifact</name>
20+
<url>${codeartifact.url}</url> <!-- passed via command line to avoid hardcoding it here -->
21+
</repository>
22+
</repositories>
23+
</profile>
24+
</profiles>
25+
26+
</settings>

codebuild/release/validate-prod.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
java: $JAVA_ENV_VERSION
7+
pre_build:
8+
commands:
9+
- git clone https://github.com/aws-samples/busy-engineers-document-bucket.git
10+
- cd busy-engineers-document-bucket/exercises/java/encryption-context-complete
11+
build:
12+
commands:
13+
- |
14+
mvn verify \
15+
-Dcheckstyle.skip \
16+
-Desdk.version=$VERSION \
17+
-Dmaven.compiler.target=$JAVA_NUMERIC_VERSION \
18+
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 0.2
2+
3+
env:
4+
variables:
5+
REGION: us-east-1
6+
DOMAIN: crypto-tools-internal
7+
REPOSITORY: java-esdk-staging
8+
parameter-store:
9+
ACCOUNT: /CodeBuild/AccountId
10+
11+
phases:
12+
install:
13+
commands:
14+
- pip install awscli
15+
runtime-versions:
16+
java: $JAVA_ENV_VERSION
17+
pre_build:
18+
commands:
19+
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
20+
- git clone https://github.com/aws-samples/busy-engineers-document-bucket.git
21+
- cd busy-engineers-document-bucket/exercises/java/encryption-context-complete
22+
- export CODEARTIFACT_TOKEN=$(aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $ACCOUNT --query authorizationToken --output text --region ${REGION})
23+
- export CODEARTIFACT_REPO_URL=https://${DOMAIN}-${ACCOUNT}.d.codeartifact.${REGION}.amazonaws.com/maven/${REPOSITORY}
24+
build:
25+
commands:
26+
- |
27+
mvn verify \
28+
-Pcodeartifact \
29+
-Dcheckstyle.skip \
30+
-Desdk.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
36+

0 commit comments

Comments
 (0)