🏗️ Build #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 📦 Cache NuGet packages | |
uses: actions/cache@v2 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- 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}} --p:FileVersion=${{env.VERSION}} --p:AssemblyVersion=${{env.VERSION}} --p:Version=${{env.VERSION}} -r=win-x64 --self-contained=true | |
- name: 🔧 Setup WiX v5 | |
run: dotnet tool install --global wix | |
- name: 🏭 Build MSI | |
run: dotnet build ${{env.MSI_PROJECT_PATH}} -c=Release -o=${{env.MSI_PROJECT_OUTPUT}} -p:Version=${{env.VERSION}} -p:AppDir=${{env.APP_PROJECT_OUTPUT}} -p:OutputName=${{env.MSI_FILE_NAME}} | |
- 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 |