-
Notifications
You must be signed in to change notification settings - Fork 326
/
Copy pathrelease-update-tilt-docs-repo.sh
executable file
·52 lines (41 loc) · 1.64 KB
/
release-update-tilt-docs-repo.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
#!/bin/bash
#
# Updates the Tilt docs repo with the latest version info.
#
# Usage:
# scripts/update-docs-tilt-repo.sh $VERSION
# where VERSION is of the form 0.1.0
set -euo pipefail
if [[ "${GITHUB_TOKEN-}" == "" ]]; then
echo "Missing GITHUB_TOKEN"
exit 1
fi
VERSION=${1//v/}
VERSION_PATTERN="^[0-9]+\\.[0-9]+\\.[0-9]+$"
if ! [[ $VERSION =~ $VERSION_PATTERN ]]; then
echo "Version did not match expected pattern. Actual: $VERSION"
exit 1
fi
DIR=$(dirname "$0")
cd "$DIR/.."
ROOT=$(mktemp -d)
git clone https://tilt-releaser:"$GITHUB_TOKEN"@github.com/tilt-dev/tilt.build "$ROOT"
set -x
VERSION_ARGS="-X main.version=$VERSION -X main.date=$(date +%Y-%m-%d)"
go run -mod=vendor -ldflags "$VERSION_ARGS" ./cmd/tilt/main.go dump cli-docs --dir="$ROOT/docs/cli"
go run -mod=vendor -ldflags "$VERSION_ARGS" ./cmd/tilt/main.go dump api-docs --dir="$ROOT/api"
cd "$ROOT"
make cli-toc
make api
sed -i -E "s/asdf install tilt .*/asdf install tilt $VERSION/" docs/install.md
sed -i -E "s/asdf global tilt .*/asdf global tilt $VERSION/" docs/install.md
sed -i -E "s/asdf install tilt .*/asdf install tilt $VERSION/" docs/upgrade.md
sed -i -E "s/asdf global tilt .*/asdf global tilt $VERSION/" docs/upgrade.md
# the sed pattern doesn't need to match the whole string.
SED_VERSION_PATTERN="[0-9]+\\.[0-9]+\\.[0-9]+"
sed -i -E "s|/download/v$SED_VERSION_PATTERN/tilt.$SED_VERSION_PATTERN|/download/v$VERSION/tilt.$VERSION|" docs/install.md
sed -i -E "s|/download/v$SED_VERSION_PATTERN/tilt.$SED_VERSION_PATTERN|/download/v$VERSION/tilt.$VERSION|" docs/upgrade.md
git add .
git commit -a -m "Update docs to Tilt version: $VERSION"
git push origin master
rm -fR "$ROOT"