webui/.github/workflows/windows.yml
2025-01-30 15:52:24 -05:00

134 lines
4.2 KiB
YAML

# https://webui.me
# https://github.com/webui-dev/webui
# Copyright (c) 2020-2025 Hassan Draga.
# Licensed under MIT License.
# All rights reserved.
# Canada.
#
# Special Thanks to Turiiya (https://github.com/ttytm)
name: Windows
on:
workflow_call:
jobs:
setup:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Bundle WebUI Bridge
run: bridge/build.ps1
- uses: actions/cache@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
build:
needs: setup
runs-on: windows-latest
permissions:
contents: write
strategy:
matrix:
cc: ['gcc', 'msvc']
include:
- cc: gcc
make: mingw32-make
- cc: msvc
make: nmake
fail-fast: false
env:
ARTIFACT: webui-windows-${{ matrix.cc }}-x64
WEBUI_TLS_INCLUDE: "C:\\Program Files\\OpenSSL\\include"
WEBUI_TLS_LIB: "C:\\Program Files\\OpenSSL\\lib"
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
path: bridge/webui_bridge.h
key: ${{ runner.os }}-${{ github.sha }}-bridge
fail-on-cache-miss: true
- uses: microsoft/setup-msbuild@v2
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.cc == 'msvc'
- name: Build Debug Target
run: ${{ matrix.make }} debug
- name: Build Release Target
if: ${{ !cancelled() }}
run: ${{ matrix.make }}
- name: Build TLS Debug Target
run: ${{ matrix.make }} WEBUI_USE_TLS=1 debug
- name: Build TLS Release Target
run: ${{ matrix.make }} WEBUI_USE_TLS=1
- name: Build examples
run: |
$examples_base_dir = "$(Get-Location)/examples/C/"
foreach ($example in Get-ChildItem -Path $examples_base_dir -Directory) {
Write-Host "> $example"
Set-Location -Path $example.FullName
if (!$?) {
$exit_code = 1
continue
}
$make_output = Invoke-Expression ${{ matrix.make }}
if (!$?) {
Write-Host "Failed to build '$example': $make_output"
$exit_code = 1
continue
}
Write-Output $make_output
if (!(Test-Path "main.exe") -or !(Test-Path "main-dyn.exe")) {
Write-Host "Failed to find executable for '$example'"
Get-ChildItem
$exit_code = 1
continue
}
}
exit $exit_code
- name: Prepare Artifact
shell: bash
run: |
cp -r include dist
mv dist/ "$ARTIFACT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT }}
path: ${{ env.ARTIFACT }}
- name: Prepare Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
shell: bash
run: |
7z a -tzip "$ARTIFACT.zip" "$ARTIFACT/*"
if [ $GITHUB_REF_TYPE == tag ]; then
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV
else
{
echo "IS_PRERELEASE=true";
echo "TAG=nightly";
echo "TITLE=WebUI Nightly Build $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "BODY=Generated from commit $GITHUB_SHA."
} >> $GITHUB_ENV
fi
- name: Update Nightly Tag
if: env.IS_PRERELEASE
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
- name: Release
if: >
github.repository_owner == 'webui-dev'
&& (github.ref_type == 'tag' || (github.ref_name == 'main' && github.event_name == 'push'))
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.ARTIFACT }}.zip
tag: ${{ env.TAG }}
body: ${{ env.BODY }}
name: ${{ env.TITLE }}
prerelease: ${{ env.IS_PRERELEASE }}
allowUpdates: true