mirror of
https://github.com/Xevion/HATray.git
synced 2025-12-06 03:15:16 -06:00
124 lines
3.4 KiB
YAML
124 lines
3.4 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches: master
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-linux:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
strategy:
|
|
fail-fast: false
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.24"
|
|
|
|
- name: Install Task
|
|
uses: arduino/setup-task@v2
|
|
with:
|
|
version: "3.x"
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build Linux Binary
|
|
run: task build
|
|
|
|
- name: Get Version
|
|
id: get_version
|
|
run: |
|
|
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo 'unknown')
|
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "BINARY_NAME=HATray-linux-amd64-$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Rename Linux Binary with Version
|
|
run: mv bin/HATray ${{ steps.get_version.outputs.BINARY_NAME }}
|
|
|
|
- name: Upload Linux Binary
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ steps.get_version.outputs.BINARY_NAME }}
|
|
path: ${{ steps.get_version.outputs.BINARY_NAME }}
|
|
if-no-files-found: error
|
|
|
|
build-windows:
|
|
runs-on: windows-latest
|
|
timeout-minutes: 10
|
|
strategy:
|
|
fail-fast: false
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.24"
|
|
|
|
- name: Install Task
|
|
uses: arduino/setup-task@v2
|
|
with:
|
|
version: "3.x"
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build Windows Binary
|
|
run: task build
|
|
|
|
- name: Get Version
|
|
id: get_version_win
|
|
shell: pwsh
|
|
run: |
|
|
# Extract the version using git tags, fallback to 'unknown' if it fails
|
|
try {
|
|
$version = git describe --tags --abbrev=0 2>$null
|
|
if ([string]::IsNullOrWhiteSpace($version)) { $version = 'unknown' }
|
|
} catch {
|
|
$version = 'unknown'
|
|
}
|
|
|
|
echo "VERSION=$($version.Trim())" >> $env:GITHUB_OUTPUT
|
|
echo "BINARY_NAME=HATray-windows-amd64-$($version.Trim())" >> $env:GITHUB_OUTPUT
|
|
|
|
- name: Rename Windows Binary with Version
|
|
shell: pwsh
|
|
run: Rename-Item -Path bin/HATray.exe -NewName "${{ steps.get_version_win.outputs.BINARY_NAME }}.exe"
|
|
|
|
- name: Upload Windows Binary
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ steps.get_version_win.outputs.BINARY_NAME }}.exe
|
|
path: bin/${{ steps.get_version_win.outputs.BINARY_NAME }}.exe
|
|
if-no-files-found: error
|
|
|
|
- name: Set up .NET for WiX
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: "8.0.x"
|
|
|
|
- name: Install WiX Toolset
|
|
run: dotnet tool install --global wix
|
|
|
|
- name: Add WiX Extensions
|
|
run: |
|
|
wix extension add WixToolset.Util.wixext
|
|
wix extension add WixToolset.UI.wixext
|
|
|
|
- name: Build MSI
|
|
run: task package
|
|
|
|
- name: Rename MSI with Version
|
|
shell: pwsh
|
|
run: Rename-Item -Path bin/HATray.msi -NewName "${{ steps.get_version_win.outputs.BINARY_NAME }}.msi"
|
|
|
|
- name: Upload MSI
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ steps.get_version_win.outputs.BINARY_NAME }}.msi
|
|
path: bin/${{ steps.get_version_win.outputs.BINARY_NAME }}.msi
|
|
if-no-files-found: error
|