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

fix: Deploy npm fixes #2685

Merged
merged 1 commit into from
Oct 4, 2023
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
2 changes: 1 addition & 1 deletion build-system/scripts/extract_tag_version
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ REPOSITORY="$1"
ERROR_ON_FAIL="${2:-"false"}"

# Check if there is a commit tag
if [[ -z "$COMMIT_TAG" ]]; then
if [[ -z "${COMMIT_TAG:-}" ]]; then
Copy link
Collaborator Author

@spalladino spalladino Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failed due to the set -u

if [[ "$ERROR_ON_FAIL" == "true" ]]; then
echo "No commit tag found. Exiting" >&2
exit 1
Expand Down
13 changes: 10 additions & 3 deletions yarn-project/deploy_npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc

function deploy_package() {
REPOSITORY=$1
VERSION=$(extract_tag_version $REPOSITORY false)
cd $REPOSITORY

VERSION=$(extract_tag_version $REPOSITORY true)
echo "Deploying $REPOSITORY $VERSION"

# 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)
Expand All @@ -18,8 +21,8 @@ function deploy_package() {
TAG_ARG="--tag $TAG"
fi

readonly PUBLISHED_VERSION=$(npm show . version ${TAG_ARG:-} 2> /dev/null)
readonly HIGHER_VERSION=$(npx semver ${VERSION} ${PUBLISHED_VERSION} | tail -1)
PUBLISHED_VERSION=$(npm show . version ${TAG_ARG:-} 2> /dev/null)
HIGHER_VERSION=$(npx semver ${VERSION} ${PUBLISHED_VERSION} | tail -1)
Comment on lines +24 to +25
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readonly modifier blew up the 2nd time the function was called


# 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
Expand Down Expand Up @@ -50,7 +53,11 @@ function deploy_package() {
else
npm publish --dry-run $TAG_ARG --access public
fi

# Back to root
cd ..
}

deploy_package foundation
deploy_package circuits.js
deploy_package types
Expand Down