-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
212f5c7
commit c88f02c
Showing
11 changed files
with
231 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package buildinfo | ||
|
||
import ( | ||
"fmt" | ||
"github.com/samber/lo" | ||
"runtime/debug" | ||
) | ||
|
||
type Info struct { | ||
Development bool | ||
Version string | ||
BuildSettings map[string]string | ||
wailsPackage *debug.Module | ||
} | ||
|
||
func Get() (*Info, error) { | ||
|
||
var result Info | ||
|
||
// BuildInfo contains the build info for the application | ||
var BuildInfo *debug.BuildInfo | ||
|
||
var ok bool | ||
BuildInfo, ok = debug.ReadBuildInfo() | ||
if !ok { | ||
return nil, fmt.Errorf("could not read build info from binary") | ||
} | ||
result.BuildSettings = lo.Associate(BuildInfo.Settings, func(setting debug.BuildSetting) (string, string) { | ||
return setting.Key, setting.Value | ||
}) | ||
result.Version = BuildInfo.Main.Version | ||
result.Development = BuildInfo.Main.Version == "(devel)" | ||
|
||
return &result, nil | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package buildinfo | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGet(t *testing.T) { | ||
result, err := Get() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
_ = result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"github.com/wailsapp/wails/v3/internal/buildinfo" | ||
) | ||
|
||
type BuildInfoOptions struct{} | ||
|
||
func BuildInfo(_ *BuildInfoOptions) error { | ||
|
||
info, err := buildinfo.Get() | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("%+v\n", info) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v3.0.0-alpha.4 | ||
v3.0.0-alpha.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"strconv" | ||
"strings" | ||
"time" | ||
|
||
"github.com/wailsapp/wails/v3/internal/s" | ||
) | ||
|
||
const versionFile = "../../internal/version/version.txt" | ||
|
||
func checkError(err error) { | ||
if err != nil { | ||
println(err.Error()) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
// TODO:This can be replaced with "https://github.com/coreos/go-semver/blob/main/semver/semver.go" | ||
func updateVersion() string { | ||
currentVersionData, err := os.ReadFile(versionFile) | ||
checkError(err) | ||
currentVersion := string(currentVersionData) | ||
vsplit := strings.Split(currentVersion, ".") | ||
minorVersion, err := strconv.Atoi(vsplit[len(vsplit)-1]) | ||
checkError(err) | ||
minorVersion++ | ||
vsplit[len(vsplit)-1] = strconv.Itoa(minorVersion) | ||
newVersion := strings.Join(vsplit, ".") | ||
err = os.WriteFile(versionFile, []byte(newVersion), 0o755) | ||
checkError(err) | ||
return newVersion | ||
} | ||
|
||
//func runCommand(name string, arg ...string) { | ||
// cmd := exec.Command(name, arg...) | ||
// cmd.Stdout = os.Stdout | ||
// cmd.Stderr = os.Stderr | ||
// err := cmd.Run() | ||
// 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, ".") | ||
// // 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 | ||
if len(os.Args) > 1 { | ||
newVersion = os.Args[1] | ||
//currentVersion, err := os.ReadFile(versionFile) | ||
//checkError(err) | ||
err := os.WriteFile(versionFile, []byte(newVersion), 0o755) | ||
checkError(err) | ||
//isPointRelease = IsPointRelease(string(currentVersion), newVersion) | ||
} else { | ||
newVersion = updateVersion() | ||
} | ||
|
||
// Update ChangeLog | ||
s.CD("../../../mkdocs-website") | ||
|
||
// Read in `src/pages/changelog.mdx` | ||
changelogData, err := os.ReadFile("docs/en/changelog.md") | ||
checkError(err) | ||
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("docs/en/changelog.md", []byte(newChangelog), 0o755) | ||
checkError(err) | ||
|
||
// TODO: Documentation Versioning and Translations | ||
|
||
//if !isPointRelease { | ||
// 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") | ||
// 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, 0o755) | ||
// 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") | ||
//} | ||
} |