Skip to content

Commit

Permalink
Skip release archive
Browse files Browse the repository at this point in the history
Don't archive the release any more and move the announcement to the
release artifacts (`kubernetes-release/release/v1.x.y`).

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Aug 21, 2024
1 parent a7bd8b3 commit 24f07c5
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 1,328 deletions.
3 changes: 2 additions & 1 deletion cmd/krel/cmd/announce_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/release/pkg/announce"

"sigs.k8s.io/release-utils/command"
)
Expand Down Expand Up @@ -240,7 +241,7 @@ func (opts *buildAnnounceOptions) saveAnnouncement(announcementSubject string, a
return fmt.Errorf("saving announcement.html: %w", err)
}

absOutputPath = filepath.Join(opts.workDir, "announcement-subject.txt")
absOutputPath = filepath.Join(opts.workDir, announce.SubjectFile)
logrus.Infof("Writing announcement subject to %s", absOutputPath)
err = os.WriteFile(absOutputPath, []byte(announcementSubject), os.FileMode(0o644))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/krel/cmd/announce_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func runAnnounce(opts *sendAnnounceOptions, announceRootOpts *announceOptions, r

tag := util.AddTagPrefix(announceRootOpts.tag)
u := fmt.Sprintf(
"%s/archive/anago-%s/announcement.html",
"%s/release/%s/announcement.html",
release.URLPrefixForBucket(release.ProductionBucket), tag,
)
logrus.Infof("Using announcement remote URL: %s", u)
Expand Down
22 changes: 12 additions & 10 deletions pkg/anago/anago.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"sigs.k8s.io/release-utils/util"
"sigs.k8s.io/release-utils/version"

"k8s.io/release/pkg/announce"
"k8s.io/release/pkg/release"
)

Expand All @@ -51,6 +52,12 @@ const (
// releaseNotesJSONFile is the file containing the release notes in json format.
releaseNotesJSONFile = workspaceDir + "/src/release-notes.json"

// announcementHTMLFile is the file containing the release announcement in HTML format.
announcementHTMLFile = workspaceDir + "/src/" + announce.AnnouncementFile

// announcementSubjectFile is the file containing the release announcement subject.
announcementSubjectFile = workspaceDir + "/src/" + announce.SubjectFile

// The default license for all artifacts.
LicenseIdentifier = "Apache-2.0"
)
Expand Down Expand Up @@ -431,6 +438,11 @@ func (r *Release) Run() error {
logrus.Warnf("Unable to check provenance attestation: %v", err)
}

logger.WithStep().Info("Creating announcement")
if err := r.client.CreateAnnouncement(); err != nil {
return fmt.Errorf("create announcement: %w", err)
}

logger.WithStep().Info("Pushing artifacts")
if err := r.client.PushArtifacts(); err != nil {
return fmt.Errorf("push artifacts: %w", err)
Expand All @@ -441,21 +453,11 @@ func (r *Release) Run() error {
return fmt.Errorf("push git objects: %w", err)
}

logger.WithStep().Info("Creating announcement")
if err := r.client.CreateAnnouncement(); err != nil {
return fmt.Errorf("create announcement: %w", err)
}

logger.WithStep().Info("Updating GitHub release page")
if err := r.client.UpdateGitHubPage(); err != nil {
return fmt.Errorf("updating github page: %w", err)
}

logger.WithStep().Info("Archiving release")
if err := r.client.Archive(); err != nil {
return fmt.Errorf("archive release: %w", err)
}

logger.Info("Release done")
return nil
}
65 changes: 0 additions & 65 deletions pkg/anago/anagofakes/fake_release_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 0 additions & 74 deletions pkg/anago/anagofakes/fake_release_impl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 25 additions & 46 deletions pkg/anago/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ type releaseClient interface {
// UpdateGitHubPage updates the GitHub release page to with the source code
// and release information.
UpdateGitHubPage() error

// Archive copies the release process logs to a bucket and sets private
// permissions on it.
Archive() error
}

// DefaultRelease is the default staging implementation used in production.
Expand Down Expand Up @@ -154,7 +150,6 @@ type releaseImpl interface {
PushBranches(pusher *release.GitObjectPusher, branchList []string) error
PushMainBranch(pusher *release.GitObjectPusher) error
NewGitPusher(opts *release.GitObjectPusherOptions) (*release.GitObjectPusher, error)
ArchiveRelease(options *release.ArchiverOptions) error
NormalizePath(store object.Store, pathParts ...string) (string, error)
CopyToRemote(store object.Store, src, gcsPath string) error
PublishReleaseNotesIndex(
Expand Down Expand Up @@ -265,11 +260,6 @@ func (d *defaultReleaseImpl) CreateAnnouncement(options *announce.Options) error
return announce.NewAnnounce(options).CreateForRelease()
}

func (d *defaultReleaseImpl) ArchiveRelease(options *release.ArchiverOptions) error {
// Create a new release archiver
return release.NewArchiver(options).ArchiveRelease()
}

func (d *defaultReleaseImpl) UpdateGitHubPage(options *github.Options) error {
return github.NewGitHub(options).UpdateGitHubPage()
}
Expand Down Expand Up @@ -427,7 +417,7 @@ func (d *DefaultRelease) PushArtifacts() error {
}
}

logrus.Info("Publishing release notes JSON")
logrus.Info("Publishing release notes JSON and announcement")
objStore := object.NewGCS()
objStore.SetOptions(objStore.WithNoClobber(false))
gcsReleaseRootPath, err := d.impl.NormalizePath(
Expand All @@ -441,12 +431,19 @@ func (d *DefaultRelease) PushArtifacts() error {
"/%s/release-notes.json", d.state.versions.Prime(),
)

if err := d.impl.CopyToRemote(
objStore,
releaseNotesJSONFile,
gcsReleaseNotesPath,
); err != nil {
return fmt.Errorf("copy release notes to bucket: %w", err)
for from, to := range map[string]string{
releaseNotesJSONFile: gcsReleaseNotesPath,
announcementHTMLFile: gcsReleaseRootPath + fmt.Sprintf("/%s/%s", d.state.versions.Prime(), announce.AnnouncementFile),
announcementSubjectFile: gcsReleaseRootPath + fmt.Sprintf("/%s/%s", d.state.versions.Prime(), announce.SubjectFile),
} {
logrus.Infof("Copy %q to %q", from, to)
if err := d.impl.CopyToRemote(
objStore,
from,
to,
); err != nil {
return fmt.Errorf("copy file notes to bucket: %w", err)
}
}

for _, version := range d.state.versions.Ordered() {
Expand Down Expand Up @@ -564,6 +561,17 @@ func (d *DefaultRelease) CreateAnnouncement() error {
logrus.Info("Not creating publishing bot issue in mock release")
}
}

args := ""
if d.options.NoMock {
args += " --nomock"
}
args += " --tag=" + d.state.versions.Prime()

logrus.Infof(
"To announce this release, run:\n\n$ krel announce send%s", args,
)

return nil
}

Expand Down Expand Up @@ -600,35 +608,6 @@ func (d *DefaultRelease) UpdateGitHubPage() error {
return nil
}

// Archive stores the release artifact in a bucket along with
// its logs for long term conservation.
func (d *DefaultRelease) Archive() error {
// Create a new options set for the release archiver
archiverOptions := &release.ArchiverOptions{
ReleaseBuildDir: filepath.Join(workspaceDir, "src"),
LogFile: d.state.logFile,
BuildVersion: d.options.BuildVersion,
PrimeVersion: d.state.versions.Prime(),
Bucket: d.options.Bucket(),
}

if err := d.impl.ArchiveRelease(archiverOptions); err != nil {
return fmt.Errorf("running the release archival process: %w", err)
}

args := ""
if d.options.NoMock {
args += " --nomock"
}
args += " --tag=" + d.state.versions.Prime()

logrus.Infof(
"To announce this release, run:\n\n$ krel announce send%s", args,
)

return nil
}

// CheckProvenance verifies the artifacts staged in the release bucket
// by verifying the provenance metadata generated during the stage run.
func (d *DefaultRelease) CheckProvenance() error {
Expand Down
7 changes: 5 additions & 2 deletions pkg/announce/announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ import (
)

const (
announcementFile = "announcement.html"
subjectFile = "announcement-subject.txt"
// AnnouncementFile is the default announcement HTML file.
AnnouncementFile = "announcement.html"

// SubjectFile is the default subject file for the announcement.
SubjectFile = "announcement-subject.txt"
)

const branchAnnouncement = `Kubernetes Community,
Expand Down
Loading

0 comments on commit 24f07c5

Please sign in to comment.