Skip to content

Commit 38a56b3

Browse files
authored
Merge pull request #6 from celtra/use-nexus-registry
DEV-229 Push to NPMJS
2 parents f296b44 + 6574667 commit 38a56b3

File tree

6 files changed

+50
-5
lines changed

6 files changed

+50
-5
lines changed

.github/workflows/push.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
env:
3636
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3737
PROTECTED_BRANCH_REVIEWER_TOKEN: ${{ secrets.CELTRA_DEPLOYER_GITHUB_TOKEN }}
38-
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
run: npm run canary
38+
NPM_TOKEN: ${{ secrets.NPMJS_WRITE_TOKEN }}
39+
run: bin/release-canary
4040

4141
- name: Prepare repository
4242
if: github.ref == 'refs/heads/master'
@@ -47,5 +47,5 @@ jobs:
4747
env:
4848
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4949
PROTECTED_BRANCH_REVIEWER_TOKEN: ${{ secrets.CELTRA_DEPLOYER_GITHUB_TOKEN }}
50-
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
run: npm run release
50+
NPM_TOKEN: ${{ secrets.NPMJS_WRITE_TOKEN }}
51+
run: bin/release-packages

.npmrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
@celtra:registry=https://npm.pkg.github.com
1+
registry=https://nexus.celtra.com/repository/npm/
2+
always-auth=true
3+
//nexus.celtra.com/repository/npm/:_auth=YnVpbGQ6enljN21nYTVlYmRYSFE5dWNmZ3BoaGdrN2NnYzlDS1Uzd2tw
4+
devdir=/cache/npm

bin/release-canary

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
MODULE_ROOT=$(dirname $(dirname $(readlink -e $0)))
5+
cd "$MODULE_ROOT"
6+
7+
if [ -z "$GH_TOKEN" ]; then
8+
echo "GH_TOKEN is not set"
9+
exit 1
10+
fi
11+
12+
"${MODULE_ROOT}/bin/set-npm-auth-token"
13+
14+
npm run canary

bin/release-packages

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
MODULE_ROOT=$(dirname $(dirname $(readlink -e $0)))
5+
cd "$MODULE_ROOT"
6+
7+
if [ -z "$GH_TOKEN" ]; then
8+
echo "GH_TOKEN is not set"
9+
exit 1
10+
fi
11+
12+
"${MODULE_ROOT}/bin/set-npm-auth-token"
13+
14+
npm run release

bin/set-npm-auth-token

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
# Switch to $HOME, because `npm set` can only be done outside of a workspace.
5+
pushd $HOME > /dev/null
6+
7+
# Since we use Nexus registry with auth by default,
8+
# $NPM_TOKEN is not used with `lerna` (used by `auto`),
9+
# so we need to manually set auth token.
10+
npm set "//registry.npmjs.org/:_authToken=$NPM_TOKEN"

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,9 @@
9797
"plugins": [
9898
"npm"
9999
]
100+
},
101+
"publishConfig": {
102+
"registry": "https://registry.npmjs.org",
103+
"access": "restricted"
100104
}
101105
}

0 commit comments

Comments
 (0)