forked from openqasm/openqasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildPublishable.sh
executable file
·68 lines (52 loc) · 2.12 KB
/
buildPublishable.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/bash
## This script builds the publishable version of the specification including
## all stable branches. Each is built successively in the normal way after
## a `git checkout` of the found stable branches. Each built stable version is
## placed into the `versions` folder of the top-level final build
liveBranch=${1:-main}
destDir=${2:-"./publish_build"}
repoPath=${3-"heads"} # only remotes/origin will work in CI
echo "Live branch is ${liveBranch}"
echo "Destination dir is ${destDir}"
echo "Searching for stable branches with repo path refs/${repoPath}/stable/"
origBranch=$(git symbolic-ref --short HEAD)
echo "Checking if the current branch ${origBranch} is clean"
if [ ! -z "$(git status --untracked-files=no --porcelain)" ]; then
# Uncommitted changes in tracked files
echo " ERROR: Some files that have been changed are not committed!"
echo " This script will fail to generate a publishable build until everything has been committed"
git status
exit -1
fi
# initialize the destination folder
mkdir -p ${destDir}/versions
# Build the stable version list
unset versionList
for branch in `git for-each-ref --format='%(refname:short)' --sort=-refname refs/${repoPath}/stable/`; do
versionNum=${branch/*stable\//}
if [ -z "${versionList}" ]
then
versionList="${versionNum}"
else
versionList="${versionList},${versionNum}"
fi
done
# Now build each stable version and copy to destination folder
echo "VersionList is ${versionList}"
for branch in `git for-each-ref --format='%(refname:short)' --sort=-refname refs/${repoPath}/stable/`; do
versionNum=${branch/*stable\//}
echo "Checkout stable branch ${branch} with version number ${versionNum}"
git checkout ${branch}
# build
VERSION=${versionNum} VERSION_LIST=${versionList} make html
echo "Copy to publish dir ${destDir}/versions/${versionNum}"
cp -r build/html ${destDir}/versions/${versionNum}
done
echo "Getting live branch ${liveBranch}"
git checkout origin/${liveBranch}
# build
VERSION_LIST=${versionList} make html
echo "Copy to publish dir"
cp -r build/html/* ${destDir}
echo "Restoring to ${origBranch}"
git checkout ${origBranch}