-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
57 lines (47 loc) · 1.22 KB
/
main.go
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
package main
import (
"fmt"
"os"
"github.com/equinox-io/equinox"
)
// assigned when creating a new application in the dashboard
const appID = "app_4xCaMumNoeF"
// application version
var version string
// public portion of signing key generated by `equinox genkey`
var publicKey = []byte(`
-----BEGIN ECDSA PUBLIC KEY-----
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAESYHcYsiu18n8vFslTBeM0PAfzq2gifV7
OTwj/8Jda4omURmtygToJkHyZivkuLP48S1cFnTBlk8NHRlfD+rDdj5g+ZTgA4dT
5mM1cYPmRGK2lCxazL9JL4QBQQ+jQsqr
-----END ECDSA PUBLIC KEY-----
`)
func equinoxUpdate() error {
var opts equinox.Options
if err := opts.SetPublicKeyPEM(publicKey); err != nil {
return err
}
// check for the update
resp, err := equinox.Check(appID, opts)
switch {
case err == equinox.NotAvailableErr:
fmt.Println("No update available, already at the latest version!")
return nil
case err != nil:
fmt.Println("Update failed:", err)
return err
}
// fetch the update and apply it
err = resp.Apply()
if err != nil {
return err
}
fmt.Printf("Updated to new version: %s!\n", resp.ReleaseVersion)
return nil
}
func main() {
if len(os.Args) == 2 && os.Args[1] == "update" {
equinoxUpdate()
}
fmt.Printf("Travis CI example current version: %s\n", version)
}