-
Notifications
You must be signed in to change notification settings - Fork 7
/
publish-timere.sh
executable file
·99 lines (69 loc) · 1.86 KB
/
publish-timere.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
#!/bin/bash
RETAG_CONFIRM_TEXT="retag-timere"
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 '## Timere ' \
| head -n 1 \
| sed -n 's/^## Timere\s*\(\S*\)$/\1/p')
echo "Detected version for Timere:" $ver
git_tag="timere-$ver"
echo "Computed git tag for Timere:" $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=(
"timere"
)
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