-
Notifications
You must be signed in to change notification settings - Fork 9.2k
build.sh accepts version argument #4342
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,46 +2,80 @@ | |
|
||
# Author: @MikeRalphson | ||
|
||
# run this script from the root of the repo. It is designed to be run by a GitHub workflow. | ||
# It contains bashisms | ||
# run this script from the root of the repo | ||
# It is designed to be run by a GitHub workflow | ||
|
||
mkdir -p deploy/oas | ||
mkdir -p deploy/js | ||
# Usage: build.sh [version | "latest" | "src"] | ||
# When run with no arguments, it builds artifacts for all published specification versions. | ||
# It may also be run with a specific version argument, such as "3.1.1" or "latest" | ||
# Finally, it may be run with "src" to build "src/oas.md" | ||
# | ||
# It contains bashisms | ||
|
||
cd scripts/md2html | ||
if [ -z "$1" ]; then | ||
deploydir="deploy/oas" | ||
else | ||
deploydir="deploy-preview" | ||
fi | ||
|
||
cp -p ../../node_modules/respec/builds/respec-w3c.* ../../deploy/js/ | ||
mkdir -p $deploydir/js | ||
mkdir -p $deploydir/temp | ||
|
||
latest=`git describe --abbrev=0 --tags` | ||
latestCopied=none | ||
latest=$(git describe --abbrev=0 --tags) | ||
latestCopied="none" | ||
lastMinor="-" | ||
for filename in $(ls -1 ../../versions/[23456789].*.md | sort -r) ; do | ||
if [[ ${filename} == *-editors.md ]];then | ||
continue | ||
fi | ||
|
||
version=$(basename "$filename" .md) | ||
if [ -z "$1" ]; then | ||
specifications=$(ls -1 versions/[23456789].*.md | grep -v -e "\-editors" | sort -r) | ||
elif [ "$1" = "latest" ]; then | ||
specifications=$(ls -1 versions/$latest.md) | ||
elif [ "$1" = "src" ]; then | ||
specifications="src/oas.md" | ||
else | ||
specifications=$(ls -1 versions/$1.md) | ||
fi | ||
|
||
cp -p node_modules/respec/builds/respec-w3c.* $deploydir/js/ | ||
|
||
for specification in $specifications; do | ||
version=$(basename $specification .md) | ||
minorVersion=${version:0:3} | ||
tempfile=../../deploy/oas/v$version-tmp.html | ||
echo -e "\n=== v$version ===" | ||
tempfile="$deploydir/temp/$version.html" | ||
|
||
node md2html.js --maintainers ../../versions/$version-editors.md ${filename} > $tempfile | ||
npx respec --use-local --src $tempfile --out ../../deploy/oas/v$version.html | ||
if [ "$1" = "src" ]; then | ||
destination="$deploydir/$version.html" | ||
maintainers="EDITORS.md" | ||
else | ||
destination="$deploydir/v$version.html" | ||
maintainers="$(dirname $specification)/$version-editors.md" | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this up and set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved this as far up the block as I could, but as these values depend on |
||
|
||
echo === Building $version to $destination | ||
|
||
node scripts/md2html/md2html.js --maintainers $maintainers $specification > $tempfile | ||
npx respec --use-local --src $tempfile --out $destination | ||
rm $tempfile | ||
|
||
echo === Built $destination | ||
|
||
if [ $version = $latest ]; then | ||
if [[ ${version} != *"rc"* ]];then | ||
if [[ ${version} != *"rc"* ]]; then | ||
# version is not a Release Candidate | ||
( cd ../../deploy/oas && ln -sf v$version.html latest.html ) | ||
latestCopied=v$version | ||
ln -sf $(basename $destination) $deploydir/latest.html | ||
latestCopied="v$version" | ||
fi | ||
fi | ||
|
||
if [ ${minorVersion} != ${lastMinor} ] && [ ${minorVersion} != 2.0 ]; then | ||
ralfhandl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
( cd ../../deploy/oas && ln -sf v$version.html v$minorVersion.html ) | ||
ln -sf $(basename $destination) $deploydir/v$minorVersion.html | ||
lastMinor=$minorVersion | ||
fi | ||
done | ||
echo Latest tag is $latest, copied $latestCopied to latest.html | ||
|
||
rm ../../deploy/js/respec-w3c.* | ||
if [ "$latestCopied" != "none" ]; then | ||
echo Latest tag is $latest, copied $latestCopied to latest.html | ||
fi | ||
|
||
rm $deploydir/js/respec-w3c.* | ||
rmdir $deploydir/js | ||
rmdir $deploydir/temp |
Uh oh!
There was an error while loading. Please reload this page.