Skip to content

Commit

Permalink
chore: revert "multiple release branches without merge conflicts" (aw…
Browse files Browse the repository at this point in the history
…s#11287) (aws#11292)

* Revert "chore: multiple release branches without merge conflicts (aws#11287)"

This reverts commit 85915a4.

* Update .gitignore
  • Loading branch information
Elad Ben-Israel authored Nov 4, 2020
1 parent 85915a4 commit 9859972
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 390 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ yarn-error.log
# Cloud9
.c9

/.versionrc.json
5 changes: 5 additions & 0 deletions .versionrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"skip": { "tag": true },
"packageFiles": [ { "filename": "lerna.json", "type": "json" } ],
"bumpFiles": [ { "filename": "lerna.json", "type": "json" } ]
}
71 changes: 18 additions & 53 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,59 +779,24 @@ CDK](https://github.com/aws/aws-cdk/issues/3398) we will either remove the
legacy behavior or flip the logic for all these features and then
reset the `FEATURE_FLAGS` map for the next cycle.
### Versioning and Release
The `release.json` file at the root of the repo determines which release line
this branch belongs to.
```js
{
"majorVersion": "1" | "2",
"releaseType": "stable" | "alpha" | "rc"
}
```

To reduce merge conflicts in automatic merges between version branches, the
current version number is stored under `version.vNN.json` (where `NN` is
`majorVersion`) and changelogs are stored under `CHANGELOG.NN.md` (for
historical reasons, the changelog for 1.x is under `CHANGELOG.md`). When we
fork to a new release branch (e.g. `main-v2`), we will update `release.json` in
this branch to reflect the new version line, and this information will be used
to determine how releases are cut.

The actual `version` field in all `package.json` files should always be `0.0.0`.
This means that local development builds will use version `0.0.0` instead of the
official version from the version file.

#### `./bump.sh`

This script uses [standard-version] to update the version in `version.vNN.json`
to the next version. By default it will perform a **minor** bump, but `./bump.sh
patch` can be used to perform a patch release if that's needed.

This script will also update the relevant changelog file.

[standard-version]: https://github.com/conventional-changelog/standard-version

#### `scripts/resolve-version.js`

The script evaluates evaluates the configuration in `release.json` exports an
object like this:

```js
{
version: '2.0.0-alpha.1', // the current version
versionFile: 'version.v2.json', // the version file
changelogFile: 'CHANGELOG.v2.md', // changelog file name
prerelease: 'alpha', // prerelease tag (undefined for stable)
marker: '0.0.0' // version marker in package.json files
}
```

#### scripts/align-version.sh

In official builds, the `scripts/align-version.sh` is used to update all
`package.json` files based on the version from `version.vNN.json`.
### Versioning
All `package.json` files in this repo use a stable marker version of `0.0.0`.
This means that when you declare dependencies, you should always use `0.0.0`.
This makes it easier for us to bump a new version (the `bump.sh` script will
just update the central version and create a CHANGELOG entry) and also reduces
the chance of merge conflicts after a new version is released.
Additional scripts that take part in the versioning mechanism:
- `scripts/get-version.js` can be used to obtain the actual version of the repo.
You can use either from JavaScript code by `require('./scripts/get-version')`
or from a shell script `node -p "require('./scripts/get-version')"`.
- `scripts/get-version-marker.js` returns `0.0.0` and used to DRY the version
marker.
- `scripts/align-version.sh` and `scripts/align-version.js` are used to align
all package.json files in the repo to the official version. This script is
invoked in CI builds and should not be used inside a development environment.
## Troubleshooting
Expand Down
19 changes: 18 additions & 1 deletion bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,21 @@
#
# --------------------------------------------------------------------------------------------------
set -euo pipefail
./scripts/bump.js ${1:-minor}
version=${1:-minor}

echo "Starting ${version} version bump"

# /bin/bash ./install.sh

# Generate CHANGELOG and create a commit (see .versionrc.json)
npx standard-version --release-as ${version}

# I am sorry.
#
# I've gone diving through the code of `conventional-changelog` to see if there
# was a way to configure the string and ultimately I decided that a 'sed' was the simpler
# way to go.
sed -i.tmp -e 's/BREAKING CHANGES$/BREAKING CHANGES TO EXPERIMENTAL FEATURES/' CHANGELOG.md
rm CHANGELOG.md.tmp
git add CHANGELOG.md
git commit --amend --no-edit
5 changes: 2 additions & 3 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"packages/@aws-cdk-containers/*",
"packages/@monocdk-experiment/*",
"packages/@aws-cdk/*/lambda-packages/*",
"tools/*",
"scripts/script-tests"
"tools/*"
],
"rejectCycles": "true",
"version": "0.0.0"
"version": "1.71.0"
}
17 changes: 11 additions & 6 deletions pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ export PATH=$PWD/node_modules/.bin:$PATH
export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"
root=$PWD

# Get version and changelog file name (these require that .versionrc.json would have been generated)
version=$(node -p "require('./scripts/resolve-version').version")
changelog_file=$(node -p "require('./scripts/resolve-version').changelogFile")
marker=$(node -p "require('./scripts/resolve-version').marker")

PACMAK=${PACMAK:-jsii-pacmak}
ROSETTA=${ROSETTA:-jsii-rosetta}
TMPDIR=${TMPDIR:-$(dirname $(mktemp -u))}
Expand Down Expand Up @@ -62,6 +57,15 @@ done
# Remove a JSII aggregate POM that may have snuk past
rm -rf dist/java/software/amazon/jsii

# Get version
version="$(node -p "require('./scripts/get-version')")"

# Ensure we don't publish anything beyond 1.x for now
if [[ ! "${version}" == "1."* ]]; then
echo "ERROR: accidentally releasing a major version? Expecting repo version to start with '1.' but got '${version}'"
exit 1
fi

# Get commit from CodePipeline (or git, if we are in CodeBuild)
# If CODEBUILD_RESOLVED_SOURCE_VERSION is not defined (i.e. local
# build or CodePipeline build), use the HEAD commit hash).
Expand All @@ -79,11 +83,12 @@ cat > ${distdir}/build.json <<HERE
HERE

# copy CHANGELOG.md to dist/ for github releases
cp ${changelog_file} ${distdir}/CHANGELOG.md
cp CHANGELOG.md ${distdir}/

# defensive: make sure our artifacts don't use the version marker (this means
# that "pack" will always fails when building in a dev environment)
# when we get to 10.0.0, we can fix this...
marker=$(node -p "require('./scripts/get-version-marker')")
if find dist/ | grep "${marker}"; then
echo "ERROR: build artifacts use the version marker '${marker}' instead of a real version."
echo "This is expected for builds in a development environment but should not happen in CI builds!"
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
"packages/@aws-cdk-containers/*",
"packages/@monocdk-experiment/*",
"packages/@aws-cdk/*/lambda-packages/*",
"tools/*",
"scripts/script-tests"
"tools/*"
],
"nohoist": [
"**/jszip",
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-cdk/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Note that these tests can only be executed using the `run-against-dist` wrapper.

##### Implementation

The implementation of the regression suites is not trivial to reason about and follow. Even though the code includes inline comments, we break down the exact details to better serve us in maintaining it and regaining context.
The implemention of the regression suites is not trivial to reason about and follow. Even though the code includes inline comments, we break down the exact details to better serve us in maintaining it and regaining context.

Before diving into it, we establish a few key concepts:

Expand All @@ -126,7 +126,7 @@ Before diving into it, we establish a few key concepts:
- `FRAMEWORK_VERSION` - This is the version of the framework we are testing. It varries between the two variation of the regression suites.
Its value can either be that of `CANDIDATE_VERSION` (for testing against the latest framework code), or `PREVIOUS_VERSION` (for testing against the previously published version of the framework code).

Following are the steps involved in running these tests:
Following are the steps invovled in running these tests:

1. Run [`./bump-candidate.sh`](../../bump-candidate.sh) to differentiate between the local version and the published version. For example, if the version in `lerna.json` is `1.67.0`, this script will result in a version `1.67.0-rc.0`. This is needed so that we can launch a verdaccio instance serving local tarballs without worrying about conflicts with the public npm uplink. This will help us avoid version quirks that might happen during the *post-release-pre-merge-back* time window.

Expand All @@ -143,7 +143,7 @@ Following are the steps involved in running these tests:
- [Install the CLI](./test/integ/run-against-dist#L30) using the `CANDIDATE_VERSION` version `CANDIDATE_VERSION` env variable.
- Execute the given script.

6. Both cli regression test scripts run the same [`run_regression_against_framework_version`](./test/integ/test-cli-regression.bash#L22) function. This function accepts which framework version should the regression run against, it can be either `CANDIDATE_VERSION` or `PREVIOUS_VERSION`. Note that the argument is not the actual value of the version, but instead is just an [indirection indentifier](./test/integ/test-cli-regression.bash#L81). The function will:
6. Both cli regression test scripts run the same [`run_regression_against_framework_version`](./test/integ/test-cli-regression.bash#L22) function. This function accepts which framework version should the regression run against, it can be either `CANDIDATE_VERSION` or `PREVIOUS_VERSION`. Note that the argument is not the actual value of the versio, but instead is just an [indirection indentifier](./test/integ/test-cli-regression.bash#L81). The function will:

- Calculate the actual value of the previous version based on the candidate version. (fetches from github)
- Download the previous version tarball from npm and extract the integration tests.
Expand Down
4 changes: 0 additions & 4 deletions release.json

This file was deleted.

5 changes: 2 additions & 3 deletions scripts/align-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
//
const fs = require('fs');

const ver = require('./resolve-version');
const marker = ver.marker;
const repoVersion = ver.version;
const marker = require('./get-version-marker');
const repoVersion = require('./get-version');

for (const file of process.argv.splice(2)) {
const pkg = JSON.parse(fs.readFileSync(file).toString());
Expand Down
2 changes: 1 addition & 1 deletion scripts/align-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ files="./package.json $(npx lerna ls -p -a | xargs -n1 -I@ echo @/package.json)"
${scriptdir}/align-version.js ${files}

# validation
marker=$(node -p "require('./scripts/resolve-version').marker.replace(/\./g, '\\\.')")
marker=$(node -p "require('./scripts/get-version-marker').replace(/\./g, '\\\.')")

# Get a list of all package.json files. None of them shouldn contain 0.0.0 anymore.
# Exclude a couple of specific ones that we don't care about.
Expand Down
11 changes: 7 additions & 4 deletions scripts/bump-candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# a verdaccio instance that serves local tarballs, and if those tarballs have the same version as
# already published modules, it messes things up.
#
# It does so by using a pre-release "test" tag, making it so that locally packed versions will always be
# suffixed with '-test', distinguishing it from published modules.
# It does so by using a pre-release rc tag, making it so that locally packed versions will always be
# suffixed with '-rc', distinguishing it from publisehd modules.
#
# If you need to run integration tests locally against the distribution tarballs, you should run this
# script locally as well before building and packing the repository.
Expand All @@ -16,5 +16,8 @@
#
# --------------------------------------------------------------------------------------------------
set -euo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
BUMP_CANDIDATE=true ${scriptdir}/bump.js ${1:-minor}
version=${1:-minor}

echo "Starting candidate ${version} version bump"

npx standard-version --release-as ${version} --prerelease=rc --skip.commit --skip.changelog
49 changes: 0 additions & 49 deletions scripts/bump.js

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/changelog-experimental-fix.sh

This file was deleted.

13 changes: 13 additions & 0 deletions scripts/get-version-marker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Returns the version marker used to indicate this is a local dependency.
*
* Usage:
*
* const version = require('./get-version-marker');
*
* Or from the command line:
*
* node -p require('./get-version-marker')
*
*/
module.exports = '0.0.0';
18 changes: 18 additions & 0 deletions scripts/get-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Returns the current repo version.
*
* Usage:
*
* const version = require('./get-version');
*
* Or from the command line:
*
* node -p require('./get-version')
*
*/
const versionFile = require('../.versionrc.json').packageFiles[0].filename;
if (!versionFile) {
throw new Error(`unable to determine version filename from .versionrc.json at the root of the repo`);
}

module.exports = require(`../${versionFile}`).version;
Loading

0 comments on commit 9859972

Please sign in to comment.