From 62f35dd67c1fed6d780ddfc74de4966b84043384 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 2 Nov 2018 00:53:28 +0100 Subject: [PATCH] build: move snapshot publish job to circleci (#13882) Also switch to a single GitHub deploy token --- .circleci/config.yml | 25 +++++++++++++++++++++++ .travis.yml | 4 ---- scripts/circleci/publish-snapshots.sh | 19 +++++++++++++++++ scripts/deploy/publish-build-artifacts.sh | 2 +- scripts/deploy/publish-docs-content.sh | 8 ++++---- 5 files changed, 49 insertions(+), 9 deletions(-) create mode 100755 scripts/circleci/publish-snapshots.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b318016844..e0dc265590b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -202,6 +202,28 @@ jobs: - *save_cache + # ---------------------------------------- + # Job that publishes the build snapshots + # ---------------------------------------- + publish_snapshots: + <<: *job_defaults + steps: + # Since CircleCI currently does not have any way to easily restrict jobs to only run + # for push builds, we need to manually skip publishing if the jobs runs for a PR. + # https://discuss.circleci.com/t/workflows-pull-request-filter/14396/11 + - run: + name: Check whether this job should be skipped. + command: '[[ -n ${CIRCLE_PR_NUMBER} ]] && circleci step halt || true' + + - *checkout_code + - *restore_cache + - *yarn_install + - *attach_release_output + + - run: ./scripts/circleci/publish-snapshots.sh + + - *save_cache + # ---------------------------------------------------------------------------------------- # Workflow definitions. A workflow usually groups multiple jobs together. This is useful if # one job depends on another. @@ -234,6 +256,9 @@ workflows: - build_demoapp_aot: requires: - build_release_packages + - publish_snapshots: + requires: + - build_release_packages # Lint workflow. As we want to lint in one job, this is a workflow with just one job. lint: diff --git a/.travis.yml b/.travis.yml index 7a313c7897a..e85a1c11019 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,10 +27,6 @@ jobs: include: - env: "MODE=payload" - env: "MODE=saucelabs_required" - - env: "DEPLOY_MODE=build-artifacts" - if: type = push - - env: "DEPLOY_MODE=docs-content" - if: type = push - env: "DEPLOY_MODE=dashboard" if: type = cron env: diff --git a/scripts/circleci/publish-snapshots.sh b/scripts/circleci/publish-snapshots.sh new file mode 100755 index 00000000000..2e5ec0a0638 --- /dev/null +++ b/scripts/circleci/publish-snapshots.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# This script should fail if one of the individual publish scripts fails. +set -e + +# Go to project directory. +cd $(dirname ${0})/../.. + +# Deploy build artifacts to the GitHub build repositories. The release output is already +# fetched from the CircleCI workspace storage. +./scripts/deploy/publish-build-artifacts.sh --no-build + +# Build the docs output before publishing the docs content. +yarn gulp docs + +# Deploy the docs content to the Github repository. We don't want to build the examples +# package here again because it's already fetched from the CircleCI workspace storage. +./scripts/deploy/publish-docs-content.sh --no-build + diff --git a/scripts/deploy/publish-build-artifacts.sh b/scripts/deploy/publish-build-artifacts.sh index 25888eaed98..2a9bea28331 100755 --- a/scripts/deploy/publish-build-artifacts.sh +++ b/scripts/deploy/publish-build-artifacts.sh @@ -31,7 +31,7 @@ publishPackage() { buildDir="$(pwd)/dist/releases/${packageName}" buildVersion=$(node -pe "require('./package.json').version") - branchName=${TRAVIS_BRANCH:-'master'} + branchName=${CIRCLE_BRANCH:-'master'} commitSha=$(git rev-parse --short HEAD) commitAuthorName=$(git --no-pager show -s --format='%an' HEAD) diff --git a/scripts/deploy/publish-docs-content.sh b/scripts/deploy/publish-docs-content.sh index 311c7c68d82..eec9915d340 100755 --- a/scripts/deploy/publish-docs-content.sh +++ b/scripts/deploy/publish-docs-content.sh @@ -8,9 +8,9 @@ set -e cd "$(dirname $0)/../../" -if [ -z ${MATERIAL2_DOCS_CONTENT_TOKEN} ]; then +if [ -z ${MATERIAL2_BUILDS_TOKEN} ]; then echo "Error: No access token for GitHub could be found." \ - "Please set the environment variable 'MATERIAL2_DOCS_CONTENT_TOKEN'." + "Please set the environment variable 'MATERIAL2_BUILDS_TOKEN'." exit 1 fi @@ -38,7 +38,7 @@ docsContentRepoUrl="https://github.com/angular/material2-docs-content" buildVersion=$(node -pe "require('./package.json').version") # Name of the branch that is currently being deployed. -branchName=${TRAVIS_BRANCH:-'master'} +branchName=${CIRCLE_BRANCH:-'master'} # Additional information about the last commit for docs-content commits. commitSha=$(git rev-parse --short HEAD) @@ -117,7 +117,7 @@ git config user.name "$commitAuthorName" git config user.email "$commitAuthorEmail" git config credential.helper "store --file=.git/credentials" -echo "https://${MATERIAL2_DOCS_CONTENT_TOKEN}:@github.com" > .git/credentials +echo "https://${MATERIAL2_BUILDS_TOKEN}:@github.com" > .git/credentials echo "Credentials for docs-content repository are now set up. Publishing.."