diff --git a/.circleci/config.yml b/.circleci/config.yml index 76358d8915..a247d3cdef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -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: @@ -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)/ \ No newline at end of file diff --git a/build/publish-latest.ts b/build/publish-latest.ts new file mode 100644 index 0000000000..15b0c7660b --- /dev/null +++ b/build/publish-latest.ts @@ -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); +}); diff --git a/build/publish-next.ts b/build/publish-next.ts new file mode 100644 index 0000000000..a4abf373be --- /dev/null +++ b/build/publish-next.ts @@ -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); +}); diff --git a/package.json b/package.json index 3a8686f535..5d56cc98c2 100644 --- a/package.json +++ b/package.json @@ -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/", @@ -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", @@ -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", @@ -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", diff --git a/projects/ngrx.io/src/extra-files/stable/robots.txt b/projects/ngrx.io/src/extra-files/stable/robots.txt index 7ff3ad772b..e3e8ce9957 100644 --- a/projects/ngrx.io/src/extra-files/stable/robots.txt +++ b/projects/ngrx.io/src/extra-files/stable/robots.txt @@ -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 diff --git a/yarn.lock b/yarn.lock index 13e083c57a..24d462fff0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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"