-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (62 loc) · 2.74 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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/[email protected]
- 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/[email protected]
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.*proj') }}
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/[email protected]
with:
name: ${{env.MSI_FILE_NAME}}
path: ${{env.MSI_PROJECT_OUTPUT}}/${{env.MSI_FILE_NAME}}.msi