Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions for Windows #442

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/weather-twenty-one-windows-packaged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build Windows Packaged Release

on:
push:
branches: [ main, actions ]

env:
DOTNETVERSION: 8.0.201
CONFIGURATION: Release # Values: Debug, Release
PLATFORM: x64
VERSIONNUMBER: 1.${{ github.run_number }}.${{ github.run_attempt }}

jobs:
buildWindowsPackaged:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Setup .NET SDK ${{env.DOTNETVERSION}}
uses: actions/setup-dotnet@v2
with:
dotnet-version: '${{env.DOTNETVERSION}}'

- name: List installed .NET info
shell: pwsh
run: dotnet --info

- name: Install MAUI Workload
run: dotnet workload install maui --ignore-failed-sources

- uses: managedcode/MAUIAppVersion@v1
with:
csproj: '8.0/Apps/WeatherTwentyOne/src/WeatherTwentyOne/WeatherTwentyOne.csproj'
version: 0 # Revision number must be 0 on Windows to be allowed on MS Store https://learn.microsoft.com/en-us/windows/apps/publish/publish-your-app/package-version-numbering?pivots=store-installer-msix#version-numbering-for-windows10-packages
displayVersion: '${{ env.VERSIONNUMBER }}'
printFile: true # optional

# https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/certutil
# commandline util to encode to base64 on windows
# openssl enc -base64 -a -in WinSignCert.pfx -out WinSignCert_base64.txt
- name: Create signing pfx file from secrets
shell: pwsh
id: secret-file
env:
SECRET_DATA1: ${{ secrets.WIN_SIGN_CERT }}
run: |
$secretFile = "WinSignCert.pfx";
$encodedBytes = [System.Convert]::FromBase64String($env:SECRET_DATA1);
Set-Content $secretFile -Value $encodedBytes -AsByteStream;
Write-Output "::set-output name=SECRET_FILE::$secretFile";
Write-Output " ";
Write-Output "CHECK FILE EXISTS";
Write-Output " ";
ls

- name: Add Cert to Store
run: |
certutil -user -q -p ${{ secrets.WIN_CERT_PASSWORD }} -importpfx WinSignCert.pfx NoRoot

# https://docs.microsoft.com/en-us/dotnet/maui/windows/deployment/overview
- name: Build Windows MSIX
run: |
cd .\8.0\Apps\WeatherTwentyOne\src\WeatherTwentyOne\
dotnet publish -f net8.0-windows10.0.19041.0 -c:${{ env.CONFIGURATION }} -p:PackageCertificateThumbprint=${{ secrets.WIN_CERT_THUMBPRINT }} -p:AppxPackageSigningEnabled=true -p:WindowsPackageType=MSIX --self-contained

- name: Upload Windows Artifact
uses: actions/upload-artifact@v4
with:
name: artifacts-windows
path: |
8.0\Apps\WeatherTwentyOne\src\WeatherTwentyOne\bin\${{ env.PLATFORM }}\${{ env.CONFIGURATION }}\net8.0-windows10.0.19041.0\win10-x64\AppPackages\**\*
50 changes: 50 additions & 0 deletions .github/workflows/weather-twenty-one-windows-unpackaged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build Windows Unpackaged Release

on:
push:
branches: [ main, actions ]

env:
DOTNETVERSION: 8.0.201
CONFIGURATION: Release # Values: Debug, Release
PLATFORM: x64
VERSIONNUMBER: 1.${{ github.run_number }}.${{ github.run_attempt }}

jobs:
buildWindowsPackaged:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Setup .NET SDK ${{env.DOTNETVERSION}}
uses: actions/setup-dotnet@v2
with:
dotnet-version: '${{env.DOTNETVERSION}}'

- name: List installed .NET info
shell: pwsh
run: dotnet --info

- name: Install MAUI Workload
run: dotnet workload install maui --ignore-failed-sources

- uses: managedcode/MAUIAppVersion@v1
with:
csproj: '8.0/Apps/WeatherTwentyOne/src/WeatherTwentyOne/WeatherTwentyOne.csproj'
version: 0 # Revision number must be 0 on Windows to be allowed on MS Store https://learn.microsoft.com/en-us/windows/apps/publish/publish-your-app/package-version-numbering?pivots=store-installer-msix#version-numbering-for-windows10-packages
displayVersion: '${{ env.VERSIONNUMBER }}'
printFile: true # optional

# https://docs.microsoft.com/en-us/dotnet/maui/windows/deployment/overview
- name: Build Windows EXE
run: |
cd .\8.0\Apps\WeatherTwentyOne\src\WeatherTwentyOne\
dotnet publish -f net8.0-windows10.0.19041.0 -c:${{ env.CONFIGURATION }} -p:AppxPackageSigningEnabled=false -p:WindowsPackageType=None --self-contained

- name: Upload Windows Artifact
uses: actions/upload-artifact@v4
with:
name: artifacts-windows
path: |
8.0\Apps\WeatherTwentyOne\src\WeatherTwentyOne\bin\${{ env.PLATFORM }}\${{ env.CONFIGURATION }}\net8.0-windows10.0.19041.0\win10-x64\publish\**\*
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="BA0275D4-73C9-4F0C-BF53-CAC4FAD28D12"
Publisher="CN=User Name"
Version="1.0.0.0" />
Version="0.0.0.0" />

<Properties>
<DisplayName>WeatherTwentyOne</DisplayName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-ios;net8.0-maccatalyst;net8.0-android</TargetFrameworks>
Expand All @@ -19,10 +19,13 @@
<ApplicationId>com.companyname.WeatherTwentyOne</ApplicationId>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<SingleProject>true</SingleProject>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<!-- (Optional) Pin to a specific version -->
<!--<MauiVersion>6.0.101-preview.11.2349</MauiVersion>-->
<MauiVersion>8.0.7</MauiVersion>

<!-- Required for C# Hot Reload -->
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>
Expand All @@ -35,13 +38,6 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>

</PropertyGroup>

<!-- To generate MSIX as part of dotnet publish -->
<PropertyGroup Condition="$(TargetFramework.Contains('-windows')) and '$(Configuration)' == 'Release'">
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
<!-- <AppxPackageSigningEnabled>true</AppxPackageSigningEnabled> -->
</PropertyGroup>

<!-- For iOS publish-->
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
Expand Down
Loading