summarylogtreecommitdiffstats
path: root/update_package
blob: 99b6db954510bb4135e480e8f7eefa6eae16e81c (plain)
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
#!/bin/bash

C="\x1b[0m"
GRN="\x1b[32m"
YEL="\x1b[33m"
BLU="\x1b[34m"
col2="$BLU::$C"

touch current_version

if [ "$1" != "--skip-dl" ]; then
    url=https://github.com/Yasu3D/MercuryMapper
    current=$(cat current_version)
    echo -e "$col2 Getting latest version..." >/dev/stderr
    latest=$(basename "$(curl -Ls -o /dev/null -w "%{url_effective}" "$url/releases/latest")")

    if [ "$current" = "" ]; then
        current="(nothing)"
    fi

    if [ "$current" = "$latest" ] && [ "$1" != "-f" ]; then
        echo -e "$col2 Current $GRN$current$C is latest, no update required" >/dev/stderr
        exit
    else
        echo -e "$col2 Changing current version from $YEL$current$C to $GRN$latest$C"
        echo "$latest" > current_version
    fi
fi

echo -e "$col2 Updating checksums..."
updpkgsums

echo -e "$col2 Writing .SRCINFO file..."
makepkg --printsrcinfo > .SRCINFO

echo -e "$col2 Making and installing new package..."
makepkg -si

if [ "$(git config --global user.email)" == "speykious@gmail.com" ]; then
    echo -e "$col2 Bump version in git history..."

    if [ "$1" != "--skip-dl" ]; then
        git commit -am "Bump to version $latest"
    else
        # we write the commit message ourselves
        git commit -a
    fi

    echo -e "$col2 Pushing new commit..."
    git push
fi

echo -e "$col2 Done"