Skip to content

Commit 46f6bfb

Browse files
committed
internal/task: add task to tweet about Go releases
This CL adds an internal API for making release tweets of various kinds, including the templates used to generate the tweet text and tweet image. It does not have code for using the Twitter API. CL 358898 will do that. For golang/go#40279. For golang/go#47403. Change-Id: Ic0cb2f5f1e59c0fd932aed7c5c4a88decc5a3d8d Reviewed-on: https://go-review.googlesource.com/c/build/+/358897 Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Dmitri Shuralyov <[email protected]> Trust: Alexander Rakoczy <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 5891341 commit 46f6bfb

File tree

7 files changed

+776
-10
lines changed

7 files changed

+776
-10
lines changed

cmd/release/upload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const (
3434
)
3535

3636
// File represents a file on the golang.org downloads page.
37-
// It should be kept in sync with the download code in x/tools/godoc/dl.
37+
// It should be kept in sync with the download code in x/website/internal/dl.
3838
type File struct {
3939
Filename string `json:"filename"`
4040
OS string `json:"os"`

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ require (
1515
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f
1616
github.com/creack/pty v1.1.15
1717
github.com/davecgh/go-spew v1.1.1
18+
github.com/esimov/stackblur-go v1.0.1
1819
github.com/gliderlabs/ssh v0.3.3
1920
github.com/golang-migrate/migrate/v4 v4.15.0-beta.3
21+
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
2022
github.com/golang/protobuf v1.5.2
2123
github.com/google/go-cmp v0.5.6
2224
github.com/google/go-github v17.0.0+incompatible
@@ -31,6 +33,7 @@ require (
3133
go.opencensus.io v0.23.0
3234
go4.org v0.0.0-20180809161055-417644f6feb5
3335
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
36+
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
3437
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985
3538
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
3639
golang.org/x/perf v0.0.0-20210220033136-40a54f11e909

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m
206206
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
207207
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
208208
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
209+
github.com/esimov/stackblur-go v1.0.1 h1:FI7PA9/lJKomN0Cwzzc0mnezRIzUqe31wPC16CC5m1Y=
210+
github.com/esimov/stackblur-go v1.0.1/go.mod h1:a3zzeKuJKUpCcReHmEsuPaEnq42D2b/bHoCI8UjIuMY=
209211
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
210212
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
211213
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
@@ -268,6 +270,8 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
268270
github.com/golang-migrate/migrate/v4 v4.15.0-beta.3 h1:tqLMcxs6gB6+b2Jhwao4s2sNMSKku+0rjtBtKucKWkg=
269271
github.com/golang-migrate/migrate/v4 v4.15.0-beta.3/go.mod h1:g9qbiDvB47WyrRnNu2t2gMZFNHKnatsYRxsGZbCi4EM=
270272
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
273+
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
274+
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
271275
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
272276
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
273277
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -793,6 +797,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
793797
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
794798
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
795799
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
800+
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
801+
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
796802
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
797803
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
798804
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

internal/task/dlcl.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// Package task implements tasks involved in making a Go release.
65
package task
76

87
import (
@@ -35,14 +34,8 @@ func MailDLCL(ctx context.Context, versions []string) (changeURL string, _ error
3534
if len(versions) < 1 || len(versions) > 2 {
3635
return "", fmt.Errorf("got %d Go versions, want 1 or 2", len(versions))
3736
}
38-
for _, ver := range versions {
39-
if ver != strings.ToLower(ver) {
40-
return "", fmt.Errorf("version %q is not lowercase", ver)
41-
} else if strings.Contains(ver, " ") {
42-
return "", fmt.Errorf("version %q contains a space", ver)
43-
} else if !strings.HasPrefix(ver, "go") {
44-
return "", fmt.Errorf("version %q doesn't have the 'go' prefix", ver)
45-
}
37+
if err := verifyGoVersions(versions...); err != nil {
38+
return "", err
4639
}
4740

4841
var files = make(map[string]string) // Map key is relative path, and map value is file content.
@@ -103,6 +96,19 @@ func MailDLCL(ctx context.Context, versions []string) (changeURL string, _ error
10396
return fmt.Sprintf("https://golang.org/cl/%d", ci.ChangeNumber), nil
10497
}
10598

99+
func verifyGoVersions(versions ...string) error {
100+
for _, ver := range versions {
101+
if ver != strings.ToLower(ver) {
102+
return fmt.Errorf("version %q is not lowercase", ver)
103+
} else if strings.Contains(ver, " ") {
104+
return fmt.Errorf("version %q contains a space", ver)
105+
} else if !strings.HasPrefix(ver, "go") {
106+
return fmt.Errorf("version %q doesn't have the 'go' prefix", ver)
107+
}
108+
}
109+
return nil
110+
}
111+
106112
func docHost(ver string) string {
107113
if strings.Contains(ver, "rc") || strings.Contains(ver, "beta") {
108114
return "tip.golang.org"

internal/task/doc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Package task implements tasks involved in making a Go release.
6+
package task

0 commit comments

Comments
 (0)