Skip to content

Commit 5996e43

Browse files
authored
Merge pull request #230 from documentcloud/fix-ci
2 parents 730c2ea + 880af82 commit 5996e43

File tree

5 files changed

+186
-4
lines changed

5 files changed

+186
-4
lines changed

.github/workflows/cd.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This workflow is like CI, but also builds the documentation and deploys to NPM
2+
# and gh-pages.
3+
4+
name: Continuous Deployment
5+
6+
on:
7+
push:
8+
branches: [prepublish]
9+
workflow_run:
10+
workflows: [Prepublication staging]
11+
types: [completed]
12+
13+
jobs:
14+
deploy:
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Use Node.js 14.x
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: 14.x
24+
- name: Configure yarn cache path
25+
run: yarn config set cache-folder ~/.yarn-cache
26+
- name: Restore yarn cache
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/.yarn-cache
30+
key: yarn-cache-14.x
31+
restore-keys: |
32+
yarn-cache-
33+
- name: Restore node_modules
34+
uses: actions/cache@v2
35+
with:
36+
path: node_modules
37+
key: node-modules-14.x-${{ hashFiles('yarn.lock') }}
38+
restore-keys: |
39+
node-modules-14.x-
40+
node-modules-
41+
- name: Install dependencies
42+
run: yarn
43+
- name: Build dist files and docs and run the tests
44+
run: yarn grunt dist docco tocdoc
45+
- name: Commit the build output
46+
uses: EndBug/add-and-commit@v5
47+
with:
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
- name: Publish to NPM
51+
run: yarn publish
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54+
- name: Merge into gh-pages
55+
uses: devmasx/[email protected]
56+
with:
57+
type: now
58+
target_branch: gh-pages
59+
github_token: ${{ secrets.GITHUB_TOKEN }}
60+
- uses: actions/checkout@v2
61+
with:
62+
ref: gh-pages
63+
- name: Tag the release
64+
uses: Klemensas/action-autotag@stable
65+
with:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
tag_prefix: v

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This workflow will install the node_modules, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Continuous Integration
5+
6+
on:
7+
push:
8+
branches: [master]
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [10.x, 14.x]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
- name: Configure yarn cache path
27+
run: yarn config set cache-folder ~/.yarn-cache
28+
- name: Restore yarn cache
29+
uses: actions/cache@v2
30+
with:
31+
path: ~/.yarn-cache
32+
key: yarn-cache-${{ matrix.node-version }}
33+
restore-keys: |
34+
yarn-cache-
35+
- name: Restore node_modules
36+
uses: actions/cache@v2
37+
with:
38+
path: node_modules
39+
key: node-modules-${{ matrix.node-version }}-${{ hashFiles('yarn.lock') }}
40+
restore-keys: |
41+
node-modules-${{ matrix.node-version }}-
42+
node-modules-
43+
- name: Install dependencies
44+
run: yarn
45+
- name: Run linter, concat, minifier and tests
46+
run: yarn dist

.github/workflows/prepublish.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# As an alternative to a manual push to the prepublish branch, this workflow can
2+
# be triggered on a release branch by assigning a special label to its pull
3+
# request in order to set the CD circus in motion.
4+
5+
name: Prepublication staging
6+
7+
on:
8+
pull_request:
9+
types: [labeled]
10+
branches:
11+
- release/*
12+
- hotfix/*
13+
14+
jobs:
15+
stage:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Merge into prepublish
20+
uses: devmasx/[email protected]
21+
with:
22+
label_name: ready to launch
23+
target_branch: prepublish
24+
github_token: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

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

DEPLOYING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# How to cut a new release for Underscore-contrib
2+
3+
This is a checklist for repository maintainers. It covers all the steps involved in releasing a new version, including publishing to NPM and updating the `gh-pages` branch. We have tried to automate as many of these steps as possible using GitHub Actions. The workflows involved are in the (hidden) `.github` directory.
4+
5+
A "regular" release includes new changes that were introduced to the `master` branch since the previous release. A *hotfix* release instead skips any such changes and only addresses urgent problems with the previous release.
6+
7+
8+
## Steps
9+
10+
1. Ensure your local `master` branch descends from the previous release branch and that it is in a state that you want to release. **Exception:** for hotfixes, ensure you have an up-to-date local copy of the previous release branch instead.
11+
2. Decide on the next version number, respecting [semver][semver]. For the sake of example we'll use `1.2.3` as a placeholder version throughout this checklist.
12+
3. Create a `release/1.2.3` branch based on `master`. **Exception:** if this is a hotfix, start from the previous release branch instead and call it `hotfix/1.2.3`.
13+
4. Bump the version number in the `package.json` and the `yarn.lock` by running the command `yarn version --no-git-tag-version`, with the extra flag `--major`, `--minor` or `--patch` depending on which part of the version number you're incrementing (e.g., `--patch` if you're bumping from 1.2.2 to 1.2.3). Note that you can configure `yarn` to always include the `--no-git-tag-version` flag so you don't have to type it every time.
14+
5. Bump the version number in the source code and in `docs/index.md` accordingly.
15+
6. Commit the changes from steps 4 and 5 with a commit message of the format `Bump the version to 1.2.3`.
16+
7. Add more commits to extend the change log and to update any other documentation that might require it. Ensure that all documentation looks good.
17+
8. Push the release branch and create a pull request against `master` (also if it is a hotfix).
18+
9. At your option, have the release branch reviewed and add more commits to satisfy any change requests.
19+
10. The "Continuous Integration" workflow will trigger automatically on the pull request. This runs the test suite against multiple environments. Wait for all checks to complete.
20+
11. If any checks fail, add more commits to fix and repeat from step 10.
21+
12. When all reviewers are satisfied and all checks pass, apply the "ready to launch" label to the pull request. This will trigger the "Prepublication staging" workflow, which will merge the release branch into the `prepublish` branch. Merge manually if the workflow fails for whatever reason. **Note:** do *not* merge into `master` yet.
22+
13. The merging of new changes into `prepublish` will trigger the "Continuous Deployment" workflow, which is documented below. **Pay attention as the deployment workflow progresses.**
23+
14. If the deployment workflow fails, identify the failing step and address as quickly as possible. Possible solution steps include:
24+
- Adding new commits to the release branch and repeating from step 12 (most likely if the docs fail to build for some reason).
25+
- Manually pushing new commits to the `prepublish` branch and repeating from step 13 (this might be needed in case of merge conflicts, although this is highly unlikely).
26+
- Manually running `yarn publish` (if something is wrong with the NPM registry or the authentication credentials).
27+
- Manually merging `prepublish` into `gh-pages` (in unlikely case of merge conflicts).
28+
- Manually tagging the release on `gh-pages`.
29+
15. When the deployment workflow has completed, double-check that the new version was published to NPM, that the website was updated and that the repository contains a tag for the new release.
30+
16. Finally merge the release branch into `master`, but keep the branch around for a few days in case you need to do a hotfix.
31+
17. Delete the release branch. You can still restore it if necessary, by tracing the history graph two commits back from the release tag.
32+
33+
34+
## Automated continuous deployment workflow
35+
36+
This workflow is defined in `.github/workflows/cd.yml`. Note that roughly the first half of the steps in that file consists of basic boilerplate to check out the source and install dependencies.
37+
38+
The publishing to NPM depends on a [secret][secrets] named `NPM_TOKEN`, representing the API token of the NPM account that owns the `underscore-contrib` package. Only admins of the documentcloud organization can access this setting.
39+
40+
1. Checkout the source, restore caches and install the dependencies.
41+
2. Run `yarn grunt dist docco tocdoc`.
42+
3. Commit the output of the previous step to the `prepublish` branch.
43+
4. Publish to NPM.
44+
5. Merge the `prepublish` branch into `gh-pages`.
45+
6. Tag the tip of `gh-pages` with the version number in the `package.json`.
46+
47+
48+
[semver]: https://semver.org
49+
[secrets]: https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets

0 commit comments

Comments
 (0)