-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add publish.sh to publish to NPM-JS and Github Pages. #429
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
220a9d9
Add publish.sh to publish to NPM-JS and Github Pages.
RomainMuller 7829bd9
Publish documentations to historized folder, too.
RomainMuller bfe05b0
Make cdk docs open github pages
RomainMuller e9c296f
Make URL to documentation visible in case opening the browser fails.
RomainMuller b252fb1
Unconditionally showing URL in output of cdk docs
RomainMuller 18c758d
Fix broken test.
RomainMuller 8ae9eb0
Ouput URL only
RomainMuller a62fb85
Exit success even if opening the browser fails.
RomainMuller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
### | ||
# Usage: ./publish.sh <release-zip> | ||
# | ||
# Publishes the content of a release bundle ZIP file to the standard package | ||
# repositories for the various supported languages: | ||
# * Javascript & TypeScript: NPM | ||
# * Documentation: GitHub Pages | ||
# * (More to come later) | ||
### | ||
|
||
if [ $# -ne 1 ]; then | ||
echo "Missing release zip file argument" | ||
echo "Usage: ./publish.sh <release-zip>" | ||
exit 1 | ||
fi | ||
|
||
RELEASE_BUNDLE=$1 | ||
if [ ! -f ${RELEASE_BUNDLE} ]; then | ||
echo "${RELEASE_BUNDLE} is not a file!" | ||
exit 127 | ||
fi | ||
|
||
############### | ||
# PREPARATION # | ||
############### | ||
|
||
declare -a CLEANUP=() | ||
function cleanup() { | ||
for ((i = 0; i < ${#CLEANUP[@]}; i++ )) | ||
do | ||
eval "${CLEANUP[$i]}" | ||
done | ||
echo '🍻 Done!' | ||
} | ||
trap cleanup 'EXIT' | ||
|
||
|
||
WORK_DIR=$(mktemp -d) | ||
CLEANUP+=("echo '🚮 Cleaning up working directory'" "rm -fr ${WORK_DIR}") | ||
echo "💼 Working directory: ${WORK_DIR}" | ||
|
||
echo "🗜 Unzipping release bundle (be patient - this may take a while)" | ||
unzip -q ${RELEASE_BUNDLE} -d ${WORK_DIR} | ||
|
||
####### | ||
# NPM # | ||
####### | ||
|
||
echo "📦 Publishing to NPM" | ||
REGISTRY='https://registry.npmjs.org/' | ||
OLD_REGISTRY=$(npm config get registry) | ||
if [ ${OLD_REGISTRY} != ${REGISTRY} ]; then | ||
echo "👉 Switching to NPM registry ${REGISTRY}" | ||
npm config set registry ${REGISTRY} | ||
CLEANUP+=("echo '👈 Resetting NPM registry to ${OLD_REGISTRY}'" "npm config set registry ${OLD_REGISTRY}") | ||
fi | ||
|
||
TOKENS=$(npm token list 2>&1 || echo '') | ||
if echo ${TOKENS} | grep 'EAUTHUNKNOWN' > /dev/null; then | ||
echo "🔑 Can't list tokens - apparently missing authentication info" | ||
npm login | ||
fi | ||
|
||
for TGZ in $(find ${WORK_DIR}/y/npm -iname '*.tgz'); do | ||
npm publish $TGZ --access=public | ||
done | ||
|
||
################ | ||
# GitHub Pages # | ||
################ | ||
|
||
echo "📖 Publishing to GitHub Pages" | ||
|
||
GIT_REPO=$(mktemp -d) | ||
CLEANUP+=("echo '🚮 Cleaning up GitHub Pages working copy'" "rm -fr ${GIT_REPO}") | ||
|
||
DOC_STAGING=$(mktemp -d) | ||
CLEANUP+=("echo '🚮 Cleaning up Documentations staging directory'" "rm -fr ${DOC_STAGING}") | ||
|
||
( | ||
cd ${DOC_STAGING} | ||
${WORK_DIR}/bin/y-npm i aws-cdk-docs --no-save | ||
) | ||
|
||
git clone -b gh-pages --depth=1 ssh://github.com/awslabs/aws-cdk ${GIT_REPO} | ||
rsync -ar --delete --exclude=/.git ${DOC_STAGING}/node_modules/aws-cdk-docs/dist/docs/ ${GIT_REPO}/ | ||
( | ||
cd ${GIT_REPO} | ||
git add . | ||
git commit -m "Release $(cat ${WORK_DIR}/.version)" | ||
git push | ||
) | ||
|
||
echo "✅ All OK!" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to maintain docs for all versions so it will be possible to point to a specific version when referencing the docs. So I think we should publish the docs to a per-version directory (i.e. /v0.7.3-beta) and /also/ publish the latest docs to the root (or just generate an index.html at the root with a redirect metadata). Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I've added code to copy the released doc both to the root and to a
versions/${version-number}
directory.