Skip to content

Commit

Permalink
fix: Deploy npm fixes (#2685)
Browse files Browse the repository at this point in the history
Fixes to the `deploy_npm` script. We were not `cd`ing into each package,
so the script was attempting to publish the root workspace
`package.json`.
  • Loading branch information
spalladino authored Oct 4, 2023
1 parent 628127d commit 0b788c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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
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)

# 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

0 comments on commit 0b788c6

Please sign in to comment.