-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathProjectfile
executable file
·137 lines (111 loc) · 2.63 KB
/
Projectfile
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# usage: ./Projectfile [command]
#############################################################################
images () {
for os in $(ls dockerfiles/)
do image "$os"
done
}
image () {
os="${1:-shell}"
docker build -f dockerfiles/"$os"/Dockerfile -t "ts:$os" . >&2
printf "%s\n" "ts:$os"
}
shell () {
os="${1:-shell}"
docker run -it --rm -v "$PWD:/app" "ts:$os" /bin/bash
}
test () {
image="${1:-ts:shell}"
shell="${2:-/bin/sh}"
# Switch /bin/sh so that all scripts will pick up the target shell as a part
# of shebang usage. Assumes image runs as root user.
docker run --rm -i "$image" /bin/sh <<DOC
if [ "$shell" != /bin/sh ]
then ln -sf "$shell" /bin/sh
fi
./test/suite
DOC
}
test-os () {
os="$1"
shift 1
if [ "$#" -eq 0 ]
then set /bin/sh
fi
os_dir="tmp/artifacts/$os"
mkdir -p "$os_dir"
buildlog="$os_dir/buildlog"
image="$(image "$os" 2>"$buildlog")"
for shell in "$@"
do
printf "# %s %s\t" "$os" "$shell"
outfile="$os_dir/$(basename "$shell")"
test "$image" "$shell" >"$outfile" 2>&1
tail -n 1 "$outfile"
awk -v os="$os" -v shell="$shell" '
/^\[/ { summary=$0 };
/^F/ { print $1 " " os " " shell "\t" summary }
' "$outfile"
done
}
test-all () {
test-os alpine /bin/bash /bin/zsh
test-os centos /bin/bash /bin/zsh /bin/ksh
test-os debian /bin/bash /bin/zsh /bin/ksh
test-os fedora /bin/bash /bin/zsh /bin/ksh
test-os opensuse /bin/bash /bin/zsh /bin/ksh
test-os ubuntu /bin/dash /bin/bash /bin/zsh /bin/ksh
}
#
# Release
#
prepare-release () {
ts_version="$1"
ts_release_date="$(date +"%Y-%m-%d")"
if [ -z "$ts_version" ]
then
printf "no version specified\nusage: ./Bakefile prepare-release <version>\n" >&2
exit 1
fi
if ! ./test/suite
then
printf "cannot release (failing tests)\n" >&2
exit 1
fi
# set new version
sed -i "" \
-e "s/ts_version=.*/ts_version=\"$ts_version\"/" \
-e "s/ts_release_date=.*/ts_release_date=\"$ts_release_date\"/" \
./bin/ts
# update the manpages
docker run --rm -i -v "$PWD:/app" "$(image shell)" /bin/bash <<DOC
mkdir -p man/man1
ronn -r --pipe --organization="$ts_version" --date="$ts_release_date" README.md > man/man1/ts.1
DOC
cat >&2 <<DOC
Next steps:
git status # double check your changes
git commit -a -m "Release $ts_version"
git push origin master
git tag "v$ts_version"
git push origin --tags
A draft release will be created by GitHub Actions. Take a look, write release
notes, and publish if desired.
DOC
}
#
# Utility
#
list () {
compgen -A function 2>/dev/null
}
if list | grep -qFx -- "${1:-}"
then "$@"
else
if [ -z "$1" ]
then printf "no command specified (try 'list')\n" >&2
else printf "unknown command: %s\n" "$1" >&2
fi
exit 1
fi