Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the website documentation step #58

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions go/interactive/release/website_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,50 @@ import (
tea "github.com/charmbracelet/bubbletea"
"vitess.io/vitess-releaser/go/interactive/ui"
"vitess.io/vitess-releaser/go/releaser"
"vitess.io/vitess-releaser/go/releaser/release"
"vitess.io/vitess-releaser/go/releaser/steps"
)

func WebsiteDocumentationItem(ctx context.Context) *ui.MenuItem {
state := releaser.UnwrapState(ctx)
act := websiteDocumentationAct
if state.Issue.WebsiteDocumentation.Done {
act = nil
}
return &ui.MenuItem{
State: state,
Name: steps.WebsiteDocumentation,
Act: act,
Update: websiteDocumentationUpdate,
Info: state.Issue.WebsiteDocumentation.URL,
IsDone: state.Issue.WebsiteDocumentation.Done,
IsDone: state.Issue.WebsiteDocumentation,
}
}

type websiteDocumentationUrl string
type websiteDocumentationMsg []string

func websiteDocumentationUpdate(mi *ui.MenuItem, msg tea.Msg) (*ui.MenuItem, tea.Cmd) {
switch msg := msg.(type) {
case websiteDocumentationMsg:
return mi, ui.PushDialog(&ui.DoneDialog{
StepName: mi.Name,
Title: steps.WebsiteDocumentation,
Message: msg,
IsDone: mi.IsDone,
})
case ui.DoneDialogAction:
if string(msg) != mi.Name {
return mi, nil
}
mi.State.Issue.WebsiteDocumentation = !mi.State.Issue.WebsiteDocumentation
mi.IsDone = !mi.IsDone
pl, fn := mi.State.UploadIssue()
return mi, tea.Batch(func() tea.Msg {
fn()
return tea.Msg("")
}, ui.PushDialog(ui.NewProgressDialog("Updating the Release Issue", pl)))
}
return mi, nil
}

func websiteDocumentationAct(mi *ui.MenuItem) (*ui.MenuItem, tea.Cmd) {
return mi, nil
return mi, func() tea.Msg {
return websiteDocumentationMsg(release.WebsiteDocs(mi.State))
}
}
16 changes: 3 additions & 13 deletions go/releaser/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ const (
stateReadingTagReleaseItem
stateReadingReleaseNotesMainItem
stateReadingBackToDevModeItem
stateReadingWebsiteDocsItem
stateReadingCloseMilestoneItem
stateReadingVtopUpdateGo
stateReadingVtopCreateReleasePR
)

const (
markdownItemDone = "- [x]"
markdownItemToDo = "- [ ]"

// Divers
dateItem = "This release is scheduled for"
Expand Down Expand Up @@ -135,7 +133,7 @@ type (
TagRelease ItemWithLink
ReleaseNotesOnMain ItemWithLink
BackToDevMode ItemWithLink
WebsiteDocumentation ItemWithLink
WebsiteDocumentation bool
Benchmarked bool
DockerImages bool
CloseMilestone ItemWithLink
Expand Down Expand Up @@ -232,10 +230,7 @@ The release of vitess-operator v{{.VtopRelease}} is also planned
{{- if .BackToDevMode.URL }}
- {{ .BackToDevMode.URL }}
{{- end }}
- [{{fmtStatus .WebsiteDocumentation.Done}}] Update the website documentation.
{{- if .WebsiteDocumentation.URL }}
- {{ .WebsiteDocumentation.URL }}
{{- end }}
- [{{fmtStatus .WebsiteDocumentation}}] Update the website documentation.
- [{{fmtStatus .Benchmarked}}] Make sure the release is benchmarked by arewefastyet.
- [{{fmtStatus .DockerImages}}] Docker Images available on DockerHub.
{{- if eq .RC 0 }}
Expand Down Expand Up @@ -378,10 +373,7 @@ func (s *State) LoadIssue() {
st = stateReadingBackToDevModeItem
}
case strings.Contains(line, websiteDocItem):
newIssue.WebsiteDocumentation.Done = strings.HasPrefix(line, markdownItemDone)
if isNextLineAList(lines, i) {
st = stateReadingWebsiteDocsItem
}
newIssue.WebsiteDocumentation = strings.HasPrefix(line, markdownItemDone)
case strings.Contains(line, benchmarkedItem):
newIssue.Benchmarked = strings.HasPrefix(line, markdownItemDone)
case strings.Contains(line, dockerImagesItem):
Expand Down Expand Up @@ -418,8 +410,6 @@ func (s *State) LoadIssue() {
newIssue.ReleaseNotesOnMain.URL = handleSingleTextItem(line, &st)
case stateReadingBackToDevModeItem:
newIssue.BackToDevMode.URL = handleSingleTextItem(line, &st)
case stateReadingWebsiteDocsItem:
newIssue.WebsiteDocumentation.URL = handleSingleTextItem(line, &st)
case stateReadingCloseMilestoneItem:
newIssue.CloseMilestone.URL = handleSingleTextItem(line, &st)
case stateReadingVtopUpdateGo:
Expand Down
43 changes: 43 additions & 0 deletions go/releaser/release/website_docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2024 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package release

import (
"vitess.io/vitess-releaser/go/releaser"
)

func WebsiteDocs(state *releaser.State) []string {
msg := []string{
"We want to open a Pull Request to update the documentation.",
"There are several pages we want to update:",
"\t- https://vitess.io/docs/releases/: we must add the new release to the list with all its information and link.",
"\t- https://vitess.io/docs/get-started/local/: we must use the proper version increment for this guide and the proper SHA.",
"We must do a git checkout to the proper release branch after cloning Vitess on the following pages:",
"\t- https://vitess.io/docs/get-started/operator/#install-the-operator",
"\t- https://vitess.io/docs/get-started/local-mac/#install-vitess",
"\t- https://vitess.io/docs/get-started/local-docker/#check-out-the-vitessiovitess-repository",
"\t- https://vitess.io/docs/get-started/vttestserver-docker-image/#check-out-the-vitessiovitess-repository",
}
if state.Issue.RC > 0 {
msg = append(msg, []string{
"",
"Since we are doing an RC release, we must use the ./tools/rc_release.sh script in the website repository to update the documentation even further.",
"The script creates a new entry in the sidebar which represents the next version on main and mark the version we are releasing as RC.",
}...)
}
return msg
}