Skip to content

Commit

Permalink
Release using script
Browse files Browse the repository at this point in the history
  • Loading branch information
skovhus committed Jun 2, 2020
1 parent 74b9f69 commit 30cffcf
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
57 changes: 40 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,54 @@
version: 2

jobs:
verify:
docker:
- image: circleci/node:10
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:10

_steps:
save_npm_cache: &save_npm_cache
save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

working_directory: ~/repo
restore_npm_cache: &restore_npm_cache
restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

jobs:
verify:
<<: *defaults
steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-

- *restore_npm_cache
- run: yarn install
- *save_npm_cache
- run: if [ -z "$NPM_TOKEN" ]; then exit 1; fi
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
- run: sh release.sh

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

deploy:
<<: *defaults
steps:
- checkout
- *restore_npm_cache
- run: yarn install
- *save_npm_cache
- run: yarn run ci

workflows:
version: 2
main_workflow:
jobs:
- verify
- deploy:
requires:
- verify
filters:
branches:
only:
- master
17 changes: 17 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

version=$(cat package.json | jq -r .version)
name=$(cat package.json | jq -r .name)

publishedVersion=$(yarn info "$name" --json | jq -r .data.\"dist-tags\".latest)

if [ "$version" = "$publishedVersion" ]; then
echo "Newest version is already deployed."
exit 0
fi

echo "Deploying version $version."

npm publish

0 comments on commit 30cffcf

Please sign in to comment.