Skip to content

Commit

Permalink
ci: release postject to npm on ci
Browse files Browse the repository at this point in the history
Fixes: #14
Signed-off-by: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
RaisinTen committed Sep 27, 2022
1 parent 0d7aab1 commit 2bc1430
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,42 @@ commands:
- store_test_results:
path: .

publish:
steps:
- attach_workspace:
at: .

- run:
name: Remove unnecessary files
command: rm -rf emsdk

- run:
name: Update version if not on git tag
command: |
if ! git describe --exact-match HEAD 1>/dev/null 2>/dev/null
then
git describe --exact-match HEAD 1>/dev/null 2>/dev/null && exit
CURRENT_VERSION="$(node -p "require('./package.json').version")"
GIT_COMMIT_SHA="$(git rev-parse --short HEAD)"
npm version "$CURRENT_VERSION-$GIT_COMMIT_SHA"
fi
- run:
name: Login to npm
command: npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN

- run:
name: Publish to npm
command: |
if git describe --exact-match HEAD 1>/dev/null 2>/dev/null
then
# Publish to latest when a git tag is pushed.
npm publish --tag latest
else
# Publish to beta when not run on a git tag.
npm publish --tag beta
fi
## JOBS ##

jobs:
Expand Down Expand Up @@ -210,6 +246,14 @@ jobs:
os: << parameters.os >>
- test

publish:
parameters:
<<: *common_parameters
executor: { name: linux }
steps:
- checkout
- publish

## WORKFLOWS ##

matrix: &matrix
Expand All @@ -229,4 +273,9 @@ workflows:
- test:
<<: *matrix
requires: [ build-<< matrix.os >> ]
- publish:
matrix:
parameters:
os: [ linux ]
requires: [ test-<< matrix.os >> ]

10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build/
.circleci/
CMakeLists.txt
CODEOWNERS
DEPENDENCIES
postject-api.h
scripts/
src/
test/
vendor/

0 comments on commit 2bc1430

Please sign in to comment.