Skip to content

windows build

windows build #589

Workflow file for this run

name: windows build
on:
workflow_call:
workflow_dispatch:
env:
BUILD_ARCHS: '32 64'
BUILD_TYPES: ${{ (github.ref_name == 'develop' || github.ref_name == 'main') && 'Release Debug' || 'Release' }}
BUILD_TESTING: ${{ (github.ref_name != 'main') && '-BuildTesting' || '' }}
SIGN: ${{ (github.ref_name == 'develop' || github.ref_name == 'main') && 'true' || 'false' }}
SIGNING_POLICY: 'release-signing'
jobs:
prepare-build-matrix:
runs-on: ubuntu-24.04
outputs:
archs: ${{ steps.matrix-vars.outputs.ARCHS }}
types: ${{ steps.matrix-vars.outputs.TYPES }}
build-args: ${{ steps.matrix-vars.outputs.BUILD_ARGS }}
steps:
- name: Calculate matrix variables
id: matrix-vars
run: |
echo ARCHS=[\"$BUILD_ARCHS\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT"
echo TYPES=[\"$BUILD_TYPES\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT"
BUILD_ARGS=$BUILD_TESTING
for BUILD_PARAM in $BUILD_ARCHS $BUILD_TYPES; do
BUILD_ARGS=$(echo $BUILD_ARGS -Build$BUILD_PARAM | xargs)
done
echo BUILD_ARGS=$BUILD_ARGS >> "$GITHUB_OUTPUT"
build-bin:
runs-on: windows-2022
needs: prepare-build-matrix
strategy:
matrix:
arch: ${{ fromJSON(needs.prepare-build-matrix.outputs.archs) }}
type: ${{ fromJSON(needs.prepare-build-matrix.outputs.types) }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Prepare build environment
run: |
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest https://github.com/nzbgetcom/build-files/releases/download/v5.0/vcpkg-windows-x${{ matrix.arch }}.zip -OutFile "${{ github.workspace }}\vcpkg.zip"
Rename-Item -path "C:\vcpkg" -NewName "C:\vcpkg.old"
Expand-Archive -Path "${{ github.workspace }}\vcpkg.zip" -DestinationPath C:\
Invoke-WebRequest https://github.com/nzbgetcom/build-files/releases/download/v10.0/nzbget-windows-tools.zip -OutFile "${{ github.workspace }}\tools.zip"
Expand-Archive -Path "${{ github.workspace }}\tools.zip" -DestinationPath C:\
- name: Build nzbget ${{ matrix.arch }}-bit / ${{ matrix.type }} binary
run: Invoke-Expression "windows\build-nzbget.ps1 -Build${{ matrix.type }} -Build${{ matrix.arch }} ${{ env.BUILD_TESTING }}"
- name: Upload build artifacts
uses: actions/upload-artifact@v7
id: upload-unsigned-artifact
with:
name: ${{ matrix.type }}${{ matrix.arch }}
path: |
build\${{ matrix.type }}${{ matrix.arch }}\${{ matrix.type }}\*.exe
build\${{ matrix.type }}${{ matrix.arch }}\*.nsi
retention-days: 5
- name: Submit signing request
id: submit-signing-request
if: env.SIGN == 'true' && matrix.type == 'Release'
uses: signpath/github-action-submit-signing-request@v2
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
organization-id: ${{ secrets.SIGNPATH_ORGANIZATION_ID }}
project-slug: nzbget
signing-policy-slug: ${{ env.SIGNING_POLICY }}
artifact-configuration-slug: nzbget-binary
github-artifact-id: ${{ steps.upload-unsigned-artifact.outputs.artifact-id }}
wait-for-completion: true
output-artifact-directory: build\${{ matrix.type }}${{ matrix.arch }}\signed
- name: Upload signed build artifacts
if: env.SIGN == 'true' && matrix.type == 'Release'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.type }}${{ matrix.arch }}
overwrite: true
path: build\${{ matrix.type }}${{ matrix.arch }}\signed
retention-days: 5
build-installer:
runs-on: windows-2022
needs: [build-bin, prepare-build-matrix]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download release build artifacts
uses: actions/download-artifact@v8
with:
pattern: Release*
- name: Download debug build artifacts
uses: actions/download-artifact@v8
with:
pattern: Debug*
- name: Prepare build environment
run: |
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest https://github.com/nzbgetcom/build-files/releases/download/v10.0/nzbget-windows-tools.zip -OutFile "${{ github.workspace }}\tools.zip"
Expand-Archive -Path "${{ github.workspace }}\tools.zip" -DestinationPath C:\
New-Item build -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
Copy-Item Release* build -Recurse -ErrorAction SilentlyContinue
Copy-Item Debug* build -Recurse -ErrorAction SilentlyContinue
- name: Build nzbget windows installer
run: Invoke-Expression "windows\build-nzbget.ps1 -BuildSetup ${{ needs.prepare-build-matrix.outputs.build-args }}"
- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
$Output="build"
$Suffix = $env:GITHUB_REF_NAME.Replace("/","-")
ForEach ($File In Get-ChildItem -Path $Output -Filter "*.exe") {
Rename-Item -Path "$Output\$($File.Name)" -NewName $File.Name.Replace("-bin-windows-", "-$Suffix-bin-windows-")
}
- name: Upload build artifacts
uses: actions/upload-artifact@v7
id: upload-unsigned-installer-artifact
with:
name: nzbget-windows-installers
path: build\*.exe
retention-days: 5
- name: Submit signing request for windows installers
id: submit-signing-request
if: env.SIGN == 'true'
uses: signpath/github-action-submit-signing-request@v2
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
organization-id: ${{ secrets.SIGNPATH_ORGANIZATION_ID }}
project-slug: nzbget
signing-policy-slug: ${{ env.SIGNING_POLICY }}
artifact-configuration-slug: nzbget-installer
github-artifact-id: ${{ steps.upload-unsigned-installer-artifact.outputs.artifact-id }}
wait-for-completion: true
output-artifact-directory: build\signed
- name: Upload signed build artifacts
if: env.SIGN == 'true'
uses: actions/upload-artifact@v7
with:
name: nzbget-windows-installers
overwrite: true
path: build\signed\*.exe
retention-days: 5
- name: Delete unneeded platform-specific artifacts
uses: geekyeggo/delete-artifact@v6
with:
name: |
Release*
Debug*