Skip to content

Commit a39ee75

Browse files
committed
feat: add script to publish-npm-dev
1 parent d775c88 commit a39ee75

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

.github/workflows/ci.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ jobs:
177177
name: npm-package
178178
path: ./package.tar.gz
179179

180+
- name: Publish npm package with dev tag
181+
run: yarn publish:npm:dev
182+
env:
183+
TAG: ${{ github.event.number }}-${{ github.event.pull_request.head.sha }}
184+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
185+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
186+
180187
# TODO: cache building yarn --production
181188
# possibly 2m30s of savings(?)
182189
# this requires refactoring our release scripts

ci/steps/publish-npm-dev.sh

+20-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@
22
set -euo pipefail
33

44
main() {
5-
# We need VERSION to bump the brew formula
5+
cd "$(dirname "$0")/../.."
6+
source ./ci/lib.sh
7+
source ./ci/steps/steps-lib.sh
8+
9+
# We need TAG to know what to publish under on npm
610
if ! is_env_var_set "TAG"; then
7-
echo "TAG is not set. Cannot publish to npm without setting a tag"
11+
echo "TAG is not set. Cannot publish to npm without setting a tag."
812
exit 1
913
fi
10-
cd "$(dirname "$0")/../.."
11-
source ./ci/lib.sh
14+
15+
# Needed ot publish on NPM
16+
if ! is_env_var_set "NPM_TOKEN"; then
17+
echo "NPM_TOKEN is not set. Cannot publish to npm without credentials."
18+
exit 1
19+
fi
20+
21+
# Needed to use GitHub API
22+
if ! is_env_var_set "GITHUB_TOKEN"; then
23+
echo "GITHUB_TOKEN is not set. Cannot download npm release artifact without GitHub credentials."
24+
exit 1
25+
fi
26+
27+
echo "using tag: $TAG"
1228

1329
if [[ ${CI-} ]]; then
1430
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"test:scripts": "./ci/dev/test-scripts.sh",
2424
"package": "./ci/build/build-packages.sh",
2525
"postinstall": "./ci/dev/postinstall.sh",
26+
"publish:npm:dev": "./ci/steps/publish-npm-dev.sh",
2627
"_audit": "./ci/dev/audit.sh",
2728
"fmt": "./ci/dev/fmt.sh",
2829
"lint": "./ci/dev/lint.sh",

0 commit comments

Comments
 (0)