Skip to content

Commit

Permalink
chore!: drop node10 support + switch to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed May 18, 2021
1 parent 32a4fd0 commit 1e9ffb3
Show file tree
Hide file tree
Showing 5 changed files with 628 additions and 372 deletions.
223 changes: 6 additions & 217 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,223 +1,12 @@
version: 2
version: 2.1
jobs:
test-node-10:
noop:
docker:
- image: circleci/node:10
working_directory: ~/project
- image: alpine:3.11.3
steps:
- checkout
- restore_cache:
keys:
- yarn-cache-10-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-cache-10-{{ .Branch }}
- yarn-cache-10-
- run: yarn install
- save_cache:
key: yarn-cache-10-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths: [node_modules]
- run: yarn test

test-latest(node-12):
docker:
- image: circleci/node:12
working_directory: ~/project
steps:
- checkout
- attach_workspace:
at: ~/project
- restore_cache:
keys:
- yarn-cache-12-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-cache-12-{{ .Branch }}
- yarn-cache-12-

- run: yarn install

- save_cache:
key: yarn-cache-12-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths: [node_modules]

- run: yarn test
- run: yarn send-coverage
- run: yarn docs:test

- persist_to_workspace:
root: .
paths: [.]
- store_artifacts:
path: ./coverage/clover.xml
prefix: tests
- store_artifacts:
path: coverage
prefix: coverage
- store_test_results:
path: ./coverage/clover.xml

validate-dependencies:
docker:
- image: circleci/node:12
working_directory: ~/project
steps:
- checkout
- restore_cache:
keys:
- yarn-cache-12-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-cache-12-{{ .Branch }}
- yarn-cache-12-

- run: yarn install
- run:
name: yarn validate:dependencies
command: |
if ! git log --format=oneline -n 1 | grep -q "\[ignore-audit\]"; then
yarn validate:dependencies
else
echo "Skipping audit"
fi
validate-all-dependencies:
docker:
- image: circleci/node:12
working_directory: ~/project
steps:
- checkout
- restore_cache:
keys:
- yarn-cache-12-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-cache-12-{{ .Branch }}
- yarn-cache-12-

- run: yarn install
- run: yarn validate:dependencies
- run: yarn validate:dev-dependencies

release:
docker:
- image: circleci/node:12
working_directory: ~/project
steps:
- attach_workspace:
at: ~/project
- add_ssh_keys:
fingerprints:
- '76:a4:ac:1c:ba:8c:57:f1:4c:66:1b:85:fe:44:64:52'
- run: mkdir -p ~/.ssh
- run:
name: Keyscan Github
command: ssh-keyscan -H github.com >> ~/.ssh/known_hosts
# Clean working tree, tag, and push
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "superflytvab"
- run:
name: Determine release type
command: |
if ! git log --format=oneline -n 1 | grep -q "\[release\]"; then
echo "Pre-release"
COMMIT_TIMESTAMP=$(git log -1 --pretty=format:%ct HEAD)
COMMIT_DATE=$(date -d @$COMMIT_TIMESTAMP +%Y%m%d-%H%M%S)
GIT_HASH=$(git rev-parse --short HEAD)
echo "export RELEASE_ARGS=\"--prerelease nightly-$COMMIT_DATE-$GIT_HASH --skip.changelog --skip.tag --skip.commit\"" >> $BASH_ENV
echo 'export PUBLISH_ARGS="--tag nightly"' >> $BASH_ENV
source $BASH_ENV
else
echo "Release"
fi
- run: yarn release $RELEASE_ARGS
- run:
name: Git push
command: |
if ! [ "$RELEASE_ARGS" ]; then
git push --follow-tags origin HEAD
fi
# Build and deploy
- run: yarn install
- run: yarn build
- run:
name: Write NPM Token to ~/.npmrc
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Publish to NPM with yarn
command: NEW_VERSION=$(node -p "require('./package.json').version") && yarn publish --access=public --new-version=$NEW_VERSION --network-timeout 100000 $PUBLISH_ARGS

prerelease:
docker:
- image: circleci/node:12
working_directory: ~/project
steps:
- attach_workspace:
at: ~/project
- run:
name: Check release is desired
command: |
if ! git log --format=oneline -n 1 | grep -q "\[publish\]"; then
echo "Skip"
circleci-agent step halt
else
echo "Publish experimental"
fi
- add_ssh_keys:
fingerprints:
- 'ca:54:a9:03:b6:45:45:80:ca:b9:ee:1e:cb:22:1b:a3'
- run: mkdir -p ~/.ssh
- run:
name: Keyscan Github
command: ssh-keyscan -H github.com >> ~/.ssh/known_hosts
# Clean working tree, tag, and push
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "superflytvab"
- run:
name: yarn release
command: |
COMMIT_TIMESTAMP=$(git log -1 --pretty=format:%ct HEAD)
COMMIT_DATE=$(date -d @$COMMIT_TIMESTAMP +%Y%m%d-%H%M%S)
GIT_HASH=$(git rev-parse --short HEAD)
PRERELEASE_TAG=nightly-$(echo $CIRCLE_BRANCH | sed -r 's/[^a-z0-9]+/-/gi')
yarn release --prerelease $PRERELEASE_TAG-$COMMIT_DATE-$GIT_HASH --skip.changelog --skip.tag --skip.commit
# Build and deploy
- run: yarn install
- run: yarn build
- run:
name: Write NPM Token to ~/.npmrc
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Publish to NPM with yarn
command: NEW_VERSION=$(node -p "require('./package.json').version") && yarn publish --access=public --new-version=$NEW_VERSION --network-timeout 100000 --tag experimental
- run: exit 0

workflows:
version: 2
build-test-publish:
build:
jobs:
- test-latest(node-12)
- test-node-10
- validate-all-dependencies:
filters:
branches:
only:
- master
- validate-dependencies:
filters:
branches:
only:
- master
- develop
- release:
requires:
- validate-dependencies
- test-latest(node-12)
- test-node-10
filters:
branches:
only:
- master
- prerelease:
requires:
- test-latest(node-12)
- test-node-10
filters:
tags:
ignore: /.*/
branches:
ignore:
- master
- noop
Loading

0 comments on commit 1e9ffb3

Please sign in to comment.