From 4514d72d7046b8c9ee820f1c698c8eff62a8d78d Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Tue, 15 Dec 2020 16:28:15 +0100 Subject: [PATCH] feat: add release notes to version file --- internal/frontend/qt-ie/frontend.go | 4 +- internal/frontend/qt-ie/ui.go | 2 - internal/frontend/qt/frontend.go | 4 +- internal/updater/updater.go | 2 +- internal/updater/updater_test.go | 88 ++++++++++++++--------------- internal/updater/version.go | 21 ++++--- unreleased.md | 1 - utils/versioner/main.go | 16 ++++-- 8 files changed, 74 insertions(+), 64 deletions(-) diff --git a/internal/frontend/qt-ie/frontend.go b/internal/frontend/qt-ie/frontend.go index 84204791..84269a39 100644 --- a/internal/frontend/qt-ie/frontend.go +++ b/internal/frontend/qt-ie/frontend.go @@ -119,8 +119,8 @@ func (f *FrontendQt) Loop() (err error) { func (f *FrontendQt) NotifyManualUpdate(update updater.VersionInfo, canInstall bool) { f.Qml.SetUpdateVersion(update.Version.String()) - f.Qml.SetUpdateLandingPage(update.Landing) - f.Qml.SetUpdateReleaseNotesLink("https://protonmail.com/download/ie/release_notes.html") + f.Qml.SetUpdateLandingPage(update.LandingPage) + f.Qml.SetUpdateReleaseNotesLink(update.ReleaseNotesPage) f.Qml.SetUpdateCanInstall(canInstall) f.updateInfo = update f.Qml.NotifyManualUpdate() diff --git a/internal/frontend/qt-ie/ui.go b/internal/frontend/qt-ie/ui.go index df08e2ec..4c4619c1 100644 --- a/internal/frontend/qt-ie/ui.go +++ b/internal/frontend/qt-ie/ui.go @@ -180,8 +180,6 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) { s.SetProgramTitle(f.programName) s.ConnectOpenLicenseFile(f.openLicenseFile) - s.SetUpdateReleaseNotesLink("https://protonmail.com/download/ie/release_notes.html") - s.ConnectGetLocalVersionInfo(f.getLocalVersionInfo) s.ConnectCheckForUpdates(f.checkForUpdates) s.ConnectGetBackendVersion(func() string { diff --git a/internal/frontend/qt/frontend.go b/internal/frontend/qt/frontend.go index 724a740f..91746c9b 100644 --- a/internal/frontend/qt/frontend.go +++ b/internal/frontend/qt/frontend.go @@ -164,8 +164,8 @@ func (s *FrontendQt) Loop() (err error) { func (s *FrontendQt) NotifyManualUpdate(update updater.VersionInfo, canInstall bool) { s.Qml.SetUpdateVersion(update.Version.String()) - s.Qml.SetUpdateLandingPage(update.Landing) - s.Qml.SetUpdateReleaseNotesLink("https://protonmail.com/download/bridge/release_notes.html") + s.Qml.SetUpdateLandingPage(update.LandingPage) + s.Qml.SetUpdateReleaseNotesLink(update.ReleaseNotesPage) s.Qml.SetUpdateCanInstall(canInstall) s.updateInfo = update s.Qml.NotifyManualUpdate() diff --git a/internal/updater/updater.go b/internal/updater/updater.go index 67ba0477..43d29beb 100644 --- a/internal/updater/updater.go +++ b/internal/updater/updater.go @@ -118,7 +118,7 @@ func (u *Updater) IsUpdateApplicable(version VersionInfo) bool { return false } - if u.settings.GetFloat64(settings.RolloutKey) > version.Rollout { + if u.settings.GetFloat64(settings.RolloutKey) > version.RolloutProportion { return false } diff --git a/internal/updater/updater_test.go b/internal/updater/updater_test.go index b1fe68bf..66513092 100644 --- a/internal/updater/updater_test.go +++ b/internal/updater/updater_test.go @@ -46,10 +46,10 @@ func TestCheck(t *testing.T) { versionMap := VersionMap{ "live": VersionInfo{ - Version: semver.MustParse("1.5.0"), - MinAuto: semver.MustParse("1.4.0"), - Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.5.0"), + MinAuto: semver.MustParse("1.4.0"), + Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", + RolloutProportion: 1.0, }, } @@ -77,16 +77,16 @@ func TestCheckEarlyAccess(t *testing.T) { versionMap := VersionMap{ "live": VersionInfo{ - Version: semver.MustParse("1.5.0"), - MinAuto: semver.MustParse("1.0.0"), - Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.5.0"), + MinAuto: semver.MustParse("1.0.0"), + Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", + RolloutProportion: 1.0, }, "beta": VersionInfo{ - Version: semver.MustParse("1.6.0"), - MinAuto: semver.MustParse("1.0.0"), - Package: "https://protonmail.com/download/bridge/update_1.6.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.6.0"), + MinAuto: semver.MustParse("1.0.0"), + Package: "https://protonmail.com/download/bridge/update_1.6.0_linux.tgz", + RolloutProportion: 1.0, }, } @@ -134,28 +134,28 @@ func TestIsUpdateApplicable(t *testing.T) { updater := newTestUpdater(client, "1.4.0", false) versionOld := VersionInfo{ - Version: semver.MustParse("1.3.0"), - MinAuto: semver.MustParse("1.3.0"), - Package: "https://protonmail.com/download/bridge/update_1.3.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.3.0"), + MinAuto: semver.MustParse("1.3.0"), + Package: "https://protonmail.com/download/bridge/update_1.3.0_linux.tgz", + RolloutProportion: 1.0, } assert.Equal(t, false, updater.IsUpdateApplicable(versionOld)) versionEqual := VersionInfo{ - Version: semver.MustParse("1.4.0"), - MinAuto: semver.MustParse("1.3.0"), - Package: "https://protonmail.com/download/bridge/update_1.4.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.4.0"), + MinAuto: semver.MustParse("1.3.0"), + Package: "https://protonmail.com/download/bridge/update_1.4.0_linux.tgz", + RolloutProportion: 1.0, } assert.Equal(t, false, updater.IsUpdateApplicable(versionEqual)) versionNew := VersionInfo{ - Version: semver.MustParse("1.5.0"), - MinAuto: semver.MustParse("1.3.0"), - Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.5.0"), + MinAuto: semver.MustParse("1.3.0"), + Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", + RolloutProportion: 1.0, } assert.Equal(t, true, updater.IsUpdateApplicable(versionNew)) @@ -170,19 +170,19 @@ func TestCanInstall(t *testing.T) { updater := newTestUpdater(client, "1.4.0", false) versionManual := VersionInfo{ - Version: semver.MustParse("1.5.0"), - MinAuto: semver.MustParse("1.5.0"), - Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.5.0"), + MinAuto: semver.MustParse("1.5.0"), + Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", + RolloutProportion: 1.0, } assert.Equal(t, false, updater.CanInstall(versionManual)) versionAuto := VersionInfo{ - Version: semver.MustParse("1.5.0"), - MinAuto: semver.MustParse("1.3.0"), - Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.5.0"), + MinAuto: semver.MustParse("1.3.0"), + Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", + RolloutProportion: 1.0, } assert.Equal(t, true, updater.CanInstall(versionAuto)) @@ -197,10 +197,10 @@ func TestInstallUpdate(t *testing.T) { updater := newTestUpdater(client, "1.4.0", false) latestVersion := VersionInfo{ - Version: semver.MustParse("1.5.0"), - MinAuto: semver.MustParse("1.4.0"), - Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.5.0"), + MinAuto: semver.MustParse("1.4.0"), + Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", + RolloutProportion: 1.0, } client.EXPECT().DownloadAndVerify( @@ -225,10 +225,10 @@ func TestInstallUpdateBadSignature(t *testing.T) { updater := newTestUpdater(client, "1.4.0", false) latestVersion := VersionInfo{ - Version: semver.MustParse("1.5.0"), - MinAuto: semver.MustParse("1.4.0"), - Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.5.0"), + MinAuto: semver.MustParse("1.4.0"), + Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", + RolloutProportion: 1.0, } client.EXPECT().DownloadAndVerify( @@ -255,10 +255,10 @@ func TestInstallUpdateAlreadyOngoing(t *testing.T) { updater.installer = &fakeInstaller{delay: 2 * time.Second} latestVersion := VersionInfo{ - Version: semver.MustParse("1.5.0"), - MinAuto: semver.MustParse("1.4.0"), - Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", - Rollout: 1.0, + Version: semver.MustParse("1.5.0"), + MinAuto: semver.MustParse("1.4.0"), + Package: "https://protonmail.com/download/bridge/update_1.5.0_linux.tgz", + RolloutProportion: 1.0, } client.EXPECT().DownloadAndVerify( diff --git a/internal/updater/version.go b/internal/updater/version.go index 0dc68cb2..d5ce9b2f 100644 --- a/internal/updater/version.go +++ b/internal/updater/version.go @@ -38,11 +38,14 @@ type VersionInfo struct { // Installers are the locations of installer files (for manual installation). Installers []string - // Landing is the address of the app landing page on protonmail.com. - Landing string + // LandingPage is the address of the app landing page on protonmail.com. + LandingPage string - // Rollout is the current progress of the rollout of this release. - Rollout float64 + // ReleaseNotesPage is the address of the page containing the release notes. + ReleaseNotesPage string + + // RolloutProportion indicates the proportion (0,1] of users that should update to this version. + RolloutProportion float64 } // VersionMap represents the structure of the version.json file. @@ -56,8 +59,9 @@ type VersionInfo struct { // "https://protonmail.com/.../something.rpm", // "https://protonmail.com/.../PKGBUILD" // ], -// "Landing "https://protonmail.com/bridge", -// "Rollout": 0.5 +// "LandingPage": "https://protonmail.com/bridge", +// "ReleaseNotesPage": "https://protonmail.com/.../release_notes.html", +// "RolloutProportion": 0.5 // }, // "beta": { // "Version": "2.4.0-beta", @@ -67,8 +71,9 @@ type VersionInfo struct { // "https://protonmail.com/.../something.rpm", // "https://protonmail.com/.../PKGBUILD" // ], -// "Landing "https://protonmail.com/bridge", -// "Rollout": 0.5 +// "LandingPage": "https://protonmail.com/bridge", +// "ReleaseNotesPage": "https://protonmail.com/.../release_notes.html", +// "RolloutProportion": 0.5 // }, // "...": { // ... diff --git a/unreleased.md b/unreleased.md index 124e367b..e2033e80 100644 --- a/unreleased.md +++ b/unreleased.md @@ -6,7 +6,6 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/) ### Added * GODT-906 Handle RFC2047-encoded content transfer encoding values. - * GODT-875 Added GUI dialog on force update. * GODT-820 Added GUI notification on impossibility of update installation (both silent and manual). * GODT-870 Added GUI notification on error during silent update. diff --git a/utils/versioner/main.go b/utils/versioner/main.go index 88b9c4b9..ff2f8906 100644 --- a/utils/versioner/main.go +++ b/utils/versioner/main.go @@ -88,9 +88,13 @@ func createApp() *cli.App { // nolint[funlen] Usage: "An installer that can be used to manually install the app (can be specified multiple times)", }, &cli.StringFlag{ - Name: "landing", + Name: "landing-page", Usage: "The landing page", }, + &cli.StringFlag{ + Name: "release-notes-page", + Usage: "The release notes page", + }, &cli.Float64Flag{ Name: "rollout", Usage: "What proportion of users should receive this update", @@ -129,12 +133,16 @@ func update(c *cli.Context) error { version.Installers = c.StringSlice("installer") } - if c.IsSet("landing") { - version.Landing = c.String("landing") + if c.IsSet("landing-page") { + version.LandingPage = c.String("landing-page") + } + + if c.IsSet("release-notes-page") { + version.ReleaseNotesPage = c.String("release-notes-page") } if c.IsSet("rollout") { - version.Rollout = c.Float64("rollout") + version.RolloutProportion = c.Float64("rollout") } if c.IsSet("commit") {