Skip to content

Commit

Permalink
release 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
djohts committed May 6, 2024
1 parent 2855f49 commit 283ea04
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 2.2.0 (2024-05-06)

- Update checker
- More structural changes

**Full Changelog**: https://github.com/djohts/tpc-truckersmp/compare/v2.1.0...v2.2.0

## 2.1.0 (2024-05-06)

- Improved logging
Expand Down
6 changes: 6 additions & 0 deletions constants/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package constants

const (
APP_VERSION = `2.2.0`

ETS = `Euro Truck Simulator 2`
ATS = `American Truck Simulator`
)

var (
DocumentsPath string
)
5 changes: 0 additions & 5 deletions constants/variables.go

This file was deleted.

3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ require (
git.tcp.direct/kayos/sendkeys v0.0.0-20211216174833-565f782ccf21
github.com/bradhe/stopwatch v0.0.0-20190618212248-a58cccc508ea
github.com/charmbracelet/log v0.4.0
github.com/coreos/go-semver v0.3.1
github.com/creasty/defaults v1.7.0
github.com/fsnotify/fsnotify v1.7.0
github.com/google/go-github/v61 v61.0.0
golang.org/x/sys v0.20.0
gopkg.in/yaml.v3 v3.0.1
)
Expand All @@ -16,6 +18,7 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/lipgloss v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMt
github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE=
github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM=
github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA=
github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
Expand All @@ -36,6 +43,7 @@ golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQz
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ package main

import (
"errors"
"fmt"

"github.com/charmbracelet/log"
"github.com/djohts/tpc-truckersmp/config"
"github.com/djohts/tpc-truckersmp/constants"
"github.com/djohts/tpc-truckersmp/updater"
"github.com/djohts/tpc-truckersmp/utils"
"github.com/djohts/tpc-truckersmp/watcher"
)

func main() {
fmt.Println("tpc-truckersmp", "v"+constants.APP_VERSION, "by djohts")

if !utils.IsFile("SII_Decrypt.exe") {
utils.HandleError(errors.New("SII_Decrypt.exe does not exist"))
}
Expand All @@ -21,7 +25,15 @@ func main() {
log.Info(" 2. Make a quicksave & reload 1-2 seconds later")
log.Info("======================================================")

err := config.Init()
log.Info("Checking for updates...")
needsUpdate, latest, err := updater.CheckUpdates()
if err != nil {
log.Error("Failed to check for updates", "error", err)
} else if needsUpdate {
log.Info("New version available", "current", constants.APP_VERSION, "latest", latest[1:])
}

err = config.Init()
utils.HandleError(err)

DocumentsPath := &constants.DocumentsPath
Expand Down
26 changes: 26 additions & 0 deletions updater/updater.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package updater

import (
"context"

"github.com/coreos/go-semver/semver"
"github.com/djohts/tpc-truckersmp/constants"
"github.com/google/go-github/v61/github"
)

func CheckUpdates() (bool, string, error) {
client := github.NewClient(nil)
releases, _, err := client.Repositories.ListReleases(context.Background(), "djohts", "tpc-truckersmp", nil)
if err != nil {
return false, "", err
}

if len(releases) == 0 {
return false, "", nil
}

latestRelease := releases[0]
needsUpdate := semver.New(constants.APP_VERSION).LessThan(*semver.New((*latestRelease.TagName)[1:]))

return needsUpdate, *latestRelease.TagName, nil
}

0 comments on commit 283ea04

Please sign in to comment.