From 5276067073b9b99a84551d90d145cc625c9b358d Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar <16217941+nija-at@users.noreply.github.com> Date: Tue, 3 Mar 2020 16:25:00 +0000 Subject: [PATCH] chore(cfnspec): prepare cfnspec update for autobump (#6557) * chore(cfnspec): prepare cfnspec update for autobump `update-cfnspec.sh` is a single script that does the whole bump process from a fresh repo. `cfn.version` holds the current version of the CloudFormation version which changes with the bump process. This is required by delivlib's bump API here - https://github.com/awslabs/aws-delivlib/blob/0342978b78c5dd2c7bff2279d3b9a43c9e1f359c/lib/bump/bump.ts#L23-L27 * rename to bump * tweaked per PR feedback Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- packages/@aws-cdk/cfnspec/README.md | 15 +++++++++++---- packages/@aws-cdk/cfnspec/build-tools/update.sh | 13 +++++++++---- packages/@aws-cdk/cfnspec/cfn.version | 1 + scripts/bump-cfnspec.sh | 13 +++++++++++++ 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 packages/@aws-cdk/cfnspec/cfn.version create mode 100755 scripts/bump-cfnspec.sh diff --git a/packages/@aws-cdk/cfnspec/README.md b/packages/@aws-cdk/cfnspec/README.md index 134405a180197..dcfe13e36de17 100644 --- a/packages/@aws-cdk/cfnspec/README.md +++ b/packages/@aws-cdk/cfnspec/README.md @@ -1,8 +1,15 @@ # AWS CDK CloudFormation Tools -To update the CloudFormation spec to the latest version, run: +To update the CloudFormation spec, you can run `bump-cfnspec.sh` from a clean repo, as so - - npm run update +``` +./scripts/bump-cfnspec.sh +``` + +If you wish to only update the CFN spec, make sure to install all dependencies and build the `cfnspec` module, +and then you can just run: + +``` +yarn update +``` -Any JSON hashes are alpha-sorted to make sure that only actual changes appear in -diffs. \ No newline at end of file diff --git a/packages/@aws-cdk/cfnspec/build-tools/update.sh b/packages/@aws-cdk/cfnspec/build-tools/update.sh index 8aae06c822601..b2415c71a93c7 100755 --- a/packages/@aws-cdk/cfnspec/build-tools/update.sh +++ b/packages/@aws-cdk/cfnspec/build-tools/update.sh @@ -49,6 +49,10 @@ update-spec \ spec-source/000_CloudFormationResourceSpecification.json \ true +echo >&2 "Recording new version..." +rm -f cfn.version +node -p "require('${scriptdir}/../spec-source/000_CloudFormationResourceSpecification.json').ResourceSpecificationVersion" > cfn.version + update-spec \ "Serverless Application Model (SAM) Resource Specification" \ "https://raw.githubusercontent.com/awslabs/goformation/master/generate/sam-2016-10-31.json" \ @@ -70,7 +74,8 @@ node ${scriptdir}/create-missing-libraries.js || { (cd ${scriptdir}/../../../monocdk-experiment && node ./deps.js || true) # append old changelog after new and replace as the last step because otherwise we will not be idempotent -cat CHANGELOG.md >> CHANGELOG.md.new -cp CHANGELOG.md.new CHANGELOG.md - - +_changelog_contents=$(cat CHANGELOG.md.new) +if [ -n "${_changelog_contents}" ]; then + cat CHANGELOG.md >> CHANGELOG.md.new + cp CHANGELOG.md.new CHANGELOG.md +fi \ No newline at end of file diff --git a/packages/@aws-cdk/cfnspec/cfn.version b/packages/@aws-cdk/cfnspec/cfn.version new file mode 100644 index 0000000000000..68d8f15e23cf5 --- /dev/null +++ b/packages/@aws-cdk/cfnspec/cfn.version @@ -0,0 +1 @@ +11.1.0 diff --git a/scripts/bump-cfnspec.sh b/scripts/bump-cfnspec.sh new file mode 100755 index 0000000000000..8e2bbab35c49a --- /dev/null +++ b/scripts/bump-cfnspec.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -euo pipefail + +if [ ! -f "lerna.json" ]; then + echo "This script should be run from the root of the CDK repository" + exit 1 +fi + +./install.sh +cd packages/@aws-cdk/cfnspec +../../../scripts/buildup +yarn update +git commit -a -m "feat: cloudformation spec v$(cat cfn.version)" || true # don't fail if there are no updates