-
Notifications
You must be signed in to change notification settings - Fork 297
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: NPM canary deployment #2731
Changes from 7 commits
829e081
d14ed39
c60f723
f36df38
21460b6
187e0f5
8798cf4
bbae4f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
COMMIT_TAG=$1 | ||
DIST_TAG=$1 | ||
|
||
if [ -z "$COMMIT_TAG" ]; then | ||
echo "No commit tag provided." | ||
if [ -z "$DIST_TAG" ]; then | ||
echo "No dist tag provided." | ||
exit 0 | ||
fi | ||
|
||
VERSION=$(npx semver $COMMIT_TAG) | ||
if [ -z "$VERSION" ]; then | ||
echo "$COMMIT_TAG is not a semantic version." | ||
exit 1 | ||
fi | ||
|
||
echo "Updating Aztec dependencies to version $VERSION" | ||
echo "Updating Aztec dependencies to tag $DIST_TAG" | ||
|
||
TMP=$(mktemp) | ||
for PKG in $(jq --raw-output ".dependencies | keys[] | select(contains(\"@aztec/\") and (. != \"@aztec/end-to-end\"))" package.json); do | ||
jq --arg v $VERSION ".dependencies[\"$PKG\"] = \$v" package.json > $TMP && mv $TMP package.json | ||
jq --arg v $DIST_TAG ".dependencies[\"$PKG\"] = \$v" package.json >$TMP && mv $TMP package.json | ||
done | ||
|
||
jq ".references = []" tsconfig.json > $TMP && mv $TMP tsconfig.json | ||
jq ".references = []" tsconfig.json >$TMP && mv $TMP tsconfig.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
#!/bin/bash | ||
|
||
DIST_TAG=${1:-"latest"} | ||
|
||
extract_repo yarn-project /usr/src project | ||
PROJECT_ROOT=$(pwd)/project/src/ | ||
|
||
for REPOSITORY in "pxe" "aztec-sandbox" | ||
do | ||
echo "Deploying $REPOSITORY" | ||
RELATIVE_PROJECT_DIR=$(query_manifest relativeProjectDir $REPOSITORY) | ||
cd "$PROJECT_ROOT/$RELATIVE_PROJECT_DIR" | ||
for REPOSITORY in "pxe" "aztec-sandbox"; do | ||
echo "Deploying $REPOSITORY $TAG" | ||
RELATIVE_PROJECT_DIR=$(query_manifest relativeProjectDir $REPOSITORY) | ||
cd "$PROJECT_ROOT/$RELATIVE_PROJECT_DIR" | ||
|
||
deploy_dockerhub $REPOSITORY x86_64 | ||
deploy_dockerhub $REPOSITORY arm64 | ||
create_dockerhub_manifest $REPOSITORY x86_64,arm64 | ||
deploy_dockerhub $REPOSITORY x86_64 $DIST_TAG | ||
deploy_dockerhub $REPOSITORY arm64 $DIST_TAG | ||
create_dockerhub_manifest $REPOSITORY x86_64,arm64 $DIST_TAG | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,57 +5,70 @@ set -eu | |
extract_repo yarn-project /usr/src project | ||
cd project/src/yarn-project | ||
|
||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc | ||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >.npmrc | ||
|
||
# This is to be used with the 'canary' tag for testing, and then 'latest' for making it public | ||
DIST_TAG=${1:-} | ||
|
||
function deploy_package() { | ||
REPOSITORY=$1 | ||
cd $REPOSITORY | ||
REPOSITORY=$1 | ||
cd $REPOSITORY | ||
|
||
VERSION=$(extract_tag_version $REPOSITORY true) | ||
echo "Deploying $REPOSITORY $VERSION" | ||
PACKAGE_NAME=$(jq -r '.name' package.json) | ||
|
||
# If the commit tag itself has a dist-tag (e.g. v2.1.0-testnet.123), extract the dist-tag. | ||
TAG=$(echo "$VERSION" | grep -oP ".*-\K(.*)(?=\.\d+)" || true) | ||
TAG_ARG="" | ||
if [ -n "$TAG" ]; then | ||
TAG_ARG="--tag $TAG" | ||
fi | ||
VERSION=$(extract_tag_version $REPOSITORY true) | ||
echo "Deploying $REPOSITORY $VERSION $DIST_TAG" | ||
|
||
PUBLISHED_VERSION=$(npm show . version ${TAG_ARG:-} 2> /dev/null) || true | ||
HIGHER_VERSION=$(npx semver ${VERSION} ${PUBLISHED_VERSION} | tail -1) | ||
if [ -n "$DIST_TAG" ]; then | ||
TAG_ARG="--tag $DIST_TAG" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be set to something by default? |
||
fi | ||
|
||
# If there is already a published package equal to given version, assume this is a re-run of a deploy, and early out. | ||
if [ "$VERSION" == "$PUBLISHED_VERSION" ]; then | ||
echo "Tagged version $VERSION is equal to published version $PUBLISHED_VERSION. Skipping publish." | ||
exit 0 | ||
fi | ||
PUBLISHED_VERSION=$(npm show . version ${TAG_ARG:-} 2>/dev/null) || true | ||
HIGHER_VERSION=$(npx semver ${VERSION} ${PUBLISHED_VERSION} | tail -1) | ||
|
||
# If the published version is > the given version, something's gone wrong. | ||
if [ "$VERSION" != "$HIGHER_VERSION" ]; then | ||
echo "Tagged version $VERSION is lower than published version $PUBLISHED_VERSION." | ||
exit 1 | ||
fi | ||
# Check if there is already a published package equal to given version, assume this is a re-run of a deploy | ||
if [ "$VERSION" == "$PUBLISHED_VERSION" ]; then | ||
echo "Tagged ${DIST_TAG:+ $DIST_TAG}version $VERSION is equal to published ${DIST_TAG:+ $DIST_TAG}version $PUBLISHED_VERSION." | ||
echo "Skipping publish." | ||
exit 0 | ||
fi | ||
|
||
# If the published version is > the given version, something's gone wrong. | ||
if [ "$VERSION" != "$HIGHER_VERSION" ]; then | ||
echo "Tagged version $VERSION is lower than published version $PUBLISHED_VERSION." | ||
exit 1 | ||
fi | ||
|
||
# Update the package version in package.json. | ||
TMP=$(mktemp) | ||
jq --arg v $VERSION '.version = $v' package.json > $TMP && mv $TMP package.json | ||
# Update the package version in package.json. | ||
TMP=$(mktemp) | ||
jq --arg v $VERSION '.version = $v' package.json >$TMP && mv $TMP package.json | ||
|
||
if [ -z "${STANDALONE:-}" ]; then | ||
if [ -z "${STANDALONE:-}" ]; then | ||
# Update each dependent @aztec package version in package.json. | ||
for PKG in $(jq --raw-output ".dependencies | keys[] | select(contains(\"@aztec/\"))" package.json); do | ||
jq --arg v $VERSION ".dependencies[\"$PKG\"] = \$v" package.json > $TMP && mv $TMP package.json | ||
jq --arg v $VERSION ".dependencies[\"$PKG\"] = \$v" package.json >$TMP && mv $TMP package.json | ||
done | ||
fi | ||
fi | ||
|
||
# Publish | ||
if [ -n "${COMMIT_TAG:-}" ] ; then | ||
# Publish | ||
if [ -n "${COMMIT_TAG:-}" ]; then | ||
if [ "$DIST_TAG" == "latest" ]; then | ||
# Check if version exists | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not quite sure I follow this block. Doesn't this only apply the dist tag if there is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this was wrong, fixed in bbae4f7 |
||
# npm show . version --tag canary | ||
if npm view "$PACKAGE_NAME@$VERSION" version >/dev/null 2>&1; then | ||
# Tag the existing version | ||
npm dist-tag add $PACKAGE_NAME@$VERSION $DIST_TAG | ||
else | ||
# Publish new verison | ||
npm publish $TAG_ARG --access public | ||
else | ||
npm publish --dry-run $TAG_ARG --access public | ||
fi | ||
fi | ||
else | ||
npm publish --dry-run $TAG_ARG --access public | ||
fi | ||
|
||
# Back to root | ||
cd .. | ||
# Back to root | ||
cd .. | ||
} | ||
|
||
deploy_package foundation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.