Skip to content

Commit

Permalink
ci: add scripts to automate publishing of releases, and deployment of…
Browse files Browse the repository at this point in the history
… docs (#1903)

Closes #1555
  • Loading branch information
brandonroberts authored Jun 3, 2019
1 parent 0407c5b commit 5a09844
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 2 deletions.
67 changes: 67 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ jobs:
paths:
- ~/docs/projects/ngrx.io/node_modules

deploy-docs-stable:
<<: *run_in_node
working_directory: ~/docs/projects/ngrx.io
steps:
- checkout:
path: ~/docs
- restore_cache:
keys:
- *cache_key
- *docs_cache_key
- run: npm rebuild node-sass
- run: yarn build --progress false --output-path dist/ngrx.io/ && yarn copy-404-page
- run: cp -rf src/extra-files/stable/. dist/ngrx.io/
- run:
name: Deploy Docs to Firebase
command: ./node_modules/.bin/firebase deploy --only hosting:stable --token=$FIREBASE_DEPLOY_TOKEN

deploy:
<<: *run_in_node
steps:
Expand All @@ -183,6 +200,32 @@ jobs:
at: dist
- run: yarn run deploy:builds

publish-stable:
<<: *run_in_node
steps:
- checkout
- restore_cache:
key: *cache_key
- attach_workspace:
at: dist
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
- run: yarn run publish:stable

publish-next:
<<: *run_in_node
steps:
- checkout
- restore_cache:
key: *cache_key
- attach_workspace:
at: dist
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
- run: yarn run publish:next

cleanup-previews:
<<: *run_in_node
steps:
Expand Down Expand Up @@ -239,3 +282,27 @@ workflows:
filters:
branches:
only: master
# - publish-stable:
# requires:
# - test
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /\d+\.\d+\.\d+(?!-\w+\.\d)/
# - deploy-docs-stable:
# requires:
# - test
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /\d+\.\d+\.\d+(?!-\w+\.\d)/
- publish-next:
requires:
- test
filters:
branches:
ignore: /.*/
tags:
only: /\d+\.\d+\.\d+(-\w+\.\d)/
36 changes: 36 additions & 0 deletions build/publish-latest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as util from './util';
import { createBuilder } from './util';
import { Config, packages } from './config';
import * as shelljs from 'shelljs';

/**
* Publish release to NPM on "latest" tag
*/
export async function publishToNpm(config: Config) {
for (let pkg of util.getTopLevelPackages(config)) {
console.log(`Publishing @ngrx/${pkg}`);

const cmd = [
'./node_modules/.bin/bazel run',
`//modules/${pkg}:npm_package.publish`,
'--',
'--access=public',
'--tag=latest',
'--dry-run',
];

shelljs.exec(cmd.join(' '));
}
}

const publishLatest = createBuilder([
['Publish packages on latest', publishToNpm],
]);

publishLatest({
scope: '@ngrx',
packages,
}).catch(err => {
console.error(err);
process.exit(1);
});
35 changes: 35 additions & 0 deletions build/publish-next.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as util from './util';
import { createBuilder } from './util';
import { Config, packages } from './config';
import * as shelljs from 'shelljs';

/**
* Publish release to NPM on "next" tag
*/
export async function publishNextToNpm(config: Config) {
for (let pkg of util.getTopLevelPackages(config)) {
console.log(`Publishing @ngrx/${pkg}`);

const cmd = [
'./node_modules/.bin/bazel run',
`//modules/${pkg}:npm_package.publish`,
'--',
'--access=public',
'--tag=next',
];

shelljs.exec(cmd.join(' '));
}
}

const publishNext = createBuilder([
['Publish packages on next', publishNextToNpm],
]);

publishNext({
scope: '@ngrx',
packages,
}).catch(err => {
console.error(err);
process.exit(1);
});
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test": "nyc yarn run test:unit",
"test:bazel": "bazel test //modules/...",
"clean": "git clean -xdf",
"clean:bazel": "bazel clean",
"cli": "ng",
"coverage:html": "nyc report --reporter=html",
"copy:dist": "ncp dist/ ./node_modules/@ngrx/",
Expand All @@ -33,7 +34,9 @@
"bazel:lint": "yarn bazel:format --lint=warn",
"bazel:lint-fix": "yarn bazel:format --lint=fix",
"copy:schematics": "ts-node ./build/copy-schematics-core.ts",
"build:stackblitz": "ts-node ./build/stackblitz.ts && git add ./stackblitz.html"
"build:stackblitz": "ts-node ./build/stackblitz.ts && git add ./stackblitz.html",
"publish:next": "ts-node ./build/publish-next.ts",
"publish:latest": "ts-node ./build/publish-latest.ts"
},
"engines": {
"node": ">=10.9.0 <=11.12.0",
Expand Down Expand Up @@ -117,6 +120,7 @@
"@types/node": "^7.0.5",
"@types/ora": "^1.3.1",
"@types/rimraf": "^0.0.28",
"@types/shelljs": "^0.8.5",
"chokidar": "^1.7.0",
"chokidar-cli": "^1.2.0",
"codelyzer": "^5.0.0",
Expand Down Expand Up @@ -154,6 +158,7 @@
"replace-in-file": "^3.1.1",
"rimraf": "^2.5.4",
"rollup": "^0.50.0",
"shelljs": "^0.8.3",
"sorcery": "^0.10.0",
"ts-loader": "^5.3.3",
"ts-node": "^5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion projects/ngrx.io/src/extra-files/stable/robots.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Allow all URLs (see http://www.robotstxt.org/robotstxt.html)
User-agent: *
Disallow:
Sitemap: https://angular.io/generated/sitemap.xml
Sitemap: https://ngrx.io/generated/sitemap.xml
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,14 @@
version "2.53.43"
resolved "https://registry.yarnpkg.com/@types/selenium-webdriver/-/selenium-webdriver-2.53.43.tgz#2de3d718819bc20165754c4a59afb7e9833f6707"

"@types/shelljs@^0.8.5":
version "0.8.5"
resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.5.tgz#1e507b2f6d1f893269bd3e851ec24419ef9beeea"
integrity sha512-bZgjwIWu9gHCjirKJoOlLzGi5N0QgZ5t7EXEuoqyWCHTuSddURXo3FOBYDyRPNOWzZ6NbkLvZnVkn483Y/tvcQ==
dependencies:
"@types/glob" "*"
"@types/node" "*"

"@types/sinon-chai@3.2.2":
version "3.2.2"
resolved "https://registry.yarnpkg.com/@types/sinon-chai/-/sinon-chai-3.2.2.tgz#5cfdbda70bae30f79a9423334af9e490e4cce793"
Expand Down Expand Up @@ -9988,6 +9996,15 @@ shelljs@0.8.2, shelljs@^0.8.1:
interpret "^1.0.0"
rechoir "^0.6.2"

shelljs@^0.8.3:
version "0.8.3"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.3.tgz#a7f3319520ebf09ee81275b2368adb286659b097"
integrity sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A==
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"

shellwords@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
Expand Down

0 comments on commit 5a09844

Please sign in to comment.