Skip to content

Commit c5a45b2

Browse files
authored
Yarn publish nightlies and verdaccio (#6975)
* Yarn publish nightlies and verdaccio
1 parent 10c31a7 commit c5a45b2

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

Diff for: .circleci/config.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ executors:
4040
CACHE_VERSION: v1
4141
working_directory: ~/react-spectrum
4242

43-
rsp-xlarge-nodeupdate:
44-
docker:
45-
- image: cimg/node:18.20.3
46-
resource_class: xlarge
47-
environment:
48-
CACHE_VERSION: v1
49-
working_directory: ~/react-spectrum
50-
5143
jobs:
5244
install:
5345
executor: rsp-large
@@ -279,7 +271,7 @@ jobs:
279271
path: ~/junit
280272

281273
test-esm:
282-
executor: rsp-xlarge-nodeupdate
274+
executor: rsp-xlarge
283275
steps:
284276
- restore_cache:
285277
key: react-spectrum-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
@@ -549,6 +541,7 @@ jobs:
549541
name: Authenticate with npm
550542
command: |
551543
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
544+
yarn config set authToken $NPM_TOKEN
552545
git update-index --skip-worktree .npmrc
553546
- run:
554547
name: Publish

Diff for: Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ publish: build
9898
yarn publish
9999

100100
publish-nightly: build
101+
yarn version:nightly
101102
yarn publish:nightly
102103

103104
build:

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"chromatic:s2": "NODE_ENV=production CHROMATIC=1 chromatic --buildScriptName='build:chromatic-s2' --project-token=$RAINBOW_CHROMATIC_PROJECT_TOKEN",
4848
"merge:css": "babel-node --presets @babel/env ./scripts/merge-spectrum-css.js",
4949
"release": "lerna publish from-package --yes",
50-
"publish:nightly": "lerna publish -y --canary --preid nightly --dist-tag=nightly --exact --force-publish='*' --no-push --no-verify-access",
50+
"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",
51+
"publish:nightly": "yarn workspaces foreach --all --no-private -t npm publish --tag nightly --access public",
5152
"build:api-published": "node scripts/buildPublishedAPI.js",
5253
"build:api-branch": "node scripts/buildBranchAPI.js",
5354
"compare:apis": "node scripts/compareAPIs.js",

Diff for: scripts/verdaccio.sh

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

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

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

5261
if [ "$ci" = true ];
5362
then
@@ -56,21 +65,13 @@ then
5665
fi
5766

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

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

6873
# Publish packages to verdaccio
69-
yarn lerna publish from-package --registry $registry --yes
70-
71-
# set the npm registry because that will set it at a higher level, making local testing easier
72-
npm set registry $registry
73-
yarn config set npmRegistryServer $registry
74+
yarn workspaces foreach --all --no-private -pt npm publish
7475

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

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

0 commit comments

Comments
 (0)