Update CI #273
Workflow file for this run
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 | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
workflow_call: | |
jobs: | |
build: | |
# Ignore draft PRs | |
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false) | |
runs-on: windows-latest | |
env: | |
Solution_Name: Natsurainko.FluentLauncher | |
Project_Directory: Natsurainko.FluentLauncher | |
Configuration: Release | |
Packages_DirectoryName: AppPackages | |
Packages_Directory: Natsurainko.FluentLauncher\AppPackages | |
SigningKey_Path: SigningKey.pfx | |
strategy: | |
matrix: | |
architecture: [x64, arm64] | |
name: Build (${{ matrix.architecture }}) | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 7.0.x | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v2 | |
# - name: Get NuGet Dependencies | |
# run: .\.github\write-nuget-cache-file.ps1 | |
# - name: Cache NuGet packages | |
# id: cache-nuget | |
# uses: actions/cache@v3 | |
# with: | |
# path: | | |
# ~\AppData\Local\NuGet\v3-cache | |
# ~\AppData\Roaming\NuGet\NuGet.Config | |
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
# restore-keys: | | |
# ${{ runner.os }}-nuget- | |
- name: Add NuGet Source for WCT Labs | |
# if: steps.cache.outputs.cache-hit != 'true' | |
run: dotnet nuget add source "https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json" | |
# Restore the application to populate the obj folder with RuntimeIdentifiers | |
- name: Restore NuGet packages | |
run: dotnet restore | |
# Prepare FluentLauncher.Localization | |
- name: Prepare FluentLauncher.Localization | |
run: .\update-localization.ps1 | |
# Create the app package by building and packaging the Windows Application Packaging project | |
- name: Create app package | |
env: | |
Appx_Bundle: Never | |
Platform: ${{ matrix.architecture }} | |
Appx_Bundle_Platforms: ${{ matrix.architecture }} | |
Appx_Package_Build_Mode: SideloadOnly | |
Appx_Package_Dir: ${{ env.Packages_DirectoryName }}\ # DO NOT REMOVE THE TRAILING SLASH | |
run: | | |
msbuild $env:Solution_Name /p:Platform=$env:Platform /p:AppxBundlePlatforms="$env:Appx_Bundle_Platforms" /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:AppxPackageDir="$env:Appx_Package_Dir" /p:GenerateAppxPackageOnBuild=true | |
- name: Prepare for bundling | |
id: preparation | |
run: | | |
# Get package name | |
$msixFile = Get-Item -Path "${{ env.Packages_Directory }}\*\*.msix" | |
$packageName = [System.IO.Path]::GetFileNameWithoutExtension($msixFile.FullName) | |
echo "::set-output name=packageName::$packageName" | |
# Get version number | |
$version = $packageName -replace '^(.*?Natsurainko\.FluentLauncher)_(\d+\.\d+\.\d+\.\d+)(_x64|_arm64)$', '$2' | |
echo "::set-output name=version::$version" | |
# Get package directory | |
$directory = $msixFile.DirectoryName | |
echo "::set-output name=packageDirectory::$directory" | |
# Rename .msixsym to .appxsym to pass Partner Center validation | |
# Move .appx to root directory for making .msixupload | |
mv "$directory\$packageName.msixsym" ".\$packageName.appxsym" | |
# Move .msix for upload to artifacts | |
mv ${{ env.Packages_Directory }}\*\*.msix "$packageName.msix" | |
# Decode the base64 encoded pfx and sign the package | |
- name: Sign .msix | |
run: | | |
# Get signtool.exe | |
$signtool = Get-Item -Path "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe" | |
if ($signtool -is [array]) { | |
$signtool = $signtool[0] | |
} | |
# Sign .msix | |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.PFX_BASE64_ENCODED }}") | |
[IO.File]::WriteAllBytes("${{ env.SigningKey_Path }}", $pfx_cert_byte) | |
& $signtool sign /f "${{ env.SigningKey_Path }}" /fd SHA256 /td SHA256 "${{ steps.preparation.outputs.packageName }}.msix" | |
rm "${{ env.SigningKey_Path }}" | |
- name: Upload .msix to artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: .msix | |
path: ${{ steps.preparation.outputs.packageName }}.msix | |
- name: Create .msixupload | |
id: create_msixupload | |
env: | |
PackageName: ${{ steps.preparation.outputs.packageName }} | |
PackageDirectory: ${{ steps.preparation.outputs.packageDirectory }} | |
Version: ${{ steps.preparation.outputs.version }} | |
TmpDirectory: .\tmp | |
run: | | |
# Get makeappx.exe | |
$makeappx = Get-Item -Path "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\makeappx.exe" | |
if ($makeappx -is [array]) { | |
$makeappx = $makeappx[0] | |
} | |
# Convert .msix to .msixbundle | |
mkdir "$env:TmpDirectory" | |
mv "$env:PackageName.msix" "$env:TmpDirectory\$env:PackageName.msix" | |
& $makeappx.FullName bundle /d "$env:TmpDirectory" /p "$env:PackageName.msixbundle" /bv $env:Version | |
# Create .msixupload | |
$msixbundlePath = $env:PackageName + '.msixbundle' | |
$appxsymPath = $env:PackageName + '.appxsym' | |
Compress-Archive -Path $msixbundlePath, $appxsymPath -DestinationPath "$env:PackageName.zip" | |
mv "$env:PackageName.zip" "$env:PackageName.msixupload" | |
- name: Upload .msixupload to artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: .msixupload | |
path: ${{ steps.preparation.outputs.packageName }}.msixupload |