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

feat(contributors): use 0.0.0 as a version marker #6463

Merged
merged 8 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 18 additions & 2 deletions pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ done
# Remove a JSII aggregate POM that may have snuk past
rm -rf dist/java/software/amazon/jsii

# Get version from lerna
version="$(cat ${root}/lerna.json | grep version | cut -d '"' -f4)"
# 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
Expand All @@ -79,6 +85,16 @@ HERE
# copy CHANGELOG.md to dist/ for github releases
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!"
eladb marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi

# for posterity, print all files in dist
echo "=============================================================================================="
echo " dist contents"
Expand Down
4 changes: 2 additions & 2 deletions scripts/align-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
//
const fs = require('fs');

const marker = '999.0.0';
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());

if (pkg.version !== marker) {
throw new Error(`unexpected - all package.json files in this repo should have a version of 999.0.0: ${file}`);
throw new Error(`unexpected - all package.json files in this repo should have a version of ${marker}: ${file}`);
}

pkg.version = repoVersion;
Expand Down
5 changes: 3 additions & 2 deletions scripts/align-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ files="$(find . -name package.json | grep -v node_modules | xargs)"
${scriptdir}/align-version.js ${files}

# validation
if find . -name package.json | grep -v node_modules | xargs grep "999.0.0"; then
echo "ERROR: unexpected version marker 999.0.0 in a package.json file"
marker=$(node -p "require('./scripts/get-version-marker')")
if find . -name package.json | grep -v node_modules | xargs grep "${marker}"; then
echo "ERROR: unexpected version marker ${marker} in a package.json file"
exit 1
fi
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 @@
/**
eladb marked this conversation as resolved.
Show resolved Hide resolved
* 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';