Skip to content

Commit

Permalink
build: publish docs-content bazel artifacts (angular#14634)
Browse files Browse the repository at this point in the history
  • Loading branch information
devversion authored and s2-abdo committed Jan 18, 2019
1 parent c15e2cf commit 16a4a05
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 510 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test --experimental_ui

# Configures script to do version stamping.
# See https://docs.bazel.build/versions/master/user-manual.html#flag--workspace_status_command
build:release --workspace_status_command=./tools/bazel-stamp-vars.sh
build:release --workspace_status_command="node ./tools/bazel-stamp-vars.js"

###############################
# Typescript / Angular / Sass #
Expand Down
16 changes: 9 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var_9: &docker-firefox-image
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
var_10: &attach_release_output
attach_workspace:
at: dist/releases
at: dist/


# Branch filter that we can specify for jobs that should only run on publish branches. This filter
Expand Down Expand Up @@ -250,9 +250,9 @@ jobs:
# Store the release output in the workspace storage. This means that other jobs
# in the same workflow can attach the release output to their job.
- persist_to_workspace:
root: dist/releases
root: dist
paths:
- "**/*"
- "releases/**/*"

# Since there is no UMD bundle that includes everything from the CDK, we need to move
# all bundles into a directory. This allows us to store all CDK UMD bundles as job
Expand Down Expand Up @@ -293,6 +293,9 @@ jobs:
# to publish the build snapshots. In order to fix this, we unset the global option.
- run: git config --global --unset "url.ssh://git@github.com.insteadof"

# TODO(devversion): Ideally the "build_release_packages" job should build all packages with
# Bazel, but for now we mix up the Gulp and bazel setup, so we need to build the package here.
- run: bazel build src/material-examples:npm_package --config=release
- run: ./scripts/circleci/publish-snapshots.sh


Expand Down Expand Up @@ -320,9 +323,7 @@ jobs:
workflows:
version: 2

# Build and test workflow. A workflow includes multiple jobs that run in parallel. All jobs
# that build and test source code should be part of this workflow
build_and_test:
bazel_targets:
jobs:
- bazel_build_test:
filters: *ignore_presubmit_branch_filter
Expand All @@ -347,7 +348,8 @@ workflows:

release_output:
jobs:
- build_release_packages
- build_release_packages:
filters: *ignore_presubmit_branch_filter
- build_devapp_aot:
filters: *ignore_presubmit_branch_filter
requires:
Expand Down
7 changes: 0 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
"e2e": "gulp e2e",
"deploy": "gulp deploy:devapp",
"webdriver-manager": "webdriver-manager",
"docs": "gulp docs",
"api": "gulp api-docs",
"breaking-changes": "gulp breaking-changes",
"gulp": "gulp",
"stage-release": "ts-node --project tools/release/ tools/release/stage-release.ts",
Expand Down Expand Up @@ -92,15 +90,10 @@
"gulp-clean": "^0.3.2",
"gulp-clean-css": "^3.3.1",
"gulp-cli": "^2.0.1",
"gulp-dom": "^0.9.17",
"gulp-flatten": "^0.3.1",
"gulp-highlight-files": "^0.0.5",
"gulp-htmlmin": "^3.0.0",
"gulp-if": "^2.0.2",
"gulp-markdown": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^4.0.2",
"gulp-transform": "^2.0.0",
"gulp-util": "^3.0.8",
"hammerjs": "^2.0.8",
"highlight.js": "^9.11.0",
Expand Down
3 changes: 0 additions & 3 deletions scripts/circleci/publish-snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ cd $(dirname ${0})/../..
# 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
Expand Down
38 changes: 6 additions & 32 deletions scripts/deploy/publish-docs-content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ if [ -z ${MATERIAL2_BUILDS_TOKEN} ]; then
exit 1
fi

if [[ ! ${*} == *--no-build* ]]; then
$(npm bin)/gulp material-examples:build-release:clean
$(npm bin)/gulp docs
fi

# Path to the project directory.
projectPath="$(pwd)"

Expand All @@ -28,8 +23,8 @@ docsDistPath="${projectPath}/dist/docs"
# Path to the cloned docs-content repository.
docsContentPath="${projectPath}/tmp/material2-docs-content"

# Path to the release output of the @angular/material-examples package.
examplesPackagePath="${projectPath}/dist/releases/material-examples"
# Path to the release output of the Bazel "@angular/material-examples" NPM package.
examplesPackagePath="$(bazel info bazel-bin)/src/material-examples/npm_package"

# Git clone URL for the material2-docs-content repository.
docsContentRepoUrl="https://github.com/angular/material2-docs-content"
Expand Down Expand Up @@ -79,33 +74,12 @@ fi
# Remove everything inside of the docs-content repository.
rm -Rf ${docsContentPath}/*

echo "Removed everything from the docs-content repository. Copying all files into repository.."

# Create all folders that need to exist in the docs-content repository.
mkdir ${docsContentPath}/{overview,guides,api,examples,stackblitz,examples-package}

# Copy API and example files to the docs-content repository.
cp -R ${docsDistPath}/api/* ${docsContentPath}/api
cp -r ${docsDistPath}/examples/* ${docsContentPath}/examples
cp -r ${docsDistPath}/stackblitz/* ${docsContentPath}/stackblitz

# Copy the @angular/material-examples package to the docs-content repository.
cp -r ${examplesPackagePath}/* ${docsContentPath}/examples-package

# Copy the license file to the docs-content repository.
cp ${projectPath}/LICENSE ${docsContentPath}

# Copy all immediate children of the markdown output the guides/ directory.
for guidePath in $(find ${docsDistPath}/markdown/ -maxdepth 1 -type f); do
cp ${guidePath} ${docsContentPath}/guides
done
echo "Removed everything from the docs-content repository. Copying package output.."

# All files that aren't immediate children of the markdown output are overview documents.
for overviewPath in $(find ${docsDistPath}/markdown/ -mindepth 2 -type f); do
cp ${overviewPath} ${docsContentPath}/overview
done
# Copy the package output to the docs-content repository.
cp -R ${examplesPackagePath}/* ${docsContentPath}

echo "Successfully copied all content into the docs-content repository."
echo "Successfully copied package output into the docs-content repository."

if [[ $(git ls-remote origin "refs/tags/${buildTagName}") ]]; then
echo "Skipping publish of docs-content because tag is already published. Exiting.."
Expand Down
38 changes: 38 additions & 0 deletions tools/bazel-stamp-vars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env node

/**
* Bazel workspace status script that is responsible for creating Bazel stamping variables.
* The stamping variables will be used by the NodeJS Bazel rules to provide proper version
* placeholder replacements. Read more about variable stamping within Bazel:
* https://docs.bazel.build/versions/master/user-manual.html#flag--workspace_status_command
*/

const spawnSync = require('child_process').spawnSync;
const packageJson = require('../package');

const currentCommitSha = getCurrentCommitSha();

// The "BUILD_SCM_VERSION" will be picked up by the "npm_package" and "ng_package" rule
// in order to replace the "0.0.0-PLACEHOLDER" with a proper version
console.log(`BUILD_SCM_VERSION ${packageJson.version}-${currentCommitSha.substr(0, 7)}`);
console.log(`BUILD_SCM_COMMIT_SHA ${currentCommitSha}`);
console.log(`BUILD_SCM_BRANCH ${getCurrentBranchName()}`);
console.log(`BUILD_SCM_USER ${getCurrentGitUser()}`);

/** Returns the commit SHA for the current git HEAD of the project. */
function getCurrentCommitSha() {
return spawnSync('git', ['rev-parse', 'HEAD']).stdout.toString().trim();
}

/** Returns the name of the currently checked out branch of the project. */
function getCurrentBranchName() {
return spawnSync('git', ['symbolic-ref', '--short', 'HEAD']).stdout.toString().trim();
}

/** Returns the name and email of the Git user that creates this release build. */
function getCurrentGitUser() {
const userName = spawnSync('git', ['config', 'user.name']).stdout.toString().trim();
const userEmail = spawnSync('git', ['config', 'user.email']).stdout.toString().trim();

return `${userName} <${userEmail}>`;
}
43 changes: 0 additions & 43 deletions tools/bazel-stamp-vars.sh

This file was deleted.

1 change: 0 additions & 1 deletion tools/gulp/gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import './tasks/ci';
import './tasks/clean';
import './tasks/default';
import './tasks/development';
import './tasks/docs';
import './tasks/example-module';
import './tasks/lint';
import './tasks/material-release';
Expand Down
Loading

0 comments on commit 16a4a05

Please sign in to comment.