mirror of
https://github.com/Xevion/HATray.git
synced 2025-12-06 01:15:11 -06:00
feat: include version information in builds
This commit is contained in:
19
.github/workflows/build.yml
vendored
19
.github/workflows/build.yml
vendored
@@ -21,10 +21,14 @@ jobs:
|
||||
- name: Build Linux Binary
|
||||
run: task build
|
||||
|
||||
- name: Get Version
|
||||
id: get_version
|
||||
run: echo "VERSION=$(cat VERSION.txt)" >> $GITHUB_ENV
|
||||
|
||||
- name: Upload Linux Binary
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: HATray-linux-amd64
|
||||
name: HATray-linux-amd64-${{ env.VERSION }}
|
||||
path: bin/HATray
|
||||
|
||||
build-windows:
|
||||
@@ -59,14 +63,21 @@ jobs:
|
||||
- name: Build MSI
|
||||
run: task package
|
||||
|
||||
- name: Get Version
|
||||
id: get_version_win
|
||||
shell: pwsh
|
||||
run: |
|
||||
$version = Get-Content VERSION.txt
|
||||
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
|
||||
- name: Upload Windows Binary
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: HATray-windows-amd64.exe
|
||||
name: HATray-windows-amd64-${{ env.VERSION }}.exe
|
||||
path: bin/HATray.exe
|
||||
|
||||
- name: Upload MSI
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: HATray-windows-amd64.msi
|
||||
path: bin/HATray-*.msi
|
||||
name: HATray-windows-amd64-${{ env.VERSION }}.msi
|
||||
path: bin/HATray.msi
|
||||
1
VERSION.txt
Normal file
1
VERSION.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.0.1
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
"ha-tray/internal/service"
|
||||
)
|
||||
|
||||
var Version = "dev"
|
||||
|
||||
func main() {
|
||||
logger, logFile, err := setupLogging()
|
||||
if err != nil {
|
||||
@@ -19,6 +21,8 @@ func main() {
|
||||
defer logFile.Sync()
|
||||
defer logFile.Close()
|
||||
|
||||
logger.Info("HATray started", "version", Version)
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
logger.Error("uncaught panic recovered", "panic", r)
|
||||
|
||||
@@ -6,27 +6,27 @@ vars:
|
||||
tasks:
|
||||
build:
|
||||
cmds:
|
||||
- go build -o ./bin/{{.BINARY_NAME}} ./cmd/main.go
|
||||
- go build -ldflags "-X main.Version=$(Get-Content VERSION.txt)" -o ./bin/{{.BINARY_NAME}} ./cmd/main.go
|
||||
|
||||
service:
|
||||
desc: "Install the service"
|
||||
deps: [build]
|
||||
cmds:
|
||||
# Create the service, if not already present
|
||||
- cmd: pwsh -c 'sc create HATray binPath= "$env:USERPROFILE\AppData\Local\HATray\{{.BINARY_NAME}}" start=auto'
|
||||
- cmd: pwsh -c 'sc create HATray binPath= "$env:USERPROFILE\\AppData\\Local\\HATray\\{{.BINARY_NAME}}" start=auto'
|
||||
ignore_error: true
|
||||
# Stop the service, if running
|
||||
- cmd: pwsh -c 'sc stop HATray'
|
||||
ignore_error: true
|
||||
# Replace the binary
|
||||
- cmd: pwsh -c 'Copy-Item -Force -Path .\bin\{{.BINARY_NAME}} -Destination $env:USERPROFILE\AppData\Local\HATray\{{.BINARY_NAME}}'
|
||||
- cmd: pwsh -c 'Copy-Item -Force -Path .\\bin\\{{.BINARY_NAME}} -Destination $env:USERPROFILE\\AppData\\Local\\HATray\\{{.BINARY_NAME}}'
|
||||
# Start the service
|
||||
- cmd: pwsh -c 'sc start HATray'
|
||||
|
||||
tail:
|
||||
desc: "Tail the log file"
|
||||
cmds:
|
||||
- cmd: pwsh -c 'Get-Content -Path $env:USERPROFILE\AppData\Local\HATray\current.log -Tail 100 -Wait'
|
||||
- cmd: pwsh -c 'Get-Content -Path $env:USERPROFILE\\AppData\\Local\\HATray\\current.log -Tail 100 -Wait'
|
||||
|
||||
package:
|
||||
desc: "Package the application as a MSI"
|
||||
@@ -34,4 +34,4 @@ tasks:
|
||||
cmds:
|
||||
- wix extension add WixToolset.Util.wixext
|
||||
- wix extension add WixToolset.UI.wixext
|
||||
- wix build -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -o ./bin/{{.APP_NAME}}-{{.VERSION}}.msi build/msi/HATray.wxs -arch x64 -d VERSION={{.VERSION}} -d SOURCE=./bin/{{.BINARY_NAME}}
|
||||
- wix build -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -o ./bin/{{.APP_NAME}}.msi build/msi/HATray.wxs -arch x64 -d VERSION=$(Get-Content VERSION.txt) -d SOURCE=./bin/{{.BINARY_NAME}}
|
||||
Reference in New Issue
Block a user