[#6] Workflows: Add workflow to build and deploy the installer

This commit is contained in:
2023-11-19 20:37:01 +01:00
parent 6d53e35399
commit 7c23f9bdae
7 changed files with 83 additions and 23 deletions

View File

@ -0,0 +1,55 @@
name: Deploy
on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
jobs:
deploy:
name: Build and Deploy
runs-on: windows-latest
permissions:
contents: write
steps:
- name: Set APP_VERSION variable from tag
shell: powershell
run: |
$APP_VERSION = $env:GITHUB_REF -replace '^refs/tags/v', ''
Add-Content -Path $env:GITHUB_ENV -Value "APP_VERSION=$APP_VERSION"
- name: Checkout repository
uses: actions/checkout@v4
- name: Check version in project
shell: powershell
run: |
Select-String Elwig/Elwig.csproj -Pattern "<Version>"
$res = Select-String Elwig/Elwig.csproj -Pattern "<Version>${{ env.APP_VERSION }}</Version>"
if ($res -eq $null) {
exit 1
}
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1
- name: Setup NuGet
uses: nuget/setup-nuget@v1
- name: Restore NuGet packages
shell: powershell
run: $(& nuget restore Elwig.sln; $a=$lastexitcode) | findstr x*; exit $a
- name: Build Setup
shell: powershell
run: $(& msbuild -verbosity:quiet Setup/Setup.wixproj -property:Configuration=Release -property:Platform=x64; $a=$lastexitcode) | findstr x*; exit $a
- name: Rename artifact
shell: powershell
run: Move-Item Setup/bin/x64/Release/Elwig.exe Setup/bin/x64/Release/Elwig-${{ env.APP_VERSION }}.exe
- name: Create release
uses: akkuman/gitea-release-action@v1
with:
name: Elwig ${{ env.APP_VERSION }}
files: |-
Setup/bin/x64/Release/Elwig-${{ env.APP_VERSION }}.exe
- name: Upload to website
shell: powershell
run: |
$content = [System.IO.File]::ReadAllBytes("Setup/bin/x64/Release/Elwig-${{ env.APP_VERSION }}.exe")
Invoke-WebRequest `
-Uri "https://www.necronda.net/elwig/files/Elwig-${{ env.APP_VERSION }}.exe" `
-Method PUT `
-Body $content `
-Headers @{ Authorization = "${{ secrets.API_AUTHORIZATION }}" } `
-ContentType "application/octet-stream"

2
.gitignore vendored
View File

@ -4,3 +4,5 @@ bin/
.vs
.idea
Tests/Resources/Sql/Create.sql
*.exe
!WinziPrint.exe

View File

@ -25,8 +25,8 @@
</Task>
</UsingTask>
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
<Exec Command="curl -s -L &quot;http://www.columbia.edu/~em36/PDFtoPrinter.exe&quot; -z &quot;$(TargetDir)PDFtoPrinter.exe&quot; -o &quot;$(TargetDir)PDFtoPrinter.exe&quot;" />
<Exec Command="dotnet publish &quot;$(SolutionDir)Elwig\Elwig.csproj&quot; &quot;/p:PublishProfile=$(SolutionDir)\Elwig\Properties\PublishProfiles\FolderProfile.pubxml&quot;" />
<Exec Command="curl -s -L &quot;http://www.columbia.edu/~em36/PDFtoPrinter.exe&quot; -z &quot;$(ProjectDir)\Files\PDFtoPrinter.exe&quot; -o &quot;$(ProjectDir)\Files\PDFtoPrinter.exe&quot;" />
<Exec Command="dotnet publish &quot;$(ProjectDir)\..\Elwig\Elwig.csproj&quot; &quot;/p:PublishProfile=$(ProjectDir)\..\Elwig\Properties\PublishProfiles\FolderProfile.pubxml&quot;" />
<GetFileVersion AssemblyPath="..\Elwig\bin\Publish\Elwig.exe">
<Output TaskParameter="Version" PropertyName="ElwigFileVersion" />
</GetFileVersion>

View File

@ -11,7 +11,7 @@
<File Source="$(ProjectDir)\Files\WinziPrint.exe" Id="WinziPrint.exe"/>
</Component>
<Component Directory="InstallFolder">
<File Source="$(TargetDir)\PDFtoPrinter.exe" Id="PDFtoPrinter.exe"/>
<File Source="$(ProjectDir)\Files\PDFtoPrinter.exe" Id="PDFtoPrinter.exe"/>
</Component>
</ComponentGroup>
</Fragment>

View File

@ -1,25 +1,28 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Bundle Name="Elwig" Manufacturer="Elwig" Version="!(bind.packageVersion.ElwigMsi)" UpgradeCode="f3c8fcab-c37c-43aa-9ab8-e42f4bb518b7" IconSourceFile="$(var.ElwigProjectDir)\Resources\Images\Elwig.ico" >
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" LogoFile="$(var.ElwigProjectDir)\Resources\Images\Elwig.png" SuppressOptionsUI="yes" ShowVersion="yes" />
</BootstrapperApplication>
<Bundle Name="Elwig" Manufacturer="Elwig" Version="!(bind.packageVersion.ElwigMsi)" UpgradeCode="f3c8fcab-c37c-43aa-9ab8-e42f4bb518b7"
IconSourceFile="$(var.ElwigProjectDir)\Resources\Images\Elwig.ico">
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" LogoFile="$(var.ElwigProjectDir)\Resources\Images\Elwig.png"
SuppressOptionsUI="yes" ShowVersion="yes"/>
</BootstrapperApplication>
<util:RegistrySearch Id="VCredistx86" Variable="VCredistx86" Result="exists" Root="HKLM" Key="SOFTWARE\Classes\Installer\Dependencies\VC,redist.x86,x86,14.36,bundle" />
<util:RegistrySearch Id="Webview2Machine" Variable="Webview2Machine" Result="exists" Root="HKLM" Key="SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" />
<util:RegistrySearch Id="Webview2User" Variable="Webview2User" Result="exists" Root="HKCU" Key="Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" />
<util:RegistrySearch Id="VCredistx86" Variable="VCredistx86" Result="exists"
Root="HKLM" Key="SOFTWARE\Classes\Installer\Dependencies\VC,redist.x86,x86,14.36,bundle"/>
<util:RegistrySearch Id="Webview2Machine" Variable="Webview2Machine" Result="exists"
Root="HKLM" Key="SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"/>
<util:RegistrySearch Id="Webview2User" Variable="Webview2User" Result="exists"
Root="HKCU" Key="Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"/>
<Chain>
<ExePackage Id="VCredistx86Installer" DisplayName="VC Redist x86 installer" Name="VC_redist.x86.exe" Cache="remove" Compressed="yes" PerMachine="yes"
Permanent="yes" Vital="yes" SourceFile="$(TargetDir)VC_redist.x86.exe" InstallArguments="/install /passive /norestart" DetectCondition="VCredistx86">
</ExePackage>
<ExePackage Id="MicrosoftEdgeWebview2" DisplayName="Microsoft Edge Webview2 Runtime" Name="MicrosoftEdgeWebview2Setup.exe" Cache="remove"
Compressed="yes" PerMachine="yes" Permanent ="yes" Vital ="no" SourceFile="$(TargetDir)MicrosoftEdgeWebview2Setup.exe" InstallArguments="/silent /install"
UninstallArguments="/silent /uninstall" DetectCondition="Webview2Machine OR Webview2User" >
</ExePackage>
<ExePackage Id="VCredistx86Installer" DisplayName="VC Redist x86 installer" Name="VC_redist.x86.exe"
SourceFile="$(ProjectDir)\Files\VC_redist.x86.exe"
Cache="remove" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
InstallArguments="/install /passive /norestart" DetectCondition="VCredistx86"/>
<ExePackage Id="MicrosoftEdgeWebview2" DisplayName="Microsoft Edge Webview2 Runtime" Name="MicrosoftEdgeWebview2Setup.exe"
SourceFile="$(ProjectDir)\Files\MicrosoftEdgeWebview2Setup.exe"
Cache="remove" Compressed="yes" PerMachine="yes" Permanent ="yes" Vital="no"
InstallArguments="/silent /install" UninstallArguments="/silent /uninstall" DetectCondition="Webview2Machine OR Webview2User"/>
<MsiPackage Id="ElwigMsi" SourceFile="$(var.Installer.TargetDir)\Elwig.msi" Permanent="no" Compressed="yes" Vital="yes"/>
</Chain>
</Bundle>
</Wix>

0
Setup/Files/.gitkeep Normal file
View File

View File

@ -5,8 +5,8 @@
<Cultures>de-AT</Cultures>
</PropertyGroup>
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
<Exec Command='curl -s -L "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -z "$(TargetDir)MicrosoftEdgeWebview2Setup.exe" -o "$(TargetDir)MicrosoftEdgeWebview2Setup.exe"' />
<Exec Command='curl -s -L "https://aka.ms/vs/17/release/vc_redist.x86.exe" -z "$(TargetDir)VC_redist.x86.exe" -o "$(TargetDir)VC_redist.x86.exe"' />
<Exec Command='curl -s -L "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -z "$(ProjectDir)\Files\MicrosoftEdgeWebview2Setup.exe" -o "$(ProjectDir)\Files\MicrosoftEdgeWebview2Setup.exe"' />
<Exec Command='curl -s -L "https://aka.ms/vs/17/release/vc_redist.x86.exe" -z "$(ProjectDir)\Files\VC_redist.x86.exe" -o "$(ProjectDir)\Files\VC_redist.x86.exe"' />
<PropertyGroup>
<DefineConstants>ElwigProjectDir=..\Elwig</DefineConstants>
</PropertyGroup>