atlassian / lerna-semantic-release

📦:🛠✨💥 – fully automated package publishing
https://www.npmjs.com/package/lerna-semantic-release
679 stars 42 forks source link

lerna-semantic-release always gives me unauthorized #98

Open benkim0414 opened 3 years ago

benkim0414 commented 3 years ago

Hello guys.

First of all, very thank you for contributing to this great project. I have a monorepo to manage our company APIs. And I'm trying to configure lerna and lerna-semantic-release to automate publishing packages to GitHub package registry. However, it keeps giving me an unauthorized error but I'm pretty sure the environment variables such as NPM_TOKEN and GH_TOKEN are correct.

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/usr/local/Cellar/node/14.8.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'publish',
1 verbose cli   'packages/contacts'
1 verbose cli ]
2 info using npm@6.14.7
3 info using node@v14.8.0
4 verbose npm-session 82d7e5dadad38c23
5 verbose publish [ 'packages/contacts' ]
6 info lifecycle @green-energy-trading/contacts@1.0.0~prepublish: @green-energy-trading/contacts@1.0.0
7 info lifecycle @green-energy-trading/contacts@1.0.0~prepare: @green-energy-trading/contacts@1.0.0
8 info lifecycle @green-energy-trading/contacts@1.0.0~prepublishOnly: @green-energy-trading/contacts@1.0.0
9 info lifecycle @green-energy-trading/contacts@1.0.0~prepack: @green-energy-trading/contacts@1.0.0
10 info lifecycle @green-energy-trading/contacts@1.0.0~postpack: @green-energy-trading/contacts@1.0.0
11 notice
12 notice 📦  @green-energy-trading/contacts@1.0.0
13 notice === Tarball Contents ===
14 notice 41B     v1/address_grpc_pb.js
14 notice 8.6kB   v1/address_pb.js
14 notice 41B     v1/attachment_grpc_pb.js
14 notice 27.1kB  v1/attachment_pb.js
14 notice 41B     v1/contact_grpc_pb.js
14 notice 41B     v1/contact_membership_grpc_pb.js
14 notice 13.2kB  v1/contact_membership_pb.js
14 notice 42.4kB  v1/contact_pb.js
14 notice 41B     v1/representative_grpc_pb.js
14 notice 30.9kB  v1/representative_pb.js
14 notice 19.0kB  v1/service_grpc_pb.js
14 notice 113.1kB v1/service_pb.js
14 notice 404B    package.json
14 notice 45B     CHANGELOG.md
14 notice 1.5kB   v1/address_pb.d.ts
14 notice 4.8kB   v1/attachment_pb.d.ts
14 notice 2.5kB   v1/contact_membership_pb.d.ts
14 notice 7.3kB   v1/contact_pb.d.ts
14 notice 5.8kB   v1/representative_pb.d.ts
14 notice 34.2kB  v1/service_grpc_pb.d.ts
14 notice 22.2kB  v1/service_pb.d.ts
15 notice === Tarball Details ===
16 notice name:          @green-energy-trading/contacts
16 notice version:       1.0.0
16 notice package size:  25.5 kB
16 notice unpacked size: 333.2 kB
16 notice shasum:        23eaa1f73836c870e49ca45b6f6e616b8c2abac3
16 notice integrity:     sha512-2JXZK+v1YEi4x[...]qRe2knTixafmg==
16 notice total files:   21
17 notice
18 http fetch PUT 401 https://npm.pkg.github.com/@green-energy-trading%2fcontacts 324ms
19 verbose stack Error: 401 Unauthorized - PUT https://npm.pkg.github.com/@green-energy-trading%2fcontacts - Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
19 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:114:15
19 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:93:5)
20 verbose statusCode 401
21 verbose pkgid @green-energy-trading/contacts@1.0.0
22 verbose cwd /Users/ben/workspace/apis
23 verbose Darwin 20.2.0
24 verbose argv "/usr/local/Cellar/node/14.8.0/bin/node" "/usr/local/bin/npm" "publish" "packages/contacts"
25 verbose node v14.8.0
26 verbose npm  v6.14.7
27 error code E401
28 error 401 Unauthorized - PUT https://npm.pkg.github.com/@green-energy-trading%2fcontacts - Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
29 verbose exit [ 1, true ]

Please let me know if I misconfigure something or you have any suspicious things. Any help would be very appreciated.

benkim0414 commented 3 years ago

This is the log after I ran lerna publish command. It always works fine.

➜  apis git:(master) yarn lerna publish minor
yarn run v1.22.4
$ /Users/ben/workspace/apis/node_modules/.bin/lerna publish minor
lerna info version 2.11.0
lerna info versioning independent
lerna info Checking for updated packages...
lerna info Comparing with @green-energy-trading/certificates@1.1.0.
lerna info Checking for prereleased packages...

Changes:
 - @green-energy-trading/contacts: 1.0.0 => 1.1.0

? Are you sure you want to publish the above changes? Yes
lerna info publish Publishing packages to npm...
lerna info published @green-energy-trading/contacts
lerna info git Pushing tags...
Enter passphrase for key '/Users/ben/.ssh/id_rsa':
Successfully published:
 - @green-energy-trading/contacts@1.1.0
lerna success publish finished
✨  Done in 11.71s.

This is the reason why I think the access token is correct.

benkim0414 commented 3 years ago

And this is my .npmrc for my monorepo.

//npm.pkg.github.com/:_authToken=GH_TOKEN
@green-energy-trading:registry=https://npm.pkg.github.com