1 | #!/bin/bash
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | set -o errexit
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | PROFILES="ol ol-debug"
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | BUILDS=dist
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | REMOTE=https://github.com/openlayers/openlayers.git
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | display_usage() {
|
30 | cat <<-EOF
|
31 |
|
32 | Usage: ${1} <version>
|
33 |
|
34 | To publish a new release, update the version number in package.json and
|
35 | create a tag for the release.
|
36 |
|
37 | The tag name must match the version number prefixed by a "v" (for example,
|
38 | version 3.2.1 would be tagged v3.2.1).
|
39 |
|
40 | The tag must be pushed to ${REMOTE} before the release can be published.
|
41 |
|
42 | EOF
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | assert_clean() {
|
49 | source `git --exec-path`/git-sh-setup && \
|
50 | require_clean_work_tree "publish" "Please commit or stash them."
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | assert_version_match() {
|
57 | v=`grep -o '"version":.*' package.json | sed 's/"version": *"\(.*\)",/\1/'`
|
58 | if test "${1}" != "${v}"; then
|
59 | echo "Version mismatch: requested '${1}', but package.json specifies '${v}'"
|
60 | exit 1
|
61 | fi
|
62 | }
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | build_js() {
|
68 | for p in ${@}; do
|
69 | echo building ${BUILDS}/${p}.js
|
70 | node ./tasks/build.js config/${p}.json ${BUILDS}/${p}.js
|
71 | done
|
72 | }
|
73 |
|
74 | build_css() {
|
75 | ./node_modules/.bin/cleancss css/ol.css -o ${BUILDS}/ol.css
|
76 | cp css/ol.css ${BUILDS}/ol-debug.css
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | checkout_tag() {
|
84 | git fetch ${REMOTE} refs/tags/v${1}:refs/tags/v${1}
|
85 | git checkout refs/tags/v${1}
|
86 | }
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | main() {
|
92 | root=$(cd -P -- "$(dirname -- "${0}")" && pwd -P)/..
|
93 | cd ${root}
|
94 | assert_clean
|
95 | checkout_tag ${1}
|
96 | assert_version_match ${1}
|
97 | rm -rf ${BUILDS}
|
98 | npm install
|
99 | build_js ${PROFILES}
|
100 | build_css
|
101 | npm publish
|
102 | }
|
103 |
|
104 | if test ${#} -ne 1; then
|
105 | display_usage ${0}
|
106 | exit 1
|
107 | else
|
108 | main ${1}
|
109 | fi
|