-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4: Migrate to CircleCI.
- Loading branch information
Showing
8 changed files
with
1,436 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
|
||
# https://circleci.com/docs/2.1/language-javascript/ | ||
version: 2.1 | ||
commands: | ||
extract-changelog-version: | ||
steps: | ||
- run: | ||
name: extract changelog version | ||
working_directory: ~/eslint-config | ||
command: | | ||
VERSION=$(head -n1 CHANGELOG.md | grep -o '\([0-9]\+\.\)\{2\}[0-9]\+') | ||
echo "export VERSION=${VERSION}" >> $BASH_ENV | ||
echo "export CHANGELOG_VERSION=${VERSION}" >> $BASH_ENV | ||
echo "changelog version: ${VERSION}" | ||
extract-package-json-version: | ||
steps: | ||
- run: | ||
name: extract package.json version | ||
working_directory: ~/eslint-config | ||
command: | | ||
PACKAGE_JSON_VERSION=$(node -e "console.info(require('./package').version)") | ||
echo "export PACKAGE_JSON_VERSION=${PACKAGE_JSON_VERSION}" >> $BASH_ENV | ||
echo "package.json version: ${PACKAGE_JSON_VERSION}" | ||
extract-published-version: | ||
steps: | ||
- run: | ||
name: extract latest published version | ||
working_directory: ~/eslint-config | ||
command: | | ||
LIVE_VERSION=$(npm show @haensl/eslint-config version || true) | ||
[ -z "${LIVE_VERSION}" ] && LIVE_VERSION='0.0.0' | ||
echo "export LIVE_VERSION=${LIVE_VERSION}" >> ${BASH_ENV} | ||
echo "latest published version: ${LIVE_VERSION}" | ||
extract-versions: | ||
steps: | ||
- extract-changelog-version | ||
- extract-package-json-version | ||
- extract-published-version | ||
|
||
init: | ||
steps: | ||
- run: | ||
name: update npm | ||
command: sudo npm install -g npm@latest | ||
|
||
prepare-repo: | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: eslint-config-dependencies-{{ checksum "package-lock.json" }} | ||
- run: | ||
name: install dependencies | ||
command: npm i | ||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: eslint-config-dependencies-{{ checksum "package-lock.json" }} | ||
- extract-versions | ||
|
||
create-test-project: | ||
parameters: | ||
project_name: | ||
description: project name | ||
type: string | ||
default: test-app | ||
steps: | ||
- run: | ||
working-directory: /tmp | ||
name: create test application | ||
command: | | ||
mkdir /tmp/<< parameters.project_name >> | ||
cd /tmp/<< parameters.project_name >> && npm init -y && echo "Created package.json" && cat package.json | ||
package-information: | ||
steps: | ||
- run: | ||
name: install tree | ||
command: sudo apt-get -y install tree | ||
- run: | ||
name: gather bundle information | ||
command: | | ||
npm info @haensl/eslint-config@${VERSION} > ./bundle.info | ||
tree -s node_modules/@haensl/eslint-config >> ./bundle.info | ||
- store_artifacts: | ||
path: bundle.info | ||
|
||
workflows: | ||
version: 2 | ||
default: | ||
when: always | ||
jobs: | ||
- lint | ||
- bundle: | ||
requires: | ||
- lint | ||
- bundle-test: | ||
requires: | ||
- bundle | ||
- ensure-versioned-correctly: | ||
requires: | ||
- bundle | ||
- publish: | ||
requires: | ||
- ensure-versioned-correctly | ||
- bundle-test | ||
filters: | ||
branches: | ||
only: master | ||
- package-test: | ||
requires: | ||
- publish | ||
- publish-github-release: | ||
requires: | ||
- package-test | ||
|
||
jobs: | ||
lint: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/eslint-config | ||
steps: | ||
- init | ||
- prepare-repo | ||
- run: | ||
name: create test-results-folder | ||
command: mkdir -p test-results/eslint | ||
- run: | ||
name: lint | ||
command: npm run lint:ci | ||
- store_test_results: | ||
path: test-results | ||
|
||
bundle: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/eslint-config | ||
steps: | ||
- init | ||
- prepare-repo | ||
- extract-versions | ||
- run: | ||
name: pack | ||
environment: | ||
NODE_ENV: 'production' | ||
command: | | ||
npm pack | ||
mv haensl-eslint-config-${VERSION}.tgz haensl-eslint-config.tgz | ||
- store_artifacts: | ||
path: haensl-eslint-config.tgz | ||
- persist_to_workspace: | ||
root: ./ | ||
paths: | ||
- CHANGELOG.md | ||
- lib | ||
- README.md | ||
- LICENSE | ||
- package.json | ||
- package-lock.json | ||
- .npmignore | ||
- haensl-eslint-config.tgz | ||
|
||
bundle-test: | ||
docker: | ||
- image: circleci/node:lts | ||
steps: | ||
- init | ||
- attach_workspace: | ||
at: ~/eslint-config | ||
- extract-versions | ||
- create-test-project | ||
- run: | ||
name: install module | ||
working_directory: /tmp/test-app | ||
command: | | ||
npm i -S ~/eslint-config/haensl-eslint-config.tgz | ||
ensure-versioned-correctly: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/eslint-config | ||
steps: | ||
- init | ||
- attach_workspace: | ||
at: ~/eslint-config | ||
- extract-versions | ||
- run: | ||
name: changelog matches package.json | ||
command: | | ||
test ${PACKAGE_JSON_VERSION} = ${CHANGELOG_VERSION} | ||
- run: | ||
name: pacakge.json greater than live | ||
command: | | ||
node \<<VERSION_CHECK | ||
const pkgVersion = require('./package').version | ||
.split('.') | ||
.map((i) => parseInt(i, 10)); | ||
const liveVersion = process.env.LIVE_VERSION | ||
.split('.') | ||
.map((i) => parseInt(i, 10)); | ||
const isGreater = pkgVersion.reduce((isGreater, part, i) => { | ||
return isGreater || (part > liveVersion[i]); | ||
}, false); | ||
if (!isGreater) { | ||
process.exit(1); | ||
} | ||
VERSION_CHECK | ||
publish: | ||
docker: | ||
- image: circleci/node:lts | ||
working_directory: ~/eslint-config | ||
steps: | ||
- init | ||
- attach_workspace: | ||
at: ~/eslint-config | ||
- run: | ||
name: setup npm registry token | ||
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | ||
- run: | ||
name: publish node module | ||
command: npm publish --access public | ||
|
||
package-test: | ||
docker: | ||
- image: circleci/node:lts | ||
steps: | ||
- init | ||
- create-test-project | ||
- run: | ||
name: install module | ||
working_directory: /tmp/test-app | ||
command: | | ||
npm i -S @haensl/eslint-config | ||
- package-information | ||
|
||
publish-github-release: | ||
docker: | ||
- image: cibuilds/github | ||
steps: | ||
- attach_workspace: | ||
at: ~/eslint-config | ||
- extract-changelog-version | ||
- run: | ||
name: publish github release | ||
working_directory: ~/eslint-config | ||
command: | | ||
cp ./haensl-eslint-config.tgz ./haensl-eslint-config-${VERSION}.tgz | ||
CHANGES=$(awk "/## ${VERSION}/,/^$/" CHANGELOG.md) | ||
echo "Publishing release v${VERSION} to Github.\nChanges:" | ||
echo $CHANGES | ||
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete -n "v${VERSION}" -b "${CHANGES}" "v${VERSION}" ./haensl-eslint-config-${VERSION}.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,5 @@ typings/ | |
|
||
# next.js build output | ||
.next | ||
|
||
test-results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.md | ||
.* | ||
test-results/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.