Skip to content
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

chore: release updates #369

Merged
merged 18 commits into from
Oct 18, 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
54 changes: 5 additions & 49 deletions codebuild/release/release-prod.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
## SPDX-License-Identifier: Apache-2.0

version: 0.2

env:
Expand All @@ -13,13 +16,7 @@ phases:
java: openjdk11
pre_build:
commands:
- git checkout $COMMIT_ID
- FOUND_VERSION=$(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
- |
if expr ${FOUND_VERSION} != ${VERSION}; then
echo "pom.xml version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
exit 1;
fi
- export VERSION=$(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
- 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 ~
Expand All @@ -38,45 +35,4 @@ phases:
-Dsonatype.password="$SONA_PASSWORD" \
--no-transfer-progress \
-s $SETTINGS_FILE


batch:
fast-fail: false
build-graph:
- identifier: release_to_prod
- identifier: validate_prod_release_openjdk8
depend-on:
- release_to_prod
buildspec: codebuild/release/validate-prod.yml
env:
variables:
JAVA_ENV_VERSION: openjdk8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/standard:3.0
- identifier: validate_prod_release_openjdk11
depend-on:
- release_to_prod
buildspec: codebuild/release/validate-prod.yml
env:
variables:
JAVA_ENV_VERSION: openjdk11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/standard:3.0
- identifier: validate_prod_release_corretto8
depend-on:
- release_to_prod
buildspec: codebuild/release/validate-prod.yml
env:
variables:
JAVA_ENV_VERSION: corretto8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
- identifier: validate_prod_release_corretto11
depend-on:
- release_to_prod
buildspec: codebuild/release/validate-prod.yml
env:
variables:
JAVA_ENV_VERSION: corretto11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
- ./look_4_version.sh $VERSION
58 changes: 9 additions & 49 deletions codebuild/release/release-staging.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
## SPDX-License-Identifier: Apache-2.0

version: 0.2

env:
Expand All @@ -14,23 +17,21 @@ env:
phases:
install:
runtime-versions:
java: openjdk11
java: corretto11
pre_build:
commands:
- git checkout $COMMIT_ID
- FOUND_VERSION=$(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')
- |
if expr ${FOUND_VERSION} != ${VERSION}; then
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:
- VERSION_HASH="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-$CODEBUILD_RESOLVED_SOURCE_VERSION"
# See https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
- echo "Setting version in POM to $VERSION_HASH"
- mvn versions:set -DnewVersion="$VERSION_HASH" --no-transfer-progress
- echo "Version is now $(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')"
- |
mvn deploy \
-PpublishingCodeArtifact \
Expand All @@ -44,44 +45,3 @@ phases:
-DaltDeploymentRepository=codeartifact::default::$CODEARTIFACT_REPO_URL \
--no-transfer-progress \
-s $SETTINGS_FILE

batch:
fast-fail: false
build-graph:
- identifier: release_to_staging
- identifier: validate_staging_release_openjdk8
depend-on:
- release_to_staging
buildspec: codebuild/release/validate-staging.yml
env:
variables:
JAVA_ENV_VERSION: openjdk8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/standard:3.0
- identifier: validate_staging_release_openjdk11
depend-on:
- release_to_staging
buildspec: codebuild/release/validate-staging.yml
env:
variables:
JAVA_ENV_VERSION: openjdk11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/standard:3.0
- identifier: validate_staging_release_corretto8
depend-on:
- release_to_staging
buildspec: codebuild/release/validate-staging.yml
env:
variables:
JAVA_ENV_VERSION: corretto8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
- identifier: validate_staging_release_corretto11
depend-on:
- release_to_staging
buildspec: codebuild/release/validate-staging.yml
env:
variables:
JAVA_ENV_VERSION: corretto11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
112 changes: 112 additions & 0 deletions codebuild/release/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
## SPDX-License-Identifier: Apache-2.0

version: 0.2

batch:
fast-fail: true
build-graph:

# Release to CodeArtifact
- identifier: release_staging
buildspec: codebuild/release/release-staging.yml

# Validate CodeArtifact with supported JDK and Corretto
- identifier: validate_staging_release_openjdk_8
depend-on:
- release_staging
buildspec: codebuild/release/validate-staging.yml
env:
variables:
JAVA_ENV_VERSION: openjdk8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/standard:3.0

- identifier: validate_staging_release_openjdk11
depend-on:
- release_staging
buildspec: codebuild/release/validate-staging.yml
env:
variables:
JAVA_ENV_VERSION: openjdk11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/standard:3.0

- identifier: validate_staging_release_corretto8
depend-on:
- release_staging
buildspec: codebuild/release/validate-staging.yml
env:
variables:
JAVA_ENV_VERSION: corretto8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

- identifier: validate_staging_release_corretto11
depend-on:
- release_staging
buildspec: codebuild/release/validate-staging.yml
env:
variables:
JAVA_ENV_VERSION: corretto11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

# Version Project
- identifier: version
depend-on:
- release_staging
- validate_staging_release_openjdk_8
- validate_staging_release_openjdk11
- validate_staging_release_corretto8
- validate_staging_release_corretto11
buildspec: codebuild/release/version.yml
env:
image: aws/codebuild/standard:5.0

# Publish to Maven Central
- identifier: publish
depend-on:
- version
buildspec: codebuild/release/release-prod.yml

# Validate Maven Central with supported JDK and Corretto
- identifier: validate_prod_release_openjdk_8
depend-on:
- publish
buildspec: codebuild/release/validate-prod.yml
env:
variables:
JAVA_ENV_VERSION: openjdk8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/standard:3.0

- identifier: validate_prod_release_openjdk11
depend-on:
- publish
buildspec: codebuild/release/validate-prod.yml
env:
variables:
JAVA_ENV_VERSION: openjdk11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/standard:3.0

- identifier: validate_prod_release_corretto8
depend-on:
- publish
buildspec: codebuild/release/validate-prod.yml
env:
variables:
JAVA_ENV_VERSION: corretto8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0

- identifier: validate_prod_release_corretto11
depend-on:
- publish
buildspec: codebuild/release/validate-prod.yml
env:
variables:
JAVA_ENV_VERSION: corretto11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
4 changes: 4 additions & 0 deletions codebuild/release/settings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!--
Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
Expand Down
3 changes: 3 additions & 0 deletions codebuild/release/validate-prod.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
## SPDX-License-Identifier: Apache-2.0

version: 0.2

phases:
Expand Down
7 changes: 6 additions & 1 deletion codebuild/release/validate-staging.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
## SPDX-License-Identifier: Apache-2.0

version: 0.2

env:
Expand All @@ -16,6 +19,7 @@ phases:
java: $JAVA_ENV_VERSION
pre_build:
commands:
- VERSION_HASH="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-$CODEBUILD_RESOLVED_SOURCE_VERSION"
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
- git clone https://github.com/aws-samples/busy-engineers-document-bucket.git
- cd busy-engineers-document-bucket/exercises/java/encryption-context-complete
Expand All @@ -27,11 +31,12 @@ phases:
mvn verify \
-Pcodeartifact \
-Dcheckstyle.skip \
-Desdk.version=$VERSION \
-Desdk.version=$VERSION_HASH \
-Dmaven.compiler.target=$JAVA_NUMERIC_VERSION \
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION \
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
-Dcodeartifact.url=$CODEARTIFACT_REPO_URL \
--no-transfer-progress \
-T 4 \
-s $SETTINGS_FILE

29 changes: 29 additions & 0 deletions codebuild/release/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
## SPDX-License-Identifier: Apache-2.0

version: 0.2

env:
variables:
NODE_OPTIONS: "--max-old-space-size=4096"
BRANCH: "master"
git-credential-helper: "yes"

phases:
install:
commands:
- npm install --save-dev semantic-release
- npm install @semantic-release/changelog -d
- npm install @semantic-release/exec -d
- npm install @semantic-release/git -d
- npm install --save conventional-changelog
runtime-versions:
nodejs: 14
pre_build:
commands:
- git config --global user.name "aws-crypto-tools-ci-bot"
- git config --global user.email "no-reply@noemail.local"
- git checkout $BRANCH
build:
commands:
- npx semantic-release --no-ci
29 changes: 29 additions & 0 deletions look_4_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
## SPDX-License-Identifier: Apache-2.0

#!bin/bash

VERSION=$1
COUNTER=0
STATUS=1

echo "Looking for version $VERSION"

while [ $STATUS -ne 0 ]; do
mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.1:get \
-Dartifact=com.amazonaws:aws-encryption-sdk-java:$VERSION:jar -U

STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "Found version $VERSION in Maven Central :)"
break
fi

if [ $((COUNTER+=1)) -eq 10 ]; then
echo "It has been an awfully long time, you should check Maven Central for issues"
exit 1
fi

echo "Could not find version $VERSION. Trying again."
sleep 60
done