Skip to content

Commit

Permalink
Yarn publish nightlies and verdaccio (#6975)
Browse files Browse the repository at this point in the history
* Yarn publish nightlies and verdaccio
  • Loading branch information
snowystinger authored Sep 5, 2024
1 parent 10c31a7 commit c5a45b2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
11 changes: 2 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ executors:
CACHE_VERSION: v1
working_directory: ~/react-spectrum

rsp-xlarge-nodeupdate:
docker:
- image: cimg/node:18.20.3
resource_class: xlarge
environment:
CACHE_VERSION: v1
working_directory: ~/react-spectrum

jobs:
install:
executor: rsp-large
Expand Down Expand Up @@ -279,7 +271,7 @@ jobs:
path: ~/junit

test-esm:
executor: rsp-xlarge-nodeupdate
executor: rsp-xlarge
steps:
- restore_cache:
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
Expand Down Expand Up @@ -549,6 +541,7 @@ jobs:
name: Authenticate with npm
command: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
yarn config set authToken $NPM_TOKEN
git update-index --skip-worktree .npmrc
- run:
name: Publish
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ publish: build
yarn publish

publish-nightly: build
yarn version:nightly
yarn publish:nightly

build:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"chromatic:s2": "NODE_ENV=production CHROMATIC=1 chromatic --buildScriptName='build:chromatic-s2' --project-token=$RAINBOW_CHROMATIC_PROJECT_TOKEN",
"merge:css": "babel-node --presets @babel/env ./scripts/merge-spectrum-css.js",
"release": "lerna publish from-package --yes",
"publish:nightly": "lerna publish -y --canary --preid nightly --dist-tag=nightly --exact --force-publish='*' --no-push --no-verify-access",
"version:nightly": "yarn workspaces foreach --all --no-private -t version -d 3.0.0-nightly-$(git rev-parse --short HEAD)-$(date +'%y%m%d') && yarn version apply --all",
"publish:nightly": "yarn workspaces foreach --all --no-private -t npm publish --tag nightly --access public",
"build:api-published": "node scripts/buildPublishedAPI.js",
"build:api-branch": "node scripts/buildBranchAPI.js",
"compare:apis": "node scripts/compareAPIs.js",
Expand Down
31 changes: 16 additions & 15 deletions scripts/verdaccio.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

port=4000
# usually defaults to https://registry.npmjs.com/
original_registry=`npm get registry`
registry="http://localhost:$port"
output="output.out"
Expand All @@ -22,10 +23,11 @@ function cleanup {
rm -rf storage/ ~/.config/verdaccio/storage/ $output
if [ "$commit_to_revert" != "HEAD" ];
then
git tag -d $(git tag -l)
git fetch
git reset --hard $commit_to_revert
npm set registry $original_registry
yarn config set npmPublishRegistry $original_registry
yarn config set npmRegistryServer $original_registry
fi
else
# lsof doesn't work in circleci
Expand All @@ -48,6 +50,13 @@ grep -q 'http address' <(tail -f $output)

# Login as test user
yarn npm-cli-login -u abc -p abc -e '[email protected]' -r $registry
yarn config set npmPublishRegistry $registry
yarn config set npmRegistryServer $registry
yarn config set unsafeHttpWhitelist localhost
yarn config set npmAlwaysAuth true
npm set registry $registry
# Pause is important so that the username isn't interpreted as both username and password
(echo "abc"; sleep 2; echo "abc") | yarn npm login

if [ "$ci" = true ];
then
Expand All @@ -56,21 +65,13 @@ then
fi

# Bump all package versions (allow publish from current branch but don't push tags or commit)
yarn lerna version minor --force-publish --allow-branch `git branch --show-current` --no-push --yes
commit_to_revert="HEAD~1"
yarn workspaces foreach --all --no-private version minor --deferred
yarn version apply --all

if [ "$ci" = true ];
then
# Get rid of npmrc file generated by install since it will block lerna publish
git checkout -- .
fi
commit_to_revert="HEAD~0"

# Publish packages to verdaccio
yarn lerna publish from-package --registry $registry --yes

# set the npm registry because that will set it at a higher level, making local testing easier
npm set registry $registry
yarn config set npmRegistryServer $registry
yarn workspaces foreach --all --no-private -pt npm publish

if [ "$ci" = true ];
then
Expand All @@ -81,11 +82,11 @@ then
yarn config set npmRegistryServer $registry
cd ../..
# build prod docs with a public url of /reactspectrum/COMMIT_HASH_BEFORE_PUBLISH/verdaccio/docs
PUBLIC_URL=/reactspectrum/`git rev-parse HEAD~1`/verdaccio/docs make website-production
PUBLIC_URL=/reactspectrum/`git rev-parse HEAD~0`/verdaccio/docs make website-production

# Rename the dist folder from dist/production/docs to verdaccio_dist/COMMIT_HASH_BEFORE_PUBLISH/verdaccio/docs
# This is so we can have verdaccio build in a separate stream from deploy and deploy_prod
verdaccio_path=verdaccio_dist/`git rev-parse HEAD~1`/verdaccio
verdaccio_path=verdaccio_dist/`git rev-parse HEAD~0`/verdaccio
mkdir -p $verdaccio_path
mv dist/production/docs $verdaccio_path

Expand Down

2 comments on commit c5a45b2

@rspbot
Copy link

@rspbot rspbot commented on c5a45b2 Sep 5, 2024

Choose a reason for hiding this comment

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

@rspbot
Copy link

@rspbot rspbot commented on c5a45b2 Sep 5, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.