diff --git a/cmd/checkboundaryrelease/main.go b/cmd/checkboundaryrelease/main.go new file mode 100644 index 0000000..0b77f89 --- /dev/null +++ b/cmd/checkboundaryrelease/main.go @@ -0,0 +1,56 @@ +package main + +import ( + "context" + "flag" + "fmt" + "log" + "net/http" + "os" + + "github.com/ringsaturn/requests" + tzfrel "github.com/ringsaturn/tzf-rel" + "github.com/ringsaturn/tzf/pb" + "google.golang.org/protobuf/proto" +) + +const API = "https://api.github.com/repos/evansiroky/timezone-boundary-builder/tags" + +type TagsResponseItem struct { + Name string `json:"name"` + Commit Commit `json:"commit"` + // ZipballURL string `json:"zipball_url"` + // TarballURL string `json:"tarball_url"` + // NodeID string `json:"node_id"` +} + +type Commit struct { + Sha string `json:"sha"` + URL string `json:"url"` +} + +func main() { + verbose := flag.Bool("verbose", false, "show more logs") + flag.Parse() + ctx := context.Background() + resp := []*TagsResponseItem{} + err := requests.ReqWithExpectJSONResponse(ctx, http.DefaultClient, "GET", API, nil, &resp) + if err != nil { + panic(err) + } + latestTag := resp[0].Name + + input := &pb.PreindexTimezones{} + if err := proto.Unmarshal(tzfrel.PreindexData, input); err != nil { + panic(err) + } + if *verbose { + log.Printf("input.Version=%v, latestTag=%v\n", input.Version, latestTag) + } + if input.Version == latestTag { + log.Println("Same version, bye!") + os.Exit(1) + return + } + fmt.Printf("TIMEZONE_BOUNDARY_VERSION=%s\n", latestTag) +} diff --git a/go.mod b/go.mod index c7e57d8..7ae2643 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/paulmach/orb v0.9.0 github.com/ringsaturn/go-cities.json v0.3.5 github.com/ringsaturn/polyf v0.0.0-20221203140730-bfa046f8af27 + github.com/ringsaturn/requests v0.1.0 github.com/ringsaturn/tzf-rel v0.0.2023-b github.com/tidwall/geojson v1.4.3 github.com/tidwall/lotsa v1.0.3 diff --git a/go.sum b/go.sum index a3dec32..8db34a6 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,8 @@ github.com/ringsaturn/go-cities.json v0.3.5 h1:MCRHTdXyXwh6EVbHp17otHrktDulK0Vu/ github.com/ringsaturn/go-cities.json v0.3.5/go.mod h1:qpTYJsvNi40oTJs0WEdRdNAbWcLBWSL7oRHUxMrF4g8= github.com/ringsaturn/polyf v0.0.0-20221203140730-bfa046f8af27 h1:zKR4J+B+Aayd3ib6Y0BGuLqjJQCRlF2yVoA1RiDrUrU= github.com/ringsaturn/polyf v0.0.0-20221203140730-bfa046f8af27/go.mod h1:+oMllvWOIIjXhH69ceZhEAXfA7kmfo75wIJoC3MRsa4= -github.com/ringsaturn/tzf-rel v0.0.2022-g1.0.20230326130439-db41fe04bde9 h1:JtA4RtC2VSboRyO3w/aEwX1jU/T9Y/AB95t73GGXoK8= -github.com/ringsaturn/tzf-rel v0.0.2022-g1.0.20230326130439-db41fe04bde9/go.mod h1:TvyUIUpF3aCH98QYjTmMb1cqK7pFswdFLoIVZwGNV/M= +github.com/ringsaturn/requests v0.1.0 h1:3W152Lc80Man+V7AoeZamKhUiZEKuHZVfPWdzdVNJkM= +github.com/ringsaturn/requests v0.1.0/go.mod h1:dq7MKwNyXr9AKHdNvUlpguFE9TJSdjdsAqN3NTQfsuI= github.com/ringsaturn/tzf-rel v0.0.2023-b h1:27Kt3ewlXJ/nkYFedYWmKbj7CUWzG0UxFYXQAjzPgBE= github.com/ringsaturn/tzf-rel v0.0.2023-b/go.mod h1:TvyUIUpF3aCH98QYjTmMb1cqK7pFswdFLoIVZwGNV/M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=