-
Notifications
You must be signed in to change notification settings - Fork 20
/
atlas.elv
45 lines (41 loc) · 1.32 KB
/
atlas.elv
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
use re
use str
fn push {|@arg|
var msg = "Markup fixes"
if (< 0 (count $arg)) {
set msg = (str:join " " $arg)
}
var BRANCH = (git symbolic-ref HEAD | sed -e 's|^refs/heads/||')
var REPO = (git remote -v | head -1 | sed 's/^.*oreilly\.com\///; s/\.git.*$//')
echo (styled "Committing and pushing changes to "$REPO", branch "$BRANCH"..." yellow) > /dev/tty
var st = ?(git ci -a -m $msg > /dev/tty)
git push atlas $BRANCH > /dev/tty
put $BRANCH $REPO
}
fn buildonly {|type branch repo|
echo (styled "Building "$type" on "$repo", branch "$branch"..." yellow) > /dev/tty
atlas build $E:ATLAS_TOKEN $repo $type $branch | tee build/build.out > /dev/tty
var URL EXT = (cat build/build.out | eawk {|line @f|
var m = (or (re:find '(?i)'$type':\s+(.*\.([a-z]+))$' $line) $false)
if $m {
put $m[groups][1 2][text]
}
})
echo (styled "Fetching and opening build "$URL green) > /dev/tty
var OUTFILE = "../atlas-builds/plain-format/atlas-plain."$EXT
curl -o $OUTFILE $URL > /dev/tty 2>&1
put $OUTFILE
}
fn build {|type @arg|
var BRANCH REPO = (push $@arg)
var OUTFILE = (buildonly $type $BRANCH $REPO)
open $OUTFILE
}
fn all {|@arg|
var BRANCH REPO = (push $@arg)
var FILES = []
for ext [pdf epub mobi html] {
set FILES = [ $@FILES (buildonly $ext $BRANCH $REPO) ]
}
pprint $FILES
}