forked from WICG/virtual-scroller
-
Notifications
You must be signed in to change notification settings - Fork 2
/
publish.sh
executable file
·63 lines (54 loc) · 1.21 KB
/
publish.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
#! /bin/bash -ex
# Publish a sha and/or branch to gh-pages.
#
# publish.sh <sha>
#
# Will cause the repo to be published under
# https://fergald.github.io/virtual-scroller/versions/<sha>
# and
#
# publish.sh <branch>
#
# will figure out the sha for that branch, publish that and
# link versions/<branch> to that sha.
if [ ! -e .git ]; then
echo >2 No .git
exit 1
fi
if [ $# -eq 0 ]; then
echo >2 No revision
exit 1
fi
revision=$1
shift
git checkout gh-pages
sha=$(git rev-parse "$revision")
dest=versions/"$sha"
git clone -s -n . "$dest"
(
cd "$dest"
git checkout "$sha"
echo Deleting `pwd`/.git
read f
rm -rf .git
git add .
git commit -a -m"Add gh-pages revision $sha"
if [ "$sha" = "$revision" ]; then
exit
fi
cd ..
ln -sfT "$sha" "$revision"
git add "$revision"
git commit -a -m"Update $revision->$sha"
)
git push
git checkout -
base=$(git remote show -n origin|grep "Fetch URL" | perl -lne 'print "https://$1.github.io/$2" if m#github.com:(.*?)/(.*)#')
if [ -z "$base" ]; then
echo >2 "Couldn't get base"
exit 1
fi
echo Published to "$base/versions/$revision"
if [ "$sha" != "$revision" ]; then
echo Published to "$base/versions/$sha"
fi