|
2 | 2 |
|
3 | 3 | # Author: @MikeRalphson
|
4 | 4 |
|
5 |
| -# run this script from the root of the repo. It is designed to be run by a GitHub workflow. |
6 |
| -# It contains bashisms |
| 5 | +# run this script from the root of the repo |
| 6 | +# It is designed to be run by a GitHub workflow |
7 | 7 |
|
8 |
| -mkdir -p deploy/oas |
9 |
| -mkdir -p deploy/js |
| 8 | +# Usage: build.sh [version | "latest" | "src"] |
| 9 | +# When run with no arguments, it builds artifacts for all published specification versions. |
| 10 | +# It may also be run with a specific version argument, such as "3.1.1" or "latest" |
| 11 | +# Finally, it may be run with "src" to build "src/oas.md" |
| 12 | +# |
| 13 | +# It contains bashisms |
10 | 14 |
|
11 |
| -cd scripts/md2html |
| 15 | +if [ -z "$1" ]; then |
| 16 | + deploydir="deploy/oas" |
| 17 | +else |
| 18 | + deploydir="deploy-preview" |
| 19 | +fi |
12 | 20 |
|
13 |
| -cp -p ../../node_modules/respec/builds/respec-w3c.* ../../deploy/js/ |
| 21 | +mkdir -p $deploydir/js |
| 22 | +mkdir -p $deploydir/temp |
14 | 23 |
|
15 |
| -latest=`git describe --abbrev=0 --tags` |
16 |
| -latestCopied=none |
| 24 | +latest=$(git describe --abbrev=0 --tags) |
| 25 | +latestCopied="none" |
17 | 26 | lastMinor="-"
|
18 |
| -for filename in $(ls -1 ../../versions/[23456789].*.md | sort -r) ; do |
19 |
| - if [[ ${filename} == *-editors.md ]];then |
20 |
| - continue |
21 |
| - fi |
22 | 27 |
|
23 |
| - version=$(basename "$filename" .md) |
| 28 | +if [ -z "$1" ]; then |
| 29 | + specifications=$(ls -1 versions/[23456789].*.md | grep -v -e "\-editors" | sort -r) |
| 30 | +elif [ "$1" = "latest" ]; then |
| 31 | + specifications=$(ls -1 versions/$latest.md) |
| 32 | +elif [ "$1" = "src" ]; then |
| 33 | + specifications="src/oas.md" |
| 34 | +else |
| 35 | + specifications=$(ls -1 versions/$1.md) |
| 36 | +fi |
| 37 | + |
| 38 | +cp -p node_modules/respec/builds/respec-w3c.* $deploydir/js/ |
| 39 | + |
| 40 | +for specification in $specifications; do |
| 41 | + version=$(basename $specification .md) |
24 | 42 | minorVersion=${version:0:3}
|
25 |
| - tempfile=../../deploy/oas/v$version-tmp.html |
26 |
| - echo -e "\n=== v$version ===" |
| 43 | + tempfile="$deploydir/temp/$version.html" |
27 | 44 |
|
28 |
| - node md2html.js --maintainers ../../versions/$version-editors.md ${filename} > $tempfile |
29 |
| - npx respec --use-local --src $tempfile --out ../../deploy/oas/v$version.html |
| 45 | + if [ "$1" = "src" ]; then |
| 46 | + destination="$deploydir/$version.html" |
| 47 | + maintainers="EDITORS.md" |
| 48 | + else |
| 49 | + destination="$deploydir/v$version.html" |
| 50 | + maintainers="$(dirname $specification)/$version-editors.md" |
| 51 | + fi |
| 52 | + |
| 53 | + echo === Building $version to $destination |
| 54 | + |
| 55 | + node scripts/md2html/md2html.js --maintainers $maintainers $specification > $tempfile |
| 56 | + npx respec --use-local --src $tempfile --out $destination |
30 | 57 | rm $tempfile
|
31 | 58 |
|
| 59 | + echo === Built $destination |
| 60 | + |
32 | 61 | if [ $version = $latest ]; then
|
33 |
| - if [[ ${version} != *"rc"* ]];then |
| 62 | + if [[ ${version} != *"rc"* ]]; then |
34 | 63 | # version is not a Release Candidate
|
35 |
| - ( cd ../../deploy/oas && ln -sf v$version.html latest.html ) |
36 |
| - latestCopied=v$version |
| 64 | + ln -sf $(basename $destination) $deploydir/latest.html |
| 65 | + latestCopied="v$version" |
37 | 66 | fi
|
38 | 67 | fi
|
39 | 68 |
|
40 | 69 | if [ ${minorVersion} != ${lastMinor} ] && [ ${minorVersion} != 2.0 ]; then
|
41 |
| - ( cd ../../deploy/oas && ln -sf v$version.html v$minorVersion.html ) |
| 70 | + ln -sf $(basename $destination) $deploydir/v$minorVersion.html |
42 | 71 | lastMinor=$minorVersion
|
43 | 72 | fi
|
44 | 73 | done
|
45 |
| -echo Latest tag is $latest, copied $latestCopied to latest.html |
46 | 74 |
|
47 |
| -rm ../../deploy/js/respec-w3c.* |
| 75 | +if [ "$latestCopied" != "none" ]; then |
| 76 | + echo Latest tag is $latest, copied $latestCopied to latest.html |
| 77 | +fi |
| 78 | + |
| 79 | +rm $deploydir/js/respec-w3c.* |
| 80 | +rmdir $deploydir/js |
| 81 | +rmdir $deploydir/temp |
0 commit comments