From 62d97f85ec4b02714d88936c7da603e6a3d7fa47 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Tue, 16 May 2023 19:43:41 +1000 Subject: [PATCH] v2.5.1 --- v2/cmd/wails/internal/version.txt | 2 +- v2/tools/release/release.go | 91 ++++++++++++++++++++++--------- website/src/pages/changelog.mdx | 2 + 3 files changed, 68 insertions(+), 27 deletions(-) diff --git a/v2/cmd/wails/internal/version.txt b/v2/cmd/wails/internal/version.txt index d80b4a814..8c99f59fb 100644 --- a/v2/cmd/wails/internal/version.txt +++ b/v2/cmd/wails/internal/version.txt @@ -1 +1 @@ -v2.5.0 \ No newline at end of file +v2.5.1 \ No newline at end of file diff --git a/v2/tools/release/release.go b/v2/tools/release/release.go index 558299558..a09fa7a3b 100644 --- a/v2/tools/release/release.go +++ b/v2/tools/release/release.go @@ -2,10 +2,12 @@ package main import ( "encoding/json" + "github.com/samber/lo" "os" "os/exec" "strconv" "strings" + "time" "github.com/wailsapp/wails/v2/internal/s" ) @@ -43,45 +45,82 @@ func runCommand(name string, arg ...string) { checkError(err) } +func IsPointRelease(currentVersion string, newVersion string) bool { + // The first n-1 parts of the version should be the same + if currentVersion[:len(currentVersion)-2] != newVersion[:len(newVersion)-2] { + return false + } + // split on the last dot in the string + currentVersionSplit := strings.Split(currentVersion, ".") + newVersionSplit := strings.Split(newVersion, ".") + // compare the + // if the last part of the version is the same, it's a point release + currentMinor := lo.Must(strconv.Atoi(currentVersionSplit[len(currentVersionSplit)-1])) + newMinor := lo.Must(strconv.Atoi(newVersionSplit[len(newVersionSplit)-1])) + return newMinor == currentMinor+1 +} + func main() { var newVersion string + var isPointRelease bool if len(os.Args) > 1 { newVersion = os.Args[1] - err := os.WriteFile(versionFile, []byte(newVersion), 0755) + currentVersion, err := os.ReadFile(versionFile) checkError(err) + err = os.WriteFile(versionFile, []byte(newVersion), 0755) + checkError(err) + isPointRelease = IsPointRelease(string(currentVersion), newVersion) } else { newVersion = updateVersion() } + // Update ChangeLog s.CD("../../../website") - runCommand("npx", "-y", "pnpm", "install") - s.ECHO("Generating new Docs for version: " + newVersion) - - runCommand("npx", "pnpm", "run", "docusaurus", "docs:version", newVersion) - - runCommand("npx", "pnpm", "run", "write-translations") - - // Load the version list/* - versionsData, err := os.ReadFile("versions.json") + // Read in `src/pages/changelog.mdx` + changelogData, err := os.ReadFile("src/pages/changelog.mdx") checkError(err) - var versions []string - err = json.Unmarshal(versionsData, &versions) - checkError(err) - oldestVersion := versions[len(versions)-1] - s.ECHO(oldestVersion) - versions = versions[0 : len(versions)-1] - newVersions, err := json.Marshal(&versions) - checkError(err) - err = os.WriteFile("versions.json", newVersions, 0755) + changelog := string(changelogData) + // Split on the line that has `## [Unreleased]` + changelogSplit := strings.Split(changelog, "## [Unreleased]") + // Get today's date in YYYY-MM-DD format + today := time.Now().Format("2006-01-02") + // Add the new version to the top of the changelog + newChangelog := changelogSplit[0] + "## [Unreleased]\n\n## [" + newVersion + "] - " + today + changelogSplit[1] + // Write the changelog back + err = os.WriteFile("src/pages/changelog.mdx", []byte(newChangelog), 0755) checkError(err) - s.ECHO("Removing old version: " + oldestVersion) - s.CD("versioned_docs") - s.RMDIR("version-" + oldestVersion) - s.CD("../versioned_sidebars") - s.RM("version-" + oldestVersion + "-sidebars.json") - s.CD("..") + if !isPointRelease { + runCommand("npx", "-y", "pnpm", "install") - runCommand("npx", "pnpm", "run", "build") + s.ECHO("Generating new Docs for version: " + newVersion) + + runCommand("npx", "pnpm", "run", "docusaurus", "docs:version", newVersion) + + runCommand("npx", "pnpm", "run", "write-translations") + + // Load the version list/* + versionsData, err := os.ReadFile("versions.json") + checkError(err) + var versions []string + err = json.Unmarshal(versionsData, &versions) + checkError(err) + oldestVersion := versions[len(versions)-1] + s.ECHO(oldestVersion) + versions = versions[0 : len(versions)-1] + newVersions, err := json.Marshal(&versions) + checkError(err) + err = os.WriteFile("versions.json", newVersions, 0755) + checkError(err) + + s.ECHO("Removing old version: " + oldestVersion) + s.CD("versioned_docs") + s.RMDIR("version-" + oldestVersion) + s.CD("../versioned_sidebars") + s.RM("version-" + oldestVersion + "-sidebars.json") + s.CD("..") + + runCommand("npx", "pnpm", "run", "build") + } } diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index c762fb418..f08a679da 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v2.5.1] - 2023-05-16 + ### Breaking Changes - The Go WebView2Loader allowed env variable and registry overrides to change the behaviour of WebView2. This is not possible when using the native WebView2Loader with Wails and should not be possible according to [PR](https://github.com/wailsapp/wails/pull/1771). Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2668)