From ecdc65e162942c338ab94f633a40e9e8c214f174 Mon Sep 17 00:00:00 2001 From: Ian K Smith Date: Fri, 12 Apr 2019 22:14:16 -0600 Subject: [PATCH] Update CircleCI config --- .circleci/config.yml | 110 ++++++++++++++++++++++++++++++++++--------- .grenrc.json | 6 +++ package.json | 11 +++-- 3 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 .grenrc.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 05a4189..7eb3855 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,21 +22,31 @@ aliases: paths: - node_modules - - &dist-paths + - &build-output-paths paths: - dist - &semver-regex /^v\d+\.\d+\.\d+$/ - - &filter-tagged + - &semver-canary-regex + /^v\d+\.\d+\.\d+-.+$/ + + - &tagged-for-release filters: tags: only: *semver-regex branches: ignore: /.*/ - - &filter-untagged + - &tagged-for-canary-release + filters: + tags: + only: *semver-regex + branches: + ignore: /.*/ + + - &untagged filters: tags: ignore: /.*/ @@ -95,7 +105,7 @@ jobs: name: Build modules command: yarn build - persist_to_workspace: - <<: *dist-paths + <<: *build-output-paths root: *workspace-root # Run unit tests. @@ -118,11 +128,36 @@ jobs: name: Authenticate with registry command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc - run: - name: Publish packages to NPM + name: Publish package to NPM command: npm publish - # Create release notes on GitHub. - publish-release-to-github: + # Publish the package as a pre-release version to NPM. This should depend on + # the `build` job. + release-canary: + executor: default + steps: + - checkout + - *attach-workspace + - run: + name: Authenticate with registry + command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc + - run: + name: Publish pre-release package to NPM + command: npm publish --tag next + + # In case the `release` or `release-canary` jobs fail, this will remove the + # problematic tag from the remote repository. + unrelease: + executor: default + steps: + - checkout + - *attach-workspace + - run: + name: Delete git tag '$CIRCLE_TAG' + command: git push -q --delete https://$GITHUB_REPO_TOKEN@github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git $CIRCLE_TAG + + # Create release notes on GitHub using the `github-release-notes` package. + generate-release-notes: executor: default steps: - checkout @@ -131,7 +166,7 @@ jobs: name: Install github-release-notes package command: yarn add github-release-notes - run: - name: Create a release and publish to GitHub + name: Generate release notes and publish to GitHub command: npx gren release --override --token $GITHUB_REPO_TOKEN # --- Workflow definitions --------------------------------------------------- # @@ -140,53 +175,86 @@ jobs: workflows: version: 2.1 - # Builds, lints, and tests pushed code. + # Builds modules, verifies code with the linter, and runs unit tests. pull-request: jobs: - - install-dependencies: *filter-untagged + - install-dependencies: *untagged - lint: - <<: *filter-untagged + <<: *untagged requires: - install-dependencies - build: - <<: *filter-untagged + <<: *untagged requires: - lint - test: - <<: *filter-untagged + <<: *untagged requires: - lint - # Builds, lints, and tests, and publishes semver-tagged code to NPM. + # Builds modules, verifies code with the linter, runs unit tests, and + # publishes the built package to NPM. publish-to-npm: jobs: - - install-dependencies: *filter-tagged + - install-dependencies: *tagged-for-release - lint: - <<: *filter-tagged + <<: *tagged-for-release requires: - install-dependencies - build: - <<: *filter-tagged + <<: *tagged-for-release requires: - lint - test: - <<: *filter-tagged + <<: *tagged-for-release requires: - lint - release: - <<: *filter-tagged + <<: *tagged-for-release requires: - build - test - - publish-release-to-github: - <<: *filter-tagged + - generate-release-notes: + <<: *tagged-for-release requires: - release + + # Builds modules, verifies code with the linter, runs unit tests, and + # publishes a pre-release version of the built package to NPM. + publish-canary-to-npm: + jobs: + - install-dependencies: *tagged-for-canary-release + + - lint: + <<: *tagged-for-canary-release + requires: + - install-dependencies + + - build: + <<: *tagged-for-canary-release + requires: + - lint + + - test: + <<: *tagged-for-canary-release + requires: + - lint + + - release-canary: + <<: *tagged-for-canary-release + requires: + - build + - test + + - generate-release-notes: + <<: *tagged-for-canary-release + requires: + - release-canary diff --git a/.grenrc.json b/.grenrc.json new file mode 100644 index 0000000..d021faf --- /dev/null +++ b/.grenrc.json @@ -0,0 +1,6 @@ +{ + "groupBy": { + "Enhancements:": ["enhancement"], + "Bug Fixes:": ["bug"] + } +} diff --git a/package.json b/package.json index 4241048..076d9de 100644 --- a/package.json +++ b/package.json @@ -25,16 +25,17 @@ "clean:dist": "rimraf dist", "clean:test-dist": "rimraf test/dist", "clean:cache": "rimraf .rts2_cache_*", - "test-watch": "npm-run-all -s test:compile -p test-watch:*", - "test-watch:compile": "tsc -w -p ./test", - "test-watch:run": "chokidar \"./test/dist/**/*.spec.js\" -c \"npm run test:run\" --initial \"npm run test:run\"", + "test_watch": "npm-run-all -s test:compile -p test_watch:*", + "test_watch:compile": "tsc -w -p ./test", + "test_watch:run": "chokidar \"./test/dist/**/*.spec.js\" -c \"npm run test:run\" --initial \"npm run test:run\"", "test": "npm-run-all -s clean:test-dist test:*", "test:compile": "tsc -p ./test", "test:run": "alsatian ./test/dist/**/*.spec.js", "lint": "tslint --fix -p .", - "prepublishOnly": "npm run build", "release": "PACKAGE_VERSION=$(node -pe \"require('./package.json')['version']\") && git tag v$PACKAGE_VERSION && git push origin v$PACKAGE_VERSION", - "unrelease": "PACKAGE_VERSION=$(node -pe \"require('./package.json')['version']\") && git tag -d v$PACKAGE_VERSION && git push --delete origin v$PACKAGE_VERSION" + "unrelease": "PACKAGE_VERSION=$(node -pe \"require('./package.json')['version']\") && git tag -d v$PACKAGE_VERSION && git push --delete origin v$PACKAGE_VERSION", + "release_canary": "PACKAGE_VERSION=$(node -pe \"require('./package.json')['version']\") && git tag v$PACKAGE_VERSION && git push origin v$PACKAGE_VERSION", + "unrelease_canary": "PACKAGE_VERSION=$(node -pe \"require('./package.json')['version']\") && git tag -d v$PACKAGE_VERSION && git push --delete origin v$PACKAGE_VERSION" }, "devDependencies": { "@ikscodes/tslint-config": "^5.3.1",