all repos — emessage @ 005a22cc089316b1e386ca621bb8cb47cde04c58

The EMessage email client

go-selfupdate/example/run-example.sh (view raw)

 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
#!/bin/bash

echo "This example will compile the hello-updater application a few times with"
echo "different version strings and demonstrate go-selfupdate's functionality."
echo "If the version is 'dev', no update checking will be performed."
echo

# build latest/dev local version of go-selfupdate
SELFUPDATE_PATH=../cmd/go-selfupdate/main.go
if [ -f "$SELFUPDATE_PATH" ]; then
    go build -o go-selfupdate ../cmd/go-selfupdate
fi

rm -rf deployment/update deployment/hello* public/hello-updater

echo "Building example-server"
go build -o example-server src/example-server/main.go

echo "Running example server"
killall -q example-server
./example-server &

read -n 1 -p "Press any key to start." ignored; echo

echo "Building dev version of hello-updater"; echo
go build -ldflags="-X main.version=dev" -o hello-updater src/hello-updater/main.go

echo "Creating deployment folder and copying hello-updater to it"; echo
mkdir -p deployment/ && cp hello-updater deployment/


echo "Running deployment/hello-updater"
deployment/hello-updater
read -n 1 -p "Press any key to continue." ignored; echo
echo; echo "=========="; echo

for (( minor=0; minor<=2; minor++ )); do
    echo "Building hello-updater with version set to 1.$minor"
    go build -ldflags="-X main.version=1.$minor" -o hello-updater src/hello-updater/main.go

    echo "Running ./go-selfupdate to make update available via example-server"; echo
    ./go-selfupdate -o public/hello-updater/ hello-updater 1.$minor

    if (( $minor == 0 )); then
        echo "Copying version 1.0 to deployment so it can self-update"; echo
        cp hello-updater deployment/
        cp hello-updater deployment/hello-updater-1.0
    fi

    echo "Running deployment/hello-updater"
    deployment/hello-updater
    read -n 1 -p "Press any key to continue." ignored; echo
    echo; echo "=========="; echo
done

echo "Running deployment/hello-updater-1.0 backup copy"
deployment/hello-updater-1.0
read -n 1 -p "Press any key to continue." ignored; echo
echo; echo "=========="; echo

echo "Building unknown version of hello-updater"; echo
go build -ldflags="-X main.version=unknown" -o hello-updater src/hello-updater/main.go
echo "Copying unknown version to deployment so it can self-update"; echo
cp hello-updater deployment/

echo "Running deployment/hello-updater"
deployment/hello-updater
sleep 5
echo; echo "Re-running deployment/hello-updater"
deployment/hello-updater
sleep 5
echo; echo

echo "Shutting down example-server"
killall example-server