forked from polydawn/repeatr
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrepeat-thyself.sh
More file actions
executable file
·75 lines (63 loc) · 1.97 KB
/
repeat-thyself.sh
File metadata and controls
executable file
·75 lines (63 loc) · 1.97 KB
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
74
75
#!/bin/bash
#
# Build repeatr repeatedly with repeatr.
#
# If you don't have repeatr on your path yet, you can
# use `./goad sys` to install it to your local `/usr/bin/`,
# or `./goad install` to update a copy in `./.gopath/bin/`.
#
set -euo pipefail
if [ -x .gopath/bin/repeatr ]; then PATH=$PWD/.gopath/bin/:$PATH; fi
if [ ! -d .git ]; then echo "this script assumes it is run from a local git repo containing repeatr." 1>&2 ; exit 1 ; fi
### Set values for metadata our build injects for debugging purposes.
# These are used by go-generate (see `cli/go.version.tmpl`);
# In order to produce consistent outputs, we have to affix them.
# Pick out the current head hash.
# Of course you could use any commit hash you want.
GITCOMMIT=${GITCOMMIT:-$(git rev-parse HEAD)}
# Nil builddate by default. But if you want to set one, go ahead.
BUILDDATE=${BUILDDATE:-"xxx"}
# CI requires some special modes, but you probably don't on localhost.
CI_FLAGS=${CI_FLAGS:-}
### Assemble the full formula
# This is mostly just taking our metadata variables above, and injecting them.
Formula="$(cat <<EOF
inputs:
"/":
type: "tar"
hash: "uJRF46th6rYHt0zt_n3fcDuBfGFVPS6lzRZla5hv6iDoh5DVVzxUTMMzENfPoboL"
silo: "http+ca://repeatr.s3.amazonaws.com/assets/"
"/app/go/":
type: "tar"
hash: "vbl0TwPjBrjoph65IaWxOy-Yl0MZXtXEDKcxodzY0_-inUDq7rPVTEDvqugYpJAH"
silo: "https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz"
"/task/repeatr/":
type: "git"
hash: "${GITCOMMIT}"
silo:
- "."
- "https://github.com/polydawn/repeatr.git"
action:
command:
- "/bin/bash"
- "-c"
- |
#!/bin/bash
export GOROOT=/app/go/go
export PATH=\$PATH:/app/go/go/bin
>&2 echo building...
./goad install
>&2 echo build complete!
cwd: "/task/repeatr/"
env:
"GITCOMMIT": "${GITCOMMIT}"
"BUILDDATE": "${BUILDDATE}"
outputs:
"executable":
type: "tar"
mount: "/task/repeatr/.gopath/bin/"
silo: "file://repeatr.tar"
EOF
)"
### run it!
time repeatr run $CI_FLAGS <(echo "${Formula}")