Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ jobs:
build:
name: Build
needs: test-go
outputs:
version: ${{ steps.create_release.outputs.tag }}
strategy:
matrix:
os: [windows]
arch: [amd64]
runs-on: ubuntu-latest
steps:
- name: Create release tag
id: create_release
run: |
TAG="$(date +'%Y.%m.%d%H%M%S')"
echo "Creating release tag $TAG"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -61,7 +69,7 @@ jobs:
run: brew install mitchellh/gon/gon

- name: Build App
run: wails build --platform ${{ matrix.os}}/${{ matrix.arch }} -webview2 embed -o marshaller-${{ matrix.os }}-${{ matrix.arch }}
run: wails build --platform ${{ matrix.os}}/${{ matrix.arch }} -webview2 embed -o marshaller-${{ matrix.os }}-${{ matrix.arch }} -ldflags "-X github.com/kacpermalachowski/marshal-controller/internal/build.Version='${{ steps.create_release.outputs.tag }}'"

- name: Add macOS permissions
if: runner.os == 'macOS'
Expand All @@ -81,7 +89,7 @@ jobs:
with:
name: marshaller-${{ matrix.os }}-${{ matrix.arch }}
path: ./build/bin/marshaller-*
retention-days: 1
retention-days: 7

create_release:
if: github.event_name == 'push'
Expand All @@ -95,17 +103,14 @@ jobs:
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release tag
id: create_release
run: |
TAG="v$(date +'%d%m%Y')-$(echo ${{ github.sha }} | cut -c1-8)"
echo "Creating release tag $TAG"
echo "::set-output name=tag::$TAG"

- run: mv ./artifacts/**/marshaller-* ./

- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: ./marshaller-*
generateReleaseNotes: true
tag: ${{ steps.create_release.outputs.tag }}
tag: v${{ needs.build.outputs.version }}
name: ${{ needs.build.outputs.version }}

23 changes: 22 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import (
"crypto/sha256"
"fmt"
"os"
goruntime "runtime"

"github.com/kacpermalachowski/marshal-controller/internal/build"
"github.com/kacpermalachowski/marshal-controller/pkg/station"
"github.com/kacpermalachowski/marshal-controller/pkg/td2"

selfupdate "github.com/creativeprojects/go-selfupdate"
"github.com/wailsapp/wails/v2/pkg/runtime"
)

Expand All @@ -25,7 +28,7 @@ func NewApp() *App {

func (a *App) startup(ctx context.Context) {
a.ctx = ctx
runtime.LogInfo(ctx, fmt.Sprintf("Version: %s", "test"))
runtime.LogInfo(ctx, fmt.Sprintf("Version %s, Time %s", build.Version, build.Time))
}

func (a *App) domReady(ctx context.Context) {
Expand Down Expand Up @@ -122,6 +125,24 @@ func (a *App) GetStationHash() string {
return fmt.Sprintf("%x", a.stationHash)
}

func (a *App) CheckForUpdate(currentVersion string) (bool, error) {
latest, found, err := selfupdate.DetectLatest(a.ctx, selfupdate.ParseSlug("KacperMalachowski/marshal-controller"))
if err != nil {
return false, fmt.Errorf("error occurred while detecting version: %w", err)
}
if !found {
return false, fmt.Errorf("latest version for %s/%s could not be found from github repository", goruntime.GOOS, goruntime.GOARCH)
}

runtime.LogDebugf(a.ctx, "Current version %s is less or equal of found %s: %v", latest.Name, currentVersion, latest.LessOrEqual(currentVersion))
if latest.LessOrEqual(currentVersion) {
runtime.LogInfof(a.ctx, "Current version (%s) is the latest", currentVersion)
return false, nil
}

return true, nil
}

func calculateSHA256(data []byte) []byte {
h := sha256.New()
h.Write(data)
Expand Down
2 changes: 2 additions & 0 deletions frontend/wailsjs/go/main/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// This file is automatically generated. DO NOT EDIT
import {station} from '../models';

export function CheckForUpdate(arg1:string):Promise<boolean>;

export function Connect(arg1:string):Promise<void>;

export function Disconnect():Promise<void>;
Expand Down
4 changes: 4 additions & 0 deletions frontend/wailsjs/go/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

export function CheckForUpdate(arg1) {
return window['go']['main']['App']['CheckForUpdate'](arg1);
}

export function Connect(arg1) {
return window['go']['main']['App']['Connect'](arg1);
}
Expand Down
26 changes: 23 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,30 @@ go 1.21
toolchain go1.21.3

require (
github.com/creativeprojects/go-selfupdate v1.1.4
github.com/wailsapp/wails/v2 v2.8.0
gopkg.in/yaml.v3 v3.0.1
)

require (
code.gitea.io/sdk/gitea v0.17.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/davidmz/go-pageant v1.0.2 // indirect
github.com/go-fed/httpsig v1.1.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-github/v30 v30.1.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/xanzy/go-gitlab v0.100.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)

require (
github.com/bep/debounce v1.2.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
Expand All @@ -33,10 +53,10 @@ require (
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/wailsapp/go-webview2 v1.0.10 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
)

Expand Down
Loading