Skip to content

Commit 50b7ade

Browse files
author
Andy O'Neill
authored
Merge pull request #181 from LLK/circleci
ci: Replace Travis with CircleCI
2 parents 89c3459 + a6d400d commit 50b7ade

File tree

6 files changed

+14897
-35
lines changed

6 files changed

+14897
-35
lines changed

.circleci/config.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
version: 2.1
2+
orbs:
3+
node: circleci/node@5
4+
5+
aliases:
6+
- &release-branches
7+
- master
8+
- develop
9+
- /^hotfix\//
10+
11+
executors:
12+
default-executor:
13+
docker:
14+
- image: cimg/node:16.18.1 # Consider switching to LTS when scratch-audio supports that version
15+
working_directory: ~/project
16+
resource_class: medium
17+
18+
commands:
19+
test:
20+
steps:
21+
- run:
22+
name: Test
23+
command: npm run test
24+
setup_deploy:
25+
steps:
26+
- run:
27+
name: Setup Deploy
28+
command: |
29+
export NODE_ENV=production
30+
export RELEASE_TIMESTAMP=$(date +'%Y%m%d%H%M%S')
31+
echo "export NPM_TAG=latest" >> $BASH_ENV
32+
npm run build
33+
if [ -z "$BEFORE_DEPLOY_RAN" ]; then
34+
VPKG=$($(npm bin)/json -f package.json version)
35+
VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP}
36+
echo "export RELEASE_VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP}" >> $BASH_ENV
37+
npm --no-git-tag-version version $VERSION
38+
if [[ "$CIRCLE_BRANCH" == hotfix/* ]]; then # double brackets are important for matching the wildcard
39+
echo "export NPM_TAG=hotfix" >> $BASH_ENV
40+
fi
41+
git config --global user.email "$(git log --pretty=format:"%ae" -n1)"
42+
git config --global user.name "$(git log --pretty=format:"%an" -n1)"
43+
echo "export BEFORE_DEPLOY_RAN=true" >> $BASH_ENV
44+
fi
45+
deploy:
46+
steps:
47+
- run:
48+
name: Deploy
49+
command: |
50+
echo "Deploying version $RELEASE_VERSION to $NPM_TAG"
51+
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
52+
npm publish --tag $NPM_TAG
53+
if npm info | grep -q $RELEASE_VERSION; then git tag $RELEASE_VERSION && git push https://${GH_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git $RELEASE_VERSION; fi
54+
55+
jobs:
56+
build-and-test:
57+
executor: default-executor
58+
steps:
59+
- checkout
60+
- node/install-packages
61+
- test
62+
- persist_to_workspace:
63+
root: ~/project
64+
paths:
65+
- .
66+
deploy:
67+
executor: default-executor
68+
steps:
69+
- attach_workspace:
70+
at: ~/project
71+
- setup_deploy
72+
- deploy
73+
74+
workflows:
75+
build-and-test-workflow:
76+
jobs:
77+
- build-and-test:
78+
filters:
79+
branches:
80+
ignore: *release-branches
81+
deploy-workflow:
82+
jobs:
83+
- build-and-test:
84+
filters:
85+
branches:
86+
only: *release-branches
87+
- deploy:
88+
context:
89+
- scratch-npm-creds
90+
requires:
91+
- build-and-test

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Development files
2+
/.circleci
3+
14
# Testing
25
/.nyc_output
36
/coverage

.travis.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#### Please note this project is at an early stage and we are not ready for pull requests
77

8-
[![Build Status](https://travis-ci.org/LLK/scratch-audio.svg?branch=develop)](https://travis-ci.org/LLK/scratch-audio)
8+
[![CircleCI](https://circleci.com/gh/LLK/scratch-audio/tree/develop.svg?style=shield&circle-token=3792f4f51158c8c9b448527466ffe302b0c6f0f5)](https://circleci.com/gh/LLK/scratch-audio?branch=develop)
99

1010
## Installation
1111
This requires you to have Git and Node.js installed.

0 commit comments

Comments
 (0)