Skip to content

Commit 4b9d932

Browse files
authored
chore: release updates (#369)
1 parent 63e2f05 commit 4b9d932

8 files changed

+197
-99
lines changed

codebuild/release/release-prod.yml

+5-49
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
14
version: 0.2
25

36
env:
@@ -13,13 +16,7 @@ phases:
1316
java: openjdk11
1417
pre_build:
1518
commands:
16-
- git checkout $COMMIT_ID
17-
- FOUND_VERSION=$(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
18-
- |
19-
if expr ${FOUND_VERSION} != ${VERSION}; then
20-
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
21-
exit 1;
22-
fi
19+
- export VERSION=$(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
2320
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
2421
- aws secretsmanager get-secret-value --region us-west-2 --secret-id Maven-GPG-Keys --query SecretBinary --output text | base64 -d > ~/mvn_gpg.tgz
2522
- tar -xvf ~/mvn_gpg.tgz -C ~
@@ -38,45 +35,4 @@ phases:
3835
-Dsonatype.password="$SONA_PASSWORD" \
3936
--no-transfer-progress \
4037
-s $SETTINGS_FILE
41-
42-
43-
batch:
44-
fast-fail: false
45-
build-graph:
46-
- identifier: release_to_prod
47-
- identifier: validate_prod_release_openjdk8
48-
depend-on:
49-
- release_to_prod
50-
buildspec: codebuild/release/validate-prod.yml
51-
env:
52-
variables:
53-
JAVA_ENV_VERSION: openjdk8
54-
JAVA_NUMERIC_VERSION: 8
55-
image: aws/codebuild/standard:3.0
56-
- identifier: validate_prod_release_openjdk11
57-
depend-on:
58-
- release_to_prod
59-
buildspec: codebuild/release/validate-prod.yml
60-
env:
61-
variables:
62-
JAVA_ENV_VERSION: openjdk11
63-
JAVA_NUMERIC_VERSION: 11
64-
image: aws/codebuild/standard:3.0
65-
- identifier: validate_prod_release_corretto8
66-
depend-on:
67-
- release_to_prod
68-
buildspec: codebuild/release/validate-prod.yml
69-
env:
70-
variables:
71-
JAVA_ENV_VERSION: corretto8
72-
JAVA_NUMERIC_VERSION: 8
73-
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
74-
- identifier: validate_prod_release_corretto11
75-
depend-on:
76-
- release_to_prod
77-
buildspec: codebuild/release/validate-prod.yml
78-
env:
79-
variables:
80-
JAVA_ENV_VERSION: corretto11
81-
JAVA_NUMERIC_VERSION: 11
82-
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
38+
- ./look_4_version.sh $VERSION

codebuild/release/release-staging.yml

+9-49
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
14
version: 0.2
25

36
env:
@@ -14,23 +17,21 @@ env:
1417
phases:
1518
install:
1619
runtime-versions:
17-
java: openjdk11
20+
java: corretto11
1821
pre_build:
1922
commands:
20-
- git checkout $COMMIT_ID
21-
- FOUND_VERSION=$(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
22-
- |
23-
if expr ${FOUND_VERSION} != ${VERSION}; then
24-
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
25-
exit 1;
26-
fi
2723
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
2824
- export CODEARTIFACT_TOKEN=$(aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $ACCOUNT --query authorizationToken --output text --region ${REGION})
2925
- export CODEARTIFACT_REPO_URL=https://${DOMAIN}-${ACCOUNT}.d.codeartifact.${REGION}.amazonaws.com/maven/${REPOSITORY}
3026
- aws secretsmanager get-secret-value --region us-west-2 --secret-id Maven-GPG-Keys --query SecretBinary --output text | base64 -d > ~/mvn_gpg.tgz
3127
- tar -xvf ~/mvn_gpg.tgz -C ~
3228
build:
3329
commands:
30+
- VERSION_HASH="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-$CODEBUILD_RESOLVED_SOURCE_VERSION"
31+
# See https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
32+
- echo "Setting version in POM to $VERSION_HASH"
33+
- mvn versions:set -DnewVersion="$VERSION_HASH" --no-transfer-progress
34+
- echo "Version is now $(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')"
3435
- |
3536
mvn deploy \
3637
-PpublishingCodeArtifact \
@@ -44,44 +45,3 @@ phases:
4445
-DaltDeploymentRepository=codeartifact::default::$CODEARTIFACT_REPO_URL \
4546
--no-transfer-progress \
4647
-s $SETTINGS_FILE
47-
48-
batch:
49-
fast-fail: false
50-
build-graph:
51-
- identifier: release_to_staging
52-
- identifier: validate_staging_release_openjdk8
53-
depend-on:
54-
- release_to_staging
55-
buildspec: codebuild/release/validate-staging.yml
56-
env:
57-
variables:
58-
JAVA_ENV_VERSION: openjdk8
59-
JAVA_NUMERIC_VERSION: 8
60-
image: aws/codebuild/standard:3.0
61-
- identifier: validate_staging_release_openjdk11
62-
depend-on:
63-
- release_to_staging
64-
buildspec: codebuild/release/validate-staging.yml
65-
env:
66-
variables:
67-
JAVA_ENV_VERSION: openjdk11
68-
JAVA_NUMERIC_VERSION: 11
69-
image: aws/codebuild/standard:3.0
70-
- identifier: validate_staging_release_corretto8
71-
depend-on:
72-
- release_to_staging
73-
buildspec: codebuild/release/validate-staging.yml
74-
env:
75-
variables:
76-
JAVA_ENV_VERSION: corretto8
77-
JAVA_NUMERIC_VERSION: 8
78-
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
79-
- identifier: validate_staging_release_corretto11
80-
depend-on:
81-
- release_to_staging
82-
buildspec: codebuild/release/validate-staging.yml
83-
env:
84-
variables:
85-
JAVA_ENV_VERSION: corretto11
86-
JAVA_NUMERIC_VERSION: 11
87-
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

codebuild/release/release.yml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
4+
version: 0.2
5+
6+
batch:
7+
fast-fail: true
8+
build-graph:
9+
10+
# Release to CodeArtifact
11+
- identifier: release_staging
12+
buildspec: codebuild/release/release-staging.yml
13+
14+
# Validate CodeArtifact with supported JDK and Corretto
15+
- identifier: validate_staging_release_openjdk_8
16+
depend-on:
17+
- release_staging
18+
buildspec: codebuild/release/validate-staging.yml
19+
env:
20+
variables:
21+
JAVA_ENV_VERSION: openjdk8
22+
JAVA_NUMERIC_VERSION: 8
23+
image: aws/codebuild/standard:3.0
24+
25+
- identifier: validate_staging_release_openjdk11
26+
depend-on:
27+
- release_staging
28+
buildspec: codebuild/release/validate-staging.yml
29+
env:
30+
variables:
31+
JAVA_ENV_VERSION: openjdk11
32+
JAVA_NUMERIC_VERSION: 11
33+
image: aws/codebuild/standard:3.0
34+
35+
- identifier: validate_staging_release_corretto8
36+
depend-on:
37+
- release_staging
38+
buildspec: codebuild/release/validate-staging.yml
39+
env:
40+
variables:
41+
JAVA_ENV_VERSION: corretto8
42+
JAVA_NUMERIC_VERSION: 8
43+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
44+
45+
- identifier: validate_staging_release_corretto11
46+
depend-on:
47+
- release_staging
48+
buildspec: codebuild/release/validate-staging.yml
49+
env:
50+
variables:
51+
JAVA_ENV_VERSION: corretto11
52+
JAVA_NUMERIC_VERSION: 11
53+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
54+
55+
# Version Project
56+
- identifier: version
57+
depend-on:
58+
- release_staging
59+
- validate_staging_release_openjdk_8
60+
- validate_staging_release_openjdk11
61+
- validate_staging_release_corretto8
62+
- validate_staging_release_corretto11
63+
buildspec: codebuild/release/version.yml
64+
env:
65+
image: aws/codebuild/standard:5.0
66+
67+
# Publish to Maven Central
68+
- identifier: publish
69+
depend-on:
70+
- version
71+
buildspec: codebuild/release/release-prod.yml
72+
73+
# Validate Maven Central with supported JDK and Corretto
74+
- identifier: validate_prod_release_openjdk_8
75+
depend-on:
76+
- publish
77+
buildspec: codebuild/release/validate-prod.yml
78+
env:
79+
variables:
80+
JAVA_ENV_VERSION: openjdk8
81+
JAVA_NUMERIC_VERSION: 8
82+
image: aws/codebuild/standard:3.0
83+
84+
- identifier: validate_prod_release_openjdk11
85+
depend-on:
86+
- publish
87+
buildspec: codebuild/release/validate-prod.yml
88+
env:
89+
variables:
90+
JAVA_ENV_VERSION: openjdk11
91+
JAVA_NUMERIC_VERSION: 11
92+
image: aws/codebuild/standard:3.0
93+
94+
- identifier: validate_prod_release_corretto8
95+
depend-on:
96+
- publish
97+
buildspec: codebuild/release/validate-prod.yml
98+
env:
99+
variables:
100+
JAVA_ENV_VERSION: corretto8
101+
JAVA_NUMERIC_VERSION: 8
102+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
103+
104+
- identifier: validate_prod_release_corretto11
105+
depend-on:
106+
- publish
107+
buildspec: codebuild/release/validate-prod.yml
108+
env:
109+
variables:
110+
JAVA_ENV_VERSION: corretto11
111+
JAVA_NUMERIC_VERSION: 11
112+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

codebuild/release/settings.xml

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<!--
2+
Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
-->
15
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
26
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
37
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0

codebuild/release/validate-prod.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
14
version: 0.2
25

36
phases:

codebuild/release/validate-staging.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
14
version: 0.2
25

36
env:
@@ -16,6 +19,7 @@ phases:
1619
java: $JAVA_ENV_VERSION
1720
pre_build:
1821
commands:
22+
- VERSION_HASH="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-$CODEBUILD_RESOLVED_SOURCE_VERSION"
1923
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
2024
- git clone https://github.com/aws-samples/busy-engineers-document-bucket.git
2125
- cd busy-engineers-document-bucket/exercises/java/encryption-context-complete
@@ -27,11 +31,12 @@ phases:
2731
mvn verify \
2832
-Pcodeartifact \
2933
-Dcheckstyle.skip \
30-
-Desdk.version=$VERSION \
34+
-Desdk.version=$VERSION_HASH \
3135
-Dmaven.compiler.target=$JAVA_NUMERIC_VERSION \
3236
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION \
3337
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
3438
-Dcodeartifact.url=$CODEARTIFACT_REPO_URL \
3539
--no-transfer-progress \
40+
-T 4 \
3641
-s $SETTINGS_FILE
3742

codebuild/release/version.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
4+
version: 0.2
5+
6+
env:
7+
variables:
8+
NODE_OPTIONS: "--max-old-space-size=4096"
9+
BRANCH: "master"
10+
git-credential-helper: "yes"
11+
12+
phases:
13+
install:
14+
commands:
15+
- npm install --save-dev semantic-release
16+
- npm install @semantic-release/changelog -d
17+
- npm install @semantic-release/exec -d
18+
- npm install @semantic-release/git -d
19+
- npm install --save conventional-changelog
20+
runtime-versions:
21+
nodejs: 14
22+
pre_build:
23+
commands:
24+
- git config --global user.name "aws-crypto-tools-ci-bot"
25+
- git config --global user.email "[email protected]"
26+
- git checkout $BRANCH
27+
build:
28+
commands:
29+
- npx semantic-release --no-ci

look_4_version.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
4+
#!bin/bash
5+
6+
VERSION=$1
7+
COUNTER=0
8+
STATUS=1
9+
10+
echo "Looking for version $VERSION"
11+
12+
while [ $STATUS -ne 0 ]; do
13+
mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.1:get \
14+
-Dartifact=com.amazonaws:aws-encryption-sdk-java:$VERSION:jar -U
15+
16+
STATUS=$?
17+
if [ $STATUS -eq 0 ]; then
18+
echo "Found version $VERSION in Maven Central :)"
19+
break
20+
fi
21+
22+
if [ $((COUNTER+=1)) -eq 10 ]; then
23+
echo "It has been an awfully long time, you should check Maven Central for issues"
24+
exit 1
25+
fi
26+
27+
echo "Could not find version $VERSION. Trying again."
28+
sleep 60
29+
done

0 commit comments

Comments
 (0)