-
Notifications
You must be signed in to change notification settings - Fork 79
/
archive.sh
executable file
·73 lines (61 loc) · 1.62 KB
/
archive.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
69
70
71
72
73
#!/bin/bash
#
# Run this script to generate a zip archive for the workshop in a single
# language.
#
set -o errexit
#
# Destination directory for build.
#
BUILD=build
#
# Display usage and exit.
#
display_usage() {
cat <<-EOF
Usage: ${1} <lang>
Example:
${1} en
This will generate a zip archive for the English version of the workshop.
The openlayers-workshop-en.zip should be posted to the release page.
EOF
}
#
# Exit if the current working tree is not clean.
#
assert_clean() {
git checkout -- package-lock.json
source `git --exec-path`/git-sh-setup && \
require_clean_work_tree "publish" "Please commit or stash them."
}
#
# Build the workshop and create an archive for a single language.
#
build_archive() {
npm run build
mkdir -p ${BUILD}/openlayers-workshop-${1}
url=$(node --eval 'process.stdout.write(require("./doc/book.json").variables.workshopUrl)')
sed "s|{{book.workshopUrl}}|${url}|g" doc/${1}/README.md > ${BUILD}/openlayers-workshop-${1}/README.md
cp -r src/${1}/*.* ${BUILD}/openlayers-workshop-${1}
cp -r src/${1}/data ${BUILD}/openlayers-workshop-${1}/data
cp -r src/${1}/examples ${BUILD}/openlayers-workshop-${1}/examples
cp -r ${BUILD}/openlayers-workshop/${1} ${BUILD}/openlayers-workshop-${1}/doc
cp -r ${BUILD}/openlayers-workshop/gitbook ${BUILD}/openlayers-workshop-${1}/gitbook
cd ${BUILD}
zip -FSr ../openlayers-workshop-${1}.zip openlayers-workshop-${1}
}
#
# Build the archive.
#
main() {
root=$(cd -P -- "$(dirname -- "${0}")" && pwd -P)
cd ${root}
assert_clean
build_archive ${1}
}
if test ${#} -ne 1; then
display_usage ${0}
exit 1
else
main ${1}
fi