-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
update_auto_update_ver.go
78 lines (66 loc) · 1.66 KB
/
update_auto_update_ver.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"fmt"
"path/filepath"
"strconv"
"strings"
"github.com/kjk/minioutil"
)
// Format of auto-update file:
/*
[SumatraPDF]
Latest 3.1.2
*/
/*
for 3.1.2 and earlier, we upload:
https://kjkpub.s3.amazonaws.com/sumatrapdf/sumpdf-update.txt
https://kjkpub.s3.amazonaws.com/sumatrapdf/sumpdf-latest.txt
for 3.2 and later, we use
https://www.sumatrapdfreader.org/update-check-rel.txt
This script uploads to s3 and updates website/update-check-rel.txt,
which must be then deployed.
*/
// ver should be in format:
// 3
// 3.1
// 3.1.2
func validateVer(ver string) {
parts := strings.Split(ver, ".")
panicIf(len(parts) > 3)
for i, p := range parts {
n, err := strconv.Atoi(p)
must(err)
panicIf(n < 0 || n > 19)
panicIf(i == 0 && n != 3, "major version must be 3")
}
}
func updateAutoUpdateVer(ver string) {
validateVer(ver)
// TODO: verify it's bigger than the current version
// TODO: add download links
s := fmt.Sprintf(`[SumatraPDF]
Latest %s
`, ver)
fmt.Printf("Content of update file:\n%s\n\n", s)
d := []byte(s)
uploadInfo := func(mc *minioutil.Client) {
{
remotePath := "sumatrapdf/sumpdf-update.txt"
_, err := mc.UploadData(remotePath, d, true)
must(err)
}
{
remotePath := "sumatrapdf/sumpdf-latest.txt"
_, err := mc.UploadData(remotePath, d, true)
must(err)
}
}
// TODO: anyone using those for update info?
//uploadInfo(newMinioSpacesClient())
//uploadInfo(newMinioS3Client())
uploadInfo(newMinioBackblazeClient())
uploadInfo(newMinioR2Client())
path := filepath.Join("website", "update-check-rel.txt")
writeFileMust(path, []byte(s))
fmt.Printf("Don't forget to checkin file '%s' and deploy website\n", path)
}