Skip to content

Commit

Permalink
only check for latest gophy github version when not running in scratc…
Browse files Browse the repository at this point in the history
…h container, also added readme build command for Apple Silicon devices
  • Loading branch information
felix314159 committed Nov 21, 2024
1 parent 9e3a4c4 commit a510ba0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ then in order to statically build the gophy binary use one of the following comm
* Windows:

* ```CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build .```
* MacOS:
* MacOS (x64):

* ```CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build .```
* MacOS (Apple Silicon - ARM):

* ```CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build .```
* Linux-based OS:

* ```CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build .```
Expand Down
3 changes: 3 additions & 0 deletions githubversioncheck/githubversioncheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func extractVersionFromHtml(content string) (string, error) {
version = strings.TrimRight(version, ".")

// e.g. now version = "v0.9.12"
if version == "" {
return "", fmt.Errorf("Something went wrong. If you see the error 'tls: failed to verify certificate: x509: certificate signed by unknown authority' and you are NOT using a Dokcer scratch container, then you should try the following, assuming you are using linux: 'sudo apt update && sudo apt install --reinstall ca-certificates'")
}

return version, nil
}
Expand Down
25 changes: 14 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ const version = "v0.9.31"
func main() {
// /*

// First check whether the currently run version of gophy is the newest available release on github (you are allowed to use older versions, just used to inform the user)
isUsingNewestGophyVersion, latestVersion, err := githubversioncheck.IsUsingNewestGophyVersion(version)
if err != nil {
logger.L.Printf("Failed to determine latest release of gophy: %v", err)
}
if isUsingNewestGophyVersion {
logger.L.Printf("You are running the latest version of gophy: %v\n", version)
} else {
logger.L.Printf("New version of gophy is available: %v\nYou are still using version: %v\nPlease update it manually!\n", latestVersion, version)
}

// ---- Create database folder if it does not exist already ----
simsol.CreateFolder(filepath.Join(".", "database"))

Expand Down Expand Up @@ -90,6 +79,20 @@ func main() {

// ---- Handle flags ----

// Check whether the currently run version of gophy is the newest available release on github (you are allowed to use older versions, just used to inform the user)
// Only perform this check when you are NOT running this in a docker scratch container (that container does not have CA certficates so it would fail with 'tls: failed to verify certificate: x509: certificate signed by unknown authority')
if (*dockerAliasFlag != "1f") && (*dockerAliasFlag != "2f") && (*dockerAliasFlag != "3f") && (*dockerAliasFlag != "4l") && (*dockerAliasFlag != "5l") && (*dockerAliasFlag != "6l") && (*dockerAliasFlag != "ra") {
isUsingNewestGophyVersion, latestVersion, err := githubversioncheck.IsUsingNewestGophyVersion(version)
if err != nil {
logger.L.Printf("Failed to determine latest release of gophy: %v", err)
}
if isUsingNewestGophyVersion {
logger.L.Printf("You are running the latest version of gophy: %v\n", version)
} else {
logger.L.Printf("New version of gophy is available: %v\nYou are still using version: %v\nPlease update it manually!\n", latestVersion, version)
}
}

// only allow user ports to avoid port conflicts
database.HttpPort = *httpPortFlag
if (database.HttpPort < 1024) || (database.HttpPort > 49151) || (database.HttpPort == 12345) {
Expand Down

0 comments on commit a510ba0

Please sign in to comment.