Skip to content

Commit f744b1a

Browse files
committed
Create code_freeze packages
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
1 parent 1bad72e commit f744b1a

14 files changed

+88
-89
lines changed

go/interactive/pre_release/code_freeze.go go/interactive/code_freeze/code_freeze.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"context"
2121

2222
tea "github.com/charmbracelet/bubbletea"
2323
"vitess.io/vitess-releaser/go/interactive/ui"
2424
"vitess.io/vitess-releaser/go/releaser"
25+
"vitess.io/vitess-releaser/go/releaser/code_freeze"
2526
"vitess.io/vitess-releaser/go/releaser/steps"
26-
27-
"vitess.io/vitess-releaser/go/releaser/pre_release"
2827
)
2928

3029
func CodeFreezeMenuItem(ctx context.Context) *ui.MenuItem {
@@ -61,7 +60,7 @@ func codeFreezeUpdate(mi *ui.MenuItem, msg tea.Msg) (*ui.MenuItem, tea.Cmd) {
6160
}
6261

6362
func codeFreezeAct(mi *ui.MenuItem) (*ui.MenuItem, tea.Cmd) {
64-
pl, freeze := pre_release.CodeFreeze(mi.State)
63+
pl, freeze := code_freeze.CodeFreeze(mi.State)
6564
return mi, tea.Batch(func() tea.Msg {
6665
return codeFreezeUrl(freeze())
6766
}, ui.PushDialog(ui.NewProgressDialog("Code freeze", pl)))

go/interactive/pre_release/copy_branch_protection.go go/interactive/code_freeze/copy_branch_protection.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"context"
2121

2222
tea "github.com/charmbracelet/bubbletea"
2323
"vitess.io/vitess-releaser/go/interactive/ui"
2424
"vitess.io/vitess-releaser/go/releaser"
25+
"vitess.io/vitess-releaser/go/releaser/code_freeze"
2526
"vitess.io/vitess-releaser/go/releaser/steps"
26-
27-
"vitess.io/vitess-releaser/go/releaser/pre_release"
2827
)
2928

3029
func CopyBranchProtectionMenuItem(ctx context.Context) *ui.MenuItem {
@@ -58,7 +57,7 @@ func copyBranchProtectionUpdate(mi *ui.MenuItem, msg tea.Msg) (*ui.MenuItem, tea
5857
}
5958

6059
func copyBranchProtectionAct(mi *ui.MenuItem) (*ui.MenuItem, tea.Cmd) {
61-
pl, copyRules := pre_release.CopyBranchProtectionRules(mi.State)
60+
pl, copyRules := code_freeze.CopyBranchProtectionRules(mi.State)
6261
return mi, tea.Batch(func() tea.Msg {
6362
return copyBranchProtectionUrl(copyRules())
6463
}, ui.PushDialog(ui.NewProgressDialog("Copy Branch Protection Rule", pl)))

go/interactive/pre_release/create_backport_to_label.go go/interactive/code_freeze/create_backport_to_label.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"context"
2121

2222
tea "github.com/charmbracelet/bubbletea"
2323
"vitess.io/vitess-releaser/go/interactive/ui"
2424
"vitess.io/vitess-releaser/go/releaser"
25+
"vitess.io/vitess-releaser/go/releaser/code_freeze"
2526
"vitess.io/vitess-releaser/go/releaser/steps"
26-
27-
"vitess.io/vitess-releaser/go/releaser/pre_release"
2827
)
2928

3029
func CreateBackportToLabelMenuItem(ctx context.Context) *ui.MenuItem {
@@ -60,7 +59,7 @@ func createBackportToLabelUpdate(mi *ui.MenuItem, msg tea.Msg) (*ui.MenuItem, te
6059
}
6160

6261
func createBackportToLabelAct(mi *ui.MenuItem) (*ui.MenuItem, tea.Cmd) {
63-
pl, create := pre_release.CreateBackportToLabel(mi.State)
62+
pl, create := code_freeze.CreateBackportToLabel(mi.State)
6463
return mi, tea.Batch(func() tea.Msg {
6564
return createBackportToLabelUrl(create())
6665
}, ui.PushDialog(ui.NewProgressDialog("Create Backport To label", pl)))

go/interactive/pre_release/create_github_milestones.go go/interactive/code_freeze/create_github_milestones.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"context"
2121

2222
tea "github.com/charmbracelet/bubbletea"
2323
"vitess.io/vitess-releaser/go/interactive/ui"
2424
"vitess.io/vitess-releaser/go/releaser"
25-
"vitess.io/vitess-releaser/go/releaser/pre_release"
25+
"vitess.io/vitess-releaser/go/releaser/code_freeze"
2626
"vitess.io/vitess-releaser/go/releaser/steps"
2727
)
2828

@@ -60,7 +60,7 @@ func createMilestoneUpdate(mi *ui.MenuItem, msg tea.Msg) (*ui.MenuItem, tea.Cmd)
6060
}
6161

6262
func createMilestoneAct(mi *ui.MenuItem) (*ui.MenuItem, tea.Cmd) {
63-
pl, create := pre_release.NewMilestone(mi.State)
63+
pl, create := code_freeze.NewMilestone(mi.State)
6464
return mi, tea.Batch(func() tea.Msg {
6565
return createMilestone(create())
6666
}, ui.PushDialog(ui.NewProgressDialog("Creating new GitHub Milestone", pl)))

go/interactive/pre_release/update_snapshot.go go/interactive/code_freeze/update_snapshot.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"context"
2121

2222
tea "github.com/charmbracelet/bubbletea"
2323
"vitess.io/vitess-releaser/go/interactive/ui"
2424
"vitess.io/vitess-releaser/go/releaser"
25+
"vitess.io/vitess-releaser/go/releaser/code_freeze"
2526
"vitess.io/vitess-releaser/go/releaser/steps"
26-
27-
"vitess.io/vitess-releaser/go/releaser/pre_release"
2827
)
2928

3029
func UpdateSnapshotOnMainMenuItem(ctx context.Context) *ui.MenuItem {
@@ -61,7 +60,7 @@ func updateSnapshotOnMainUpdate(mi *ui.MenuItem, msg tea.Msg) (*ui.MenuItem, tea
6160
}
6261

6362
func updateSnapshotOnMainAct(mi *ui.MenuItem) (*ui.MenuItem, tea.Cmd) {
64-
pl, update := pre_release.UpdateSnapshotOnMain(mi.State)
63+
pl, update := code_freeze.UpdateSnapshotOnMain(mi.State)
6564
return mi, tea.Batch(func() tea.Msg {
6665
return updateSnapshotOnMainUrl(update())
6766
}, ui.PushDialog(ui.NewProgressDialog("Update SNAPSHOT on main", pl)))

go/interactive/main_menu.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323

2424
tea "github.com/charmbracelet/bubbletea"
25+
"vitess.io/vitess-releaser/go/interactive/code_freeze"
2526
"vitess.io/vitess-releaser/go/interactive/post_release"
2627
"vitess.io/vitess-releaser/go/interactive/pre_release"
2728
"vitess.io/vitess-releaser/go/interactive/release"
@@ -47,11 +48,11 @@ func MainScreen(ctx context.Context, state *releaser.State) {
4748
codeFreezeMenu := ui.NewMenu(
4849
ctx,
4950
"Code Freeze",
50-
pre_release.CodeFreezeMenuItem(ctx),
51-
pre_release.CopyBranchProtectionMenuItem(ctx),
52-
pre_release.CreateBackportToLabelMenuItem(ctx),
53-
pre_release.UpdateSnapshotOnMainMenuItem(ctx),
54-
pre_release.CreateMilestoneMenuItem(ctx),
51+
code_freeze.CodeFreezeMenuItem(ctx),
52+
code_freeze.CopyBranchProtectionMenuItem(ctx),
53+
code_freeze.CreateBackportToLabelMenuItem(ctx),
54+
code_freeze.UpdateSnapshotOnMainMenuItem(ctx),
55+
code_freeze.CreateMilestoneMenuItem(ctx),
5556
)
5657

5758
preReleaseMenu := ui.NewMenu(

go/releaser/pre_release/code_freeze.go go/releaser/code_freeze/code_freeze.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"fmt"
@@ -168,7 +168,7 @@ func activateCodeFreeze() {
168168
changeCodeFreezeWorkflow(codeFreezeActivated)
169169
}
170170

171-
func deactivateCodeFreeze() {
171+
func DeactivateCodeFreeze() {
172172
changeCodeFreezeWorkflow(codeFreezeDeactivated)
173173
}
174174

go/releaser/pre_release/copy_branch_protection_rules.go go/releaser/code_freeze/copy_branch_protection_rules.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"vitess.io/vitess-releaser/go/releaser"

go/releaser/pre_release/create_backport_to_label.go go/releaser/code_freeze/create_backport_to_label.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"fmt"

go/releaser/pre_release/milestone.go go/releaser/code_freeze/milestone.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"fmt"

go/releaser/pre_release/update_snapshot.go go/releaser/code_freeze/update_snapshot.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package pre_release
17+
package code_freeze
1818

1919
import (
2020
"fmt"
@@ -66,10 +66,10 @@ func UpdateSnapshotOnMain(state *releaser.State) (*logging.ProgressLogging, func
6666
newBranchName := git.FindNewGeneratedBranch(state.VitessRelease.Remote, "main", "snapshot-update")
6767

6868
pl.NewStepf("Update version.go")
69-
UpdateVersionGoFile(snapshotRelease)
69+
releaser.UpdateVersionGoFile(snapshotRelease)
7070

7171
pl.NewStepf("Update the Java directory")
72-
UpdateJavaDir(snapshotRelease)
72+
releaser.UpdateJavaDir(snapshotRelease)
7373

7474
pl.NewStepf("Commit and push to branch %s", newBranchName)
7575
if git.CommitAll(fmt.Sprintf("Snapshot update: %s", snapshotUpdatePRName)) {

go/releaser/pre_release/create_release_pr.go

+4-54
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ package pre_release
1919
import (
2020
"fmt"
2121
"io/fs"
22-
"os"
23-
"os/exec"
24-
"path"
2522
"path/filepath"
2623
"strings"
27-
"time"
2824

2925
"vitess.io/vitess-releaser/go/releaser"
26+
"vitess.io/vitess-releaser/go/releaser/code_freeze"
3027
"vitess.io/vitess-releaser/go/releaser/git"
3128
"vitess.io/vitess-releaser/go/releaser/github"
3229
"vitess.io/vitess-releaser/go/releaser/logging"
@@ -36,31 +33,6 @@ import (
3633
const (
3734
examplesOperator = "./examples/operator"
3835
examplesCompose = "./examples/compose/"
39-
40-
versionGoFile = "./go/vt/servenv/version.go"
41-
versionGo = `/*
42-
Copyright %d The Vitess Authors.
43-
44-
Licensed under the Apache License, Version 2.0 (the "License");
45-
you may not use this file except in compliance with the License.
46-
You may obtain a copy of the License at
47-
48-
http://www.apache.org/licenses/LICENSE-2.0
49-
50-
Unless required by applicable law or agreed to in writing, software
51-
distributed under the License is distributed on an "AS IS" BASIS,
52-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53-
See the License for the specific language governing permissions and
54-
limitations under the License.
55-
*/
56-
57-
package servenv
58-
59-
// DO NOT EDIT
60-
// THIS FILE IS AUTO-GENERATED DURING NEW RELEASES BY THE VITESS-RELEASER
61-
62-
const versionName = "%s"
63-
`
6436
)
6537

6638
func CreateReleasePR(state *releaser.State) (*logging.ProgressLogging, func() string) {
@@ -112,7 +84,7 @@ func CreateReleasePR(state *releaser.State) (*logging.ProgressLogging, func() st
11284
// deactivate code freeze
11385
if unfreezeBranch {
11486
pl.NewStepf("Deactivate code freeze on %s", state.VitessRelease.ReleaseBranch)
115-
deactivateCodeFreeze()
87+
code_freeze.DeactivateCodeFreeze()
11688

11789
pl.NewStepf("Commit unfreezing the branch %s", state.VitessRelease.ReleaseBranch)
11890
if !git.CommitAll(fmt.Sprintf("Unfreeze branch %s", state.VitessRelease.ReleaseBranch)) {
@@ -135,10 +107,10 @@ func CreateReleasePR(state *releaser.State) (*logging.ProgressLogging, func() st
135107
updateExamples(lowerRelease, strings.ToLower(releaser.AddRCToReleaseTitle(state.VtOpRelease.Release, state.Issue.RC)))
136108

137109
pl.NewStepf("Update version.go")
138-
UpdateVersionGoFile(lowerRelease)
110+
releaser.UpdateVersionGoFile(lowerRelease)
139111

140112
pl.NewStepf("Update the Java directory")
141-
UpdateJavaDir(lowerRelease)
113+
releaser.UpdateJavaDir(lowerRelease)
142114

143115
pl.NewStepf("Commit the update to the codebase for the v%s release", state.VitessRelease.Release)
144116
if !git.CommitAll(fmt.Sprintf("Update codebase for the v%s release", state.VitessRelease.Release)) {
@@ -225,25 +197,3 @@ func updateExamples(newVersion, vtopNewVersion string) {
225197
args = append([]string{"-f"}, filesBackups...)
226198
utils.Exec("rm", args...)
227199
}
228-
229-
func UpdateVersionGoFile(newVersion string) {
230-
err := os.WriteFile(versionGoFile, []byte(fmt.Sprintf(versionGo, time.Now().Year(), newVersion)), os.ModePerm)
231-
if err != nil {
232-
utils.LogPanic(err, "failed to write to file %s", versionGoFile)
233-
}
234-
}
235-
236-
func UpdateJavaDir(newVersion string) {
237-
// cd $ROOT/java || exit 1
238-
// mvn versions:set -DnewVersion=$1
239-
cmd := exec.Command("mvn", "versions:set", fmt.Sprintf("-DnewVersion=%s", newVersion))
240-
pwd, err := os.Getwd()
241-
if err != nil {
242-
utils.LogPanic(err, "failed to get current working directory")
243-
}
244-
cmd.Dir = path.Join(pwd, "/java")
245-
out, err := cmd.CombinedOutput()
246-
if err != nil {
247-
utils.LogPanic(err, "failed to execute: %s, got: %s", cmd.String(), string(out))
248-
}
249-
}

go/releaser/release/back_to_dev.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"vitess.io/vitess-releaser/go/releaser/git"
2424
"vitess.io/vitess-releaser/go/releaser/github"
2525
"vitess.io/vitess-releaser/go/releaser/logging"
26-
"vitess.io/vitess-releaser/go/releaser/pre_release"
2726
)
2827

2928
func BackToDevModeOnBranch(state *releaser.State, itemToUpdate *releaser.ItemWithLink, branch string) (*logging.ProgressLogging, func() string) {
@@ -74,10 +73,10 @@ func BackToDevModeOnBranch(state *releaser.State, itemToUpdate *releaser.ItemWit
7473
newBranchName := git.FindNewGeneratedBranch(state.VitessRelease.Remote, branch, "back-to-dev-mode")
7574

7675
pl.NewStepf("Update version.go")
77-
pre_release.UpdateVersionGoFile(devModeRelease)
76+
releaser.UpdateVersionGoFile(devModeRelease)
7877

7978
pl.NewStepf("Update the Java directory")
80-
pre_release.UpdateJavaDir(devModeRelease)
79+
releaser.UpdateJavaDir(devModeRelease)
8180

8281
pl.NewStepf("Commit and push to branch %s", newBranchName)
8382
if git.CommitAll(fmt.Sprintf("Back to dev mode: %s", backToDevModePRName)) {

0 commit comments

Comments
 (0)