154 lines
No EOL
5.2 KiB
YAML
154 lines
No EOL
5.2 KiB
YAML
name: LANCommander Server Build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
inputs:
|
|
version_semver:
|
|
description: "Semantic Version"
|
|
required: true
|
|
type: string
|
|
version_tag:
|
|
description: 'Version Tag'
|
|
required: true
|
|
type: string
|
|
build_dotnet_version:
|
|
description: 'Build .NET Version'
|
|
required: true
|
|
type: string
|
|
build_runtime:
|
|
description: 'Build Runtime'
|
|
required: false
|
|
type: string
|
|
default: 'win-x64'
|
|
build_arch:
|
|
description: 'Build Architecture'
|
|
required: false
|
|
type: string
|
|
default: 'x64'
|
|
build_platform:
|
|
description: 'Build Platform'
|
|
required: false
|
|
type: string
|
|
default: 'Windows'
|
|
build_configuration:
|
|
description: 'Build Configuration (Debug/Release)'
|
|
required: false
|
|
type: string
|
|
default: 'Release'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/package
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: windows-latest
|
|
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
steps:
|
|
- uses: frabert/replace-string-action@v2
|
|
name: Swap Path Backslashes
|
|
id: swap_path_backslashes
|
|
with:
|
|
string: '${{ github.workspace }}'
|
|
pattern: '\\'
|
|
replace-with: '/'
|
|
flags: g
|
|
|
|
# Checkout code
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: true
|
|
|
|
# .NET Setup and Caching
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: ${{ inputs.build_dotnet_version }}
|
|
|
|
- name: NuGet Cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ env.NUGET_PACKAGES }}
|
|
key: ${{ runner.os }}-dotnet-${{ hashFiles('**/*.csproj') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-dotnet-
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore --locked-mode
|
|
|
|
# Node.js Setup and Caching
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3.8.1
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Restore UI build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ github.workspace }}/LANCommander.UI/wwwroot
|
|
key: ${{ runner.os }}-ui-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-ui-
|
|
|
|
- name: Restore Server npm packages
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ github.workspace }}/LANCommander.Server/node_modules
|
|
key: ${{ runner.os }}-server-npm-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-server-npm-
|
|
|
|
# .NET builds
|
|
- name: Publish Updater and Server
|
|
run: |
|
|
dotnet publish "./LANCommander.AutoUpdater/LANCommander.AutoUpdater.csproj" -c ${{ inputs.build_configuration }} --self-contained --runtime ${{ inputs.build_runtime }} -p:Version="${{ inputs.version_tag }}" -p:AssemblyVersion="${{ inputs.version_semver }}"
|
|
dotnet publish "./LANCommander.Server/LANCommander.Server.csproj" -c ${{ inputs.build_configuration }} --self-contained --runtime ${{ inputs.build_runtime }} -p:Version="${{ inputs.version_tag }}" -p:AssemblyVersion="${{ inputs.version_semver }}"
|
|
|
|
- name: Bundle and Clean
|
|
run: |
|
|
Copy-Item -Force -Recurse -Verbose LANCommander.AutoUpdater/bin/${{ inputs.build_configuration }}/net9.0/${{ inputs.build_runtime }}/publish/* LANCommander.Server/bin/${{ inputs.build_configuration }}/net9.0/${{ inputs.build_runtime }}/publish/
|
|
|
|
# Remove unnecessary files in a single operation
|
|
$PathsToRemove = @(
|
|
'wwwroot/_content/BootstrapBlazor.PdfReader/compat',
|
|
'wwwroot/_content/BootstrapBlazor.PdfReader/2.*',
|
|
'wwwroot/_content/BootstrapBlazor.PdfReader/build/pdf.sandbox.js',
|
|
'wwwroot/_content/BootstrapBlazor.PdfReader/build/*.map',
|
|
'wwwroot/_content/BootstrapBlazor.PdfReader/web/*.map',
|
|
'wwwroot/_content/AntDesign/less',
|
|
'wwwroot/_content/BlazorMonaco/lib/monaco-editor/min-maps',
|
|
'wwwroot/Identity/lib/bootstrap',
|
|
'LANCommander.ico',
|
|
'LANCommanderDark.ico',
|
|
'package-lock.json',
|
|
'package.json',
|
|
'*.pdb',
|
|
'hostfxr.dll.bak',
|
|
'Libraries/locales'
|
|
)
|
|
|
|
$BasePath = "LANCommander.Server/bin/${{ inputs.build_configuration }}/net9.0/${{ inputs.build_runtime }}/publish"
|
|
foreach ($path in $PathsToRemove) {
|
|
Remove-Item -Recurse -Force -ErrorAction Continue "$BasePath/$path"
|
|
}
|
|
|
|
- name: Compress Build Output
|
|
run: |
|
|
$compress = @{
|
|
Path = "LANCommander.Server/bin/${{ inputs.build_configuration }}/net9.0/${{ inputs.build_runtime }}/publish/*"
|
|
DestinationPath = "LANCommander.Server-${{ inputs.build_platform }}-${{ inputs.build_arch }}-v${{ inputs.version_tag }}.zip"
|
|
CompressionLevel = "Fastest"
|
|
}
|
|
Compress-Archive @compress
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
path: LANCommander.Server-${{ inputs.build_platform }}-${{ inputs.build_arch }}-v${{ inputs.version_tag }}.zip
|
|
name: LANCommander.Server-${{ inputs.build_platform }}-${{ inputs.build_arch }}-v${{ inputs.version_tag }}.zip |