Skip to content

Build and Release

Build and Release #24

name: Build and Release
on:
workflow_dispatch:
inputs:
version:
description: "Release tag(e.g., v1.2.3) without starting 'v'"
required: true
type: string
jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.7.2"
add-tools-to-path: true
cache: true
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: |
mkdir build
cd build
qmake ../
nmake
- name: Remove source and object files
shell: pwsh
run: |
$buildDir = "build/release"
if (Test-Path $buildDir) {
Get-ChildItem -Path $buildDir -Include *.cpp, *.h, *.obj, *.res, *.qrc, *.qm -Recurse | Remove-Item -Force
} else {
Write-Host "Directory not found: $buildDir"
}
- name: Deploy Qt
shell: pwsh
run: |
cd build
$windeployqtPath = "D:\a\HeadsetControl-GUI\Qt\6.7.2\msvc2019_64\bin\windeployqt6.exe"
if (Test-Path $windeployqtPath) {
& $windeployqtPath `
--exclude-plugins qsvgicon,qsvg,qico,qjpeg,qgif,qnetworklistmanager,qtuiotouchplugin `
--no-opengl-sw `
--no-system-dxc-compiler `
--no-compiler-runtime `
--no-translations `
--no-system-d3d-compiler `
D:\a\HeadsetControl-GUI\HeadsetControl-GUI\build\release\HeadsetControl-GUI.exe
} else {
Write-Error "windeploygui not found at the expected path!"
exit 1
}
- name: Download ZIP from other repo
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://github.com/Sapd/HeadsetControl/releases/latest/download/headsetcontrol-windows.zip" -OutFile headsetcontrol-windows.zip
Expand-Archive -Path headsetcontrol-windows.zip -DestinationPath build/release/
- name: Zip binaries folder
run: |
$zipFile = "HeadsetControl-GUI_windows_64.zip"
$folder = "build/release/*"
Compress-Archive -Path $folder -DestinationPath $zipFile
shell: pwsh
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: HeadsetControl-GUI_windows_64
path: HeadsetControl-GUI_windows_64.zip
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.7.2"
host: "linux"
add-tools-to-path: true
cache: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential libgl1-mesa-dev
- name: Build with qmake
run: |
mkdir build
cd build
qmake ../HeadsetControl-GUI.pro CONFIG+=release
make -j$(nproc)
- name: Zip binaries folder
run: |
zip -r HeadsetControl-GUI_linux_64.zip build/HeadsetControl-GUI
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: HeadsetControl-GUI_linux_64
path: HeadsetControl-GUI_linux_64.zip
create-release:
needs: [build-linux, build-windows]
runs-on: ubuntu-latest
steps:
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: HeadsetControl-GUI_linux_64
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: HeadsetControl-GUI_windows_64
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ inputs.version }}
release_name: Release v${{ inputs.version }}
body: |
## Contributor
@nicola02nb Mantainer
## Credits
@Sapd for [HeadsetControl](https://github.com/Sapd/HeadsetControl)
draft: false
prerelease: false
- name: Upload Linux Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./HeadsetControl-GUI_linux_64.zip
asset_name: HeadsetControl-GUI_linux_64.zip
asset_content_type: application/octet-stream
- name: Upload Windows Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./HeadsetControl-GUI_windows_64.zip
asset_name: HeadsetControl-GUI_windows_64.zip
asset_content_type: application/octet-stream
winget-release:
needs: [create-release]
runs-on: windows-latest
if: false
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download release asset
run: |
Invoke-WebRequest -Uri "https://github.com/LeoKlaus/HeadsetControl-GUI/releases/latest/download/HeadsetControl-GUI_windows_64.zip" -OutFile "HeadsetControl-GUI.zip"
- name: Calculate SHA256
id: sha256
run: |
$hash = (Get-FileHash -Algorithm SHA256 -Path .\HeadsetControl-GUI.zip).Hash
echo "::set-output name=hash::$hash"
- name: Create winget manifest
run: |
$manifest = @"
PackageIdentifier: LeoKlaus.HeadsetControl-GUI
PackageVersion: ${{ inputs.version }}
PackageLocale: en-US
Publisher: LeoKlaus
PublisherUrl: https://github.com/LeoKlaus
PackageName: HeadsetControl-GUI
PackageUrl: https://github.com/LeoKlaus/HeadsetControl-GUI
License: LGPL-2.1
LicenseUrl: https://github.com/LeoKlaus/HeadsetControl-GUI/blob/main/LICENSE
ShortDescription: A GUI for the great HeadsetControl
Installers:
- Architecture: x64
InstallerType: exe
Scope: user
InstallerUrl: https://github.com/LeoKlaus/HeadsetControl-GUI/releases/latest/download/HeadsetControl-GUI_windows_64.zip
InstallerSha256: ${{ steps.sha256.outputs.hash }}
InstallerSwitches:
Silent: /S
SilentWithProgress: /S
ManifestType: singleton
ManifestVersion: 1.0.0
"@
$manifest | Out-File -FilePath .\LeoKlaus.HeadsetControl-GUI.yaml -Encoding utf8
- name: Install Winget-Create
run: |
Invoke-WebRequest -Uri https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
.\wingetcreate.exe --version
continue-on-error: true
- name: Validate manifest
run: |
winget validate .\LeoKlaus.HeadsetControl-GUI.yaml
continue-on-error: true
- name: Submit manifest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
.\wingetcreate.exe submit .\LeoKlaus.HeadsetControl-GUI.yaml --token $env:GITHUB_TOKEN