Skip to content

Commit

Permalink
Merge pull request #4342 from duncanbeevers/build-src-changes
Browse files Browse the repository at this point in the history
build.sh accepts version argument
  • Loading branch information
ralfhandl authored Feb 10, 2025
2 parents 031d633 + 06a89cd commit 8e3015a
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ target
atlassian-ide-plugin.xml
node_modules/
deploy/
deploy-preview/
coverage/
history
Gemfile.lock
79 changes: 57 additions & 22 deletions scripts/md2html/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,81 @@

# Author: @MikeRalphson

# run this script from the root of the repo. It is designed to be run by a GitHub workflow.
# run this script from the root of the repo
# It is designed to be run by a GitHub workflow

# 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

mkdir -p deploy/oas
mkdir -p deploy/js
if [ "$1" = "src" ]; then
deploydir="deploy-preview"
else
deploydir="deploy/oas"
fi

mkdir -p $deploydir/js
mkdir -p $deploydir/temp
cp -p node_modules/respec/builds/respec-w3c.* $deploydir/js/

cd scripts/md2html
latest=$(git describe --abbrev=0 --tags)

cp -p ../../node_modules/respec/builds/respec-w3c.* ../../deploy/js/
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

latest=`git describe --abbrev=0 --tags`
latestCopied=none
latestCopied="none"
lastMinor="-"
for filename in $(ls -1 ../../versions/[23456789].*.md | sort -r) ; do
if [[ ${filename} == *-editors.md ]];then
continue

for specification in $specifications; do
version=$(basename $specification .md)

if [ "$1" = "src" ]; then
destination="$deploydir/$version.html"
maintainers="EDITORS.md"
else
destination="$deploydir/v$version.html"
maintainers="$(dirname $specification)/$version-editors.md"
fi

version=$(basename "$filename" .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
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
( cd ../../deploy/oas && ln -sf v$version.html v$minorVersion.html )
if [ ${minorVersion} != ${lastMinor} ] && [[ ${minorVersion} =~ ^[3-9] ]]; then
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
5 changes: 1 addition & 4 deletions scripts/md2html/md2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ function preface(title,options) {
preface += '<meta name="color-scheme" content="light dark">';
preface += '<script src="../js/respec-w3c.js" class="remove"></script>';
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>`;
try {
preface += fs.readFileSync('./analytics/google.html','utf8');
}
catch (ex) {}
preface += fs.readFileSync(path.resolve(__dirname,'./analytics/google.html'),'utf8');
preface += '</head><body>';
preface += '<style>';
preface += fs.readFileSync(path.resolve(__dirname,'main.css'),'utf8').split(/\r?\n/).join(' ');
Expand Down
Loading

0 comments on commit 8e3015a

Please sign in to comment.