Skip to content

Commit

Permalink
chore: standardize release script (#270)
Browse files Browse the repository at this point in the history
* chore: standardize release script

* chore: add explicit registry

* chore: add circleci script for publishing to npm
  • Loading branch information
jye-sf authored Apr 18, 2022
1 parent ca5b865 commit 4c13a88
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 18 deletions.
94 changes: 77 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,85 @@
version: 2
jobs:
build:
version: 2.1

deploy_filters: &deploy_filters
filters:
branches:
ignore: /.*/
tags:
# Trigger on tags that begin with `v`
only: /^v.*/


executors:
node:
docker:
- image: circleci/node:lts
- image: circleci/node:14

steps:
- checkout

commands:
save_yarn_cache:
description: Save cache for future build
steps:
- save_cache:
key: v1-yarn-deps-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
restore_yarn_cache:
description: Restore cache from previous build
steps:
- restore_cache:
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
- v1-dependencies-
- v1-yarn-deps-{{ checksum "yarn.lock" }}

- run: yarn install --frozen-lock
jobs:
build:
executor: node
steps:
- checkout
- restore_yarn_cache
- run:
name: Install dependencies and build
command: yarn install --frozen-lockfile
- save_yarn_cache
- run:
name: Check License Headers
command: yarn check-license-headers
- run:
name: Check formatting
command: yarn format:check
- run:
name: Run linter
command: yarn lint
- run:
name: Run unit tests
command: yarn test

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "yarn.lock" }}
deploy:
executor: node
steps:
- checkout
- restore_yarn_cache
- run:
name: Install dependencies and build
command: yarn install --frozen-lockfile
- run:
name: Configure NPM authentication
command: npm config set "//registry.npmjs.org/:_authToken" "$NPM_AUTOMATION_TOKEN"
- run:
name: Publish package
command: yarn release:publish

- run: yarn check-license-headers
- run: yarn format:check
- run: yarn lint
- run: yarn test
workflows:
workflow:
jobs:
- build
build_and_test:
jobs:
- build
build_and_test_and_deploy:
jobs:
- build:
<<: *deploy_filters
- deploy:
<<: *deploy_filters
requires:
- build
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"lint": "eslint src/ tests/",
"format": "prettier --write '**/*.{js,json,md,html,css}'",
"format:check": "prettier --check '**/*.{js,json,md,html,css}'",
"release": "npm publish --access public",
"release": "yarn release:publish",
"release:version": "npm version",
"release:publish": "npm publish --access public --registry=https://registry.npmjs.org",
"test": "jest"
},
"dependencies": {
Expand Down

0 comments on commit 4c13a88

Please sign in to comment.