mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -05:00
137 lines
3.5 KiB
YAML
137 lines
3.5 KiB
YAML
version: 2.1
|
|
orbs:
|
|
node: circleci/node@5.0.2
|
|
browser-tools: circleci/browser-tools@1.2.4
|
|
aliases:
|
|
- &defaults
|
|
docker:
|
|
- image: cimg/node:lts-browsers
|
|
auth:
|
|
username: $DOCKERHUB_USERNAME
|
|
password: $DOCKERHUB_PASSWORD
|
|
working_directory: ~/repo
|
|
environment:
|
|
NODE_ENV: production
|
|
- &setup
|
|
node/install-packages:
|
|
override-ci-command: npm --production=false ci
|
|
- &lint
|
|
run:
|
|
name: "run lint tests"
|
|
command: npm run lint -- --format junit -o ./test/results/lint-results.xml
|
|
- &unit
|
|
run:
|
|
name: "run unit tests"
|
|
command: JEST_JUNIT_OUTPUT_NAME=unit-jest-results.xml npm run unit -- --reporters=jest-junit
|
|
- &build
|
|
run:
|
|
name: "run npm build"
|
|
command: |
|
|
NODE_ENV=production npm run build
|
|
- &tag-setup
|
|
run:
|
|
name: "setup tags"
|
|
command: |
|
|
RELEASE_TIMESTAMP="$(date +'%Y%m%d%H%M%S')"
|
|
VPKG=$($(npm bin)/json -f package.json version)
|
|
echo export RELEASE_VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP} >> $BASH_ENV
|
|
echo export NPM_TAG=latest >> $BASH_ENV
|
|
if [[ "$CIRCLE_BRANCH" == hotfix/* ]]; then # double brackets are important for matching the wildcard
|
|
echo export NPM_TAG=hotfix >> $BASH_ENV
|
|
fi
|
|
- &deploy-gh-pages
|
|
run:
|
|
name: "deploy to gh pages"
|
|
command: |
|
|
git config --global user.email $(git log --pretty=format:"%ae" -n1)
|
|
git config --global user.name $(git log --pretty=format:"%an" -n1)
|
|
npm run deploy -- -e $CIRCLE_BRANCH
|
|
- &deploy-npm
|
|
run:
|
|
name: "deploy to npm"
|
|
command: |
|
|
echo "npm tag: $NPM_TAG"
|
|
echo "release version: $RELEASE_VERSION"
|
|
npm version --no-git-tag-version $RELEASE_VERSION
|
|
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
|
|
npm publish --tag $NPM_TAG
|
|
- &tag-commit
|
|
run:
|
|
name: "tag commit in github"
|
|
command: |
|
|
echo $RELEASE_VERSION
|
|
git tag $RELEASE_VERSION
|
|
git push $CIRCLE_REPOSITORY_URL $RELEASE_VERSION
|
|
|
|
jobs:
|
|
build-test:
|
|
<<: *defaults
|
|
steps:
|
|
- checkout
|
|
- *setup
|
|
- *lint
|
|
- *unit
|
|
- *build
|
|
- store_test_results:
|
|
path: test/results
|
|
build-test-deploy:
|
|
<<: *defaults
|
|
steps:
|
|
- checkout
|
|
- *setup
|
|
- *lint
|
|
- *unit
|
|
- *build
|
|
- store_test_results:
|
|
path: test/results
|
|
- *tag-setup
|
|
- *deploy-gh-pages
|
|
- *deploy-npm
|
|
- *tag-commit
|
|
push-translations:
|
|
<<: *defaults
|
|
steps:
|
|
- checkout
|
|
- *setup
|
|
- run:
|
|
name: "run i18n script"
|
|
command: |
|
|
npm run i18n:src
|
|
npm run i18n:push
|
|
|
|
workflows:
|
|
build-test-no-deploy:
|
|
jobs:
|
|
- build-test:
|
|
context:
|
|
- dockerhub-credentials
|
|
filters:
|
|
branches:
|
|
ignore:
|
|
- master
|
|
- develop
|
|
- /^hotfix\/.*/
|
|
- gh-pages
|
|
build-test-deploy:
|
|
jobs:
|
|
- build-test-deploy:
|
|
context:
|
|
- dockerhub-credentials
|
|
filters:
|
|
branches:
|
|
only:
|
|
- master
|
|
- develop
|
|
- /^hotfix\/.*/
|
|
push-translations:
|
|
triggers:
|
|
- schedule:
|
|
cron: 0 0 * * * # daily at 12 UTC, 8 ET
|
|
filters:
|
|
branches:
|
|
only:
|
|
- develop
|
|
jobs:
|
|
- push-translations:
|
|
context:
|
|
- dockerhub-credentials
|