-
Notifications
You must be signed in to change notification settings - Fork 7
/
publish-timedesc.sh
executable file
·104 lines (74 loc) · 1.98 KB
/
publish-timedesc.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
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
#!/usr/bin/env bash
RETAG_CONFIRM_TEXT="retag-timedesc"
opam_repo="$HOME/opam-repository"
echo "Checking if $opam_repo exists"
if [ ! -d "$opam_repo" ]; then
echo "$opam_repo does not exist"
exit 1
fi
ver=$(cat CHANGELOG.md \
| grep '## Timedesc' \
| head -n 1 \
| sed -n 's/^## Timedesc\s*\(\S*\)$/\1/p')
echo "Detected version for Timedesc:" $ver
git_tag="timedesc-$ver"
echo "Computed git tag for Timedesc:" $git_tag
read -p "Are the version and git tag correct [y/n]? " ans
if [[ $ans != "y" ]]; then
echo "Publishing cancelled"
exit 0
fi
echo "Checking if $git_tag exists in repo already"
if [[ $(git tag -l "$git_tag") == "" ]]; then
echo "Tagging commit"
git tag "$git_tag"
else
read -p "Tag already exists, retag [y/n]? " ans
if [[ $ans == "y" ]]; then
read -p "Type \"$RETAG_CONFIRM_TEXT\" to confirm: " ans
if [[ $ans != "$RETAG_CONFIRM_TEXT" ]]; then
echo "Publishing cancelled"
exit 0
fi
echo "Removing tag"
git tag -d "$git_tag"
git push --delete origin "$git_tag"
echo "Tagging commit"
git tag "$git_tag"
fi
fi
echo "Pushing all tags"
git push --tags
archive="$git_tag".tar.gz
echo "Archiving as $archive"
rm -f "$archive"
git archive --output=./"$archive" "$git_tag"
echo "Hashing $archive"
hash_cmd=sha256sum
archive_hash=$("$hash_cmd" "$archive" | awk '{ print $1 }')
echo "Hash from $hash_cmd:" $archive_hash
packages=(
"timedesc"
"timedesc-tzdb"
"timedesc-tzlocal"
"timedesc-tzlocal-js"
"timedesc-json"
"timedesc-sexp"
)
for package in ${packages[@]}; do
package_dir="$opam_repo"/packages/"$package"/"$package"."$ver"
dest_opam="$package_dir"/opam
echo "Making directory $package_dir"
mkdir -p "$package_dir"
echo "Copying $package.opam over"
cp "$package.opam" "$dest_opam"
echo "Adding url section to $dest_opam"
echo "
url {
src:
\"https://github.com/daypack-dev/timere/releases/download/$git_tag/$archive\"
checksum:
\"sha256=$archive_hash\"
}
" >> "$dest_opam"
done