-
Notifications
You must be signed in to change notification settings - Fork 2
/
autoupdate
executable file
·67 lines (54 loc) · 1.94 KB
/
autoupdate
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
#!/bin/bash
set -e
# Originally writtten by Stefans Mezulis <[email protected]> for
# https://github.com/pipeseroni/packaging-aur
# Released into the public domain via the CC0 waiver.
release_url="https://api.github.com/repos/pipeseroni/%s/releases"
aur_url="ssh://[email protected]/%s.git"
# Get the current tag from github, update PKGBUILD and checksums.
for branch in $(git for-each-ref refs/heads --format='%(refname:short)'); do
# Check for a valid branch
case "$branch" in
pipes.*)
repo="$branch"
;;
*) continue;;
esac
# Switch to the branch
git checkout "$branch"
# Retrieve version information from GitHub
new_version=$(\
wget -q $(printf "$release_url" "$repo") -O - \
| jq -r '.[0].tag_name' \
| sed 's/^v//')
# Retrieve current version from the PKGBUILD
current_version=$(sed -n 's/^pkgver=\(.*\)$/\1/p' PKGBUILD)
if [[ "$new_version" != "$current_version" ]]; then
# Bump verison number
sed -i "s/^pkgver=.*$/pkgver=$new_version/" PKGBUILD
# Bump checksums
updpkgsums
makepkg --printsrcinfo > .SRCINFO
# Add files to index
git add PKGBUILD .SRCINFO
# Generate informative comment for the commit message.
commit_comments=$(git diff --staged | sed 's/^/# /')
git commit -t <(\
printf "Bump version from %s → %s\n\n%s\n" \
"$current_version" \
"$new_version" \
"$commit_comments")
# Should this be pushed to the AUR?
read -n1 -p "Push to AUR? [y/N] " push
if [[ "$push" == "y" || "$push" == "Y" ]]; then
# Add remote to git
git remote add \
"$branch" \
"$(printf "$aur_url" "$branch")" \
2>/dev/null || true
git push "$branch" "$branch:master"
fi
fi
done
# Return to master
git checkout master