Skip to content

🏗️ Build

🏗️ Build #14

Workflow file for this run

name: Build & Deploy
on:
workflow_dispatch:
inputs:
Version:
description: "Version number"
required: false
default: "1.0.0"
SelfContained:
description: "Self-contained build"
required: false
type: boolean
default: false
permissions:
actions: write
contents: read
security-events: write
env:
VERSION: ${{ github.event.inputs.Version }}
SELF_CONTAINED: ${{ github.event.inputs.SelfContained }}
jobs:
build:
runs-on: windows-2022
env:
APP_PROJECT_PATH: src\Magdys.ScreenPrivacyWatermark.App\Magdys.ScreenPrivacyWatermark.App.csproj
APP_PROJECT_OUTPUT: _temp\app
MSI_PROJECT_PATH: src/Magdys.ScreenPrivacyWatermark.Setup/Magdys.ScreenPrivacyWatermark.Setup.wixproj
MSI_PROJECT_OUTPUT: _temp\msi
MSI_FILE_NAME: SPW-${{github.event.inputs.Version}}-Setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup envs
run: |
echo "APP_PROJECT_OUTPUT=${{ runner.temp }}\app" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "MSI_PROJECT_OUTPUT=${{ runner.temp }}\msi" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: List All env
run: Get-ChildItem env:* | Sort-Object -Property Name
- name: Setup .NET 8
if: false
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore NuGet Packages
run: dotnet restore src
- name: Build App
if: ${{ github.event.inputs.SelfContained == 'false' }}
run: dotnet publish ${{env.APP_PROJECT_PATH}} -c=Release -o=${{env.APP_PROJECT_OUTPUT}} --p:FileVersion=${{env.VERSION}} --p:AssemblyVersion=${{env.VERSION}} --p:Version=${{env.VERSION}}
- name: Build App (Self-contained)
if: ${{ github.event.inputs.SelfContained == 'true' }}
run: dotnet publish ${{env.APP_PROJECT_PATH}} -c=Release -o=${{env.APP_PROJECT_OUTPUT}}/app --p:FileVersion=${{env.VERSION}} --p:AssemblyVersion=${{env.VERSION}} --p:Version=${{env.VERSION}} -r=win-x64 --self-contained=true
- name: Setup Wix v4
run: dotnet tool install --global wix
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Build MSI
run: msbuild ${{env.MSI_PROJECT_PATH}} -Restore /p:Configuration=Release /p:OutputPath=${{env.MSI_PROJECT_PATH}} /p:OutputName=${{env.MSI_FILE_NAME}} /p:AppFolder=${{env.APP_PROJECT_OUTPUT}}
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.MSI_FILE_NAME}}
path: ${{env.MSI_PROJECT_OUTPUT}}/${{env.MSI_FILE_NAME}}.msi