Skip to content

Commit

Permalink
internal/task: add task to tweet about Go releases
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dmitshur committed Nov 2, 2021
1 parent 5891341 commit 46f6bfb
Show file tree
Hide file tree
Showing 7 changed files with 776 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/release/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
)

// File represents a file on the golang.org downloads page.
// It should be kept in sync with the download code in x/tools/godoc/dl.
// It should be kept in sync with the download code in x/website/internal/dl.
type File struct {
Filename string `json:"filename"`
OS string `json:"os"`
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ require (
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f
github.com/creack/pty v1.1.15
github.com/davecgh/go-spew v1.1.1
github.com/esimov/stackblur-go v1.0.1
github.com/gliderlabs/ssh v0.3.3
github.com/golang-migrate/migrate/v4 v4.15.0-beta.3
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.6
github.com/google/go-github v17.0.0+incompatible
Expand All @@ -31,6 +33,7 @@ require (
go.opencensus.io v0.23.0
go4.org v0.0.0-20180809161055-417644f6feb5
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
golang.org/x/perf v0.0.0-20210220033136-40a54f11e909
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/esimov/stackblur-go v1.0.1 h1:FI7PA9/lJKomN0Cwzzc0mnezRIzUqe31wPC16CC5m1Y=
github.com/esimov/stackblur-go v1.0.1/go.mod h1:a3zzeKuJKUpCcReHmEsuPaEnq42D2b/bHoCI8UjIuMY=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down Expand Up @@ -268,6 +270,8 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
github.com/golang-migrate/migrate/v4 v4.15.0-beta.3 h1:tqLMcxs6gB6+b2Jhwao4s2sNMSKku+0rjtBtKucKWkg=
github.com/golang-migrate/migrate/v4 v4.15.0-beta.3/go.mod h1:g9qbiDvB47WyrRnNu2t2gMZFNHKnatsYRxsGZbCi4EM=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -793,6 +797,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
24 changes: 15 additions & 9 deletions internal/task/dlcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package task implements tasks involved in making a Go release.
package task

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

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

func verifyGoVersions(versions ...string) error {
for _, ver := range versions {
if ver != strings.ToLower(ver) {
return fmt.Errorf("version %q is not lowercase", ver)
} else if strings.Contains(ver, " ") {
return fmt.Errorf("version %q contains a space", ver)
} else if !strings.HasPrefix(ver, "go") {
return fmt.Errorf("version %q doesn't have the 'go' prefix", ver)
}
}
return nil
}

func docHost(ver string) string {
if strings.Contains(ver, "rc") || strings.Contains(ver, "beta") {
return "tip.golang.org"
Expand Down
6 changes: 6 additions & 0 deletions internal/task/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package task implements tasks involved in making a Go release.
package task
Loading

0 comments on commit 46f6bfb

Please sign in to comment.