Merge pull request #200 from LanceMcCarthy/main #68
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
# If you are looking for guidance for your builds, see https://github.com/microsoft/github-actions-for-desktop-apps | |
name: Release (sideload) | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- release-sideload | |
paths: | |
- "src/**/*" | |
- ".github/workflows/cd_release_sideload.yml" | |
jobs: | |
build: | |
runs-on: windows-latest | |
env: | |
NugetConfigPath: src\nuget.config | |
Configuration: Release | |
SigningCertificate: LancelotSoftwareLLC.pfx | |
CommonProjectPath: src\MediaFileManager\MediaFileManager.Common\MediaFileManager.Common.csproj | |
WpfProjectPath: src\MediaFileManager\MediaFileManager.Desktop\MediaFileManager.Desktop.csproj | |
SolutionPath: src\MediaFileManager\MediaFileManager.sln | |
WapProjectDirectory: src\MediaFileManager\PackageProject | |
WappProjectPath: src\MediaFileManager\PackageProject\PackageProject.wapproj | |
AppxPackageDirectory: D:\a\MediaFileManager\MediaFileManager\src\MediaFileManager\PackageProject\SideLoadPackages\ | |
ArtifactsFilePath: D:\a\MediaFileManager\MediaFileManager\src\MediaFileManager\PackageProject\SideLoadPackages\SideLoadPackages.zip | |
AppInstUri: https://dvlup.blob.core.windows.net/general-app-files/Installers/MediaFileManager/ | |
TFM: net6.0-windows10.0.19041.0 | |
TargetPlatform: "x64" | |
AppxBundlePlatforms: "x86|x64|arm64" | |
AppxBundleMode: Always | |
AppxBuildMode: SideloadOnly | |
AppxPackageSigningEnabled: True | |
GenerateAppInstallerFile: True | |
HoursBetweenUpdateChecks: 12 | |
TELERIK_NUGET_KEY: ${{ secrets.TELERIK_NUGET_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# ******************| ASSEMBLY AND MANIFEST VERSIONING |********************* # | |
# Create my own version number with a specific format using date. ex: 2020.805.1.0 | |
- name: Generate version number with date and workflow Run Number | |
id: version-creator | |
run: | | |
$buildDay = Get-Date -Format "yyyy.Mdd" | |
$runNumber = "$env:GITHUB_RUN_NUMBER" | |
$ver = $buildDay + "." + $runNumber + ".0" | |
echo "APP_VERSION=$ver" | |
#echo "APP_VERSION=$ver" >> $GITHUB_OUTPUT | |
#echo "APP_VERSION=$ver" >> "$GITHUB_ENV" | |
echo "::set-output name=APP_VERSION::$ver" | |
# Update the appxmanifest for SideLoad (and signing with PFX) | |
- name: Update manifest version | |
run: | | |
[xml]$manifest = get-content "src\MediaFileManager\PackageProject\Package.appxmanifest" | |
$manifest.Package.Identity.Version = "${{ steps.version-creator.outputs.APP_VERSION }}" | |
$manifest.Package.Identity.Name = "61469LanceLotSoftware.MediaFileManager" | |
$manifest.Package.Identity.Publisher = 'CN="Lancelot Software, LLC", O="Lancelot Software, LLC", L=NORTH BILLERICA, S=Massachusetts, C=US' | |
$manifest.Package.Properties.DisplayName = "Media File Manager" | |
$manifest.Package.Properties.PublisherDisplayName = "Lancelot Software" | |
$manifest.Package.Applications.Application.VisualElements.DisplayName = "Media File Manager" | |
$manifest.save("src\MediaFileManager\PackageProject\Package.appxmanifest") | |
# Updates the WPF project's assembly version number. | |
- name: Update WPF Assembly version | |
run: | | |
function SetAssemblyFileVersion([string]$pathToFile, [string]$newVersion) { | |
$newFile = Get-Content $pathToFile -encoding "UTF8" | foreach-object { | |
if ($_.StartsWith("[assembly: AssemblyFileVersion")) { | |
$verStart = $_.IndexOf("(") | |
$verEnd = $_.IndexOf(")", $verStart) | |
$origVersion = $_.SubString($verStart+2, $verEnd-$verStart-3) | |
$newVersion = "${{ steps.version-creator.outputs.APP_VERSION }}" | |
write-host "Setting AssemblyFileVersion from $origVersion to $newVersion" | |
$_.Replace($origVersion, $newVersion) | |
} else { | |
$_ | |
} | |
} | |
$newfile | Set-Content $assemblyInfoPath -encoding "UTF8" | |
} | |
$assemblyInfoPath = "src\MediaFileManager\MediaFileManager.Desktop\Properties\AssemblyInfo.cs" | |
SetAssemblyFileVersion $assemblyInfoPath "${{ steps.version-creator.outputs.APP_VERSION }}" | |
# ******************| TOOL INSTALL and DEPENDENCY RESTORE |********************* # | |
# Install the .NET SDK workload | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0' | |
- name: Setup MSBuild.exe | |
uses: microsoft/[email protected] | |
# Use dotnet restore command for the solution (see RIDs https://docs.microsoft.com/en-us/dotnet/core/rid-catalog) | |
- name: DotNet Restore | |
run: dotnet restore ${{ env.WappProjectPath }} --configfile ${{ env.NugetConfigPath }} --runtime ${{ env.TFM }} | |
# ************************| BUILD AND DISTRIBUTION |************************ # | |
# Decode the Base64 encoded Pfx | |
- name: Decode the Pfx | |
run: | | |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.LancelotSoftwareCert_Base64 }}") | |
$currentDirectory = Get-Location | |
$certificatePath = Join-Path -Path $currentDirectory -ChildPath "src\MediaFileManager\PackageProject" -AdditionalChildPath "${{ env.SigningCertificate }}" | |
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) | |
# Build using SideLoad and AppInstaller instructions (requires code signing) | |
- name: Restore wapproj | |
run: msbuild ${{ env.WappProjectPath }} /t:Restore /p:Configuration=${{ env.Configuration }} | |
- name: Build wapproj for Sideloading | |
run: msbuild ${{ env.WappProjectPath }} /p:GenerateAppInstallerFile=${{ env.GenerateAppInstallerFile }} /p:AppInstallerUri=${{ env.AppInstUri }} /p:HoursBetweenUpdateChecks=${{ env.HoursBetweenUpdateChecks }} /p:AppxPackageDir=${{ env.AppxPackageDirectory }} /p:Configuration=${{ env.Configuration }} /p:UapAppxPackageBuildMode=${{ env.AppxBuildMode }} /p:AppxBundle=${{ env.AppxBundleMode }} /p:PackageCertificateKeyFile=${{ env.SigningCertificate }} /p:PackageCertificatePassword=${{ env.CertPrivateKey }} /p:PackageCertificateThumbprint=${{ env.CertThumbprint }} /p:AppxPackageSigningEnabled=${{ env.AppxPackageSigningEnabled }} /p:Platform=${{ env.TargetPlatform }} /p:AppxBundlePlatforms="${{ env.AppxBundlePlatforms }}" | |
env: | |
CertPrivateKey: ${{ secrets.LancelotSoftwareCert_Key }} | |
CertThumbprint: ${{ secrets.LancelotSoftwareCert_Thumbprint }} | |
# UPLOAD TO AZURE STORAGE BLOB | |
# This automatically distributes the sideLoad package, which users can visit the index.html page and run the appinstaller | |
- name: Uploading appInstaller to Azure Blob | |
id: sideload-blob-upload | |
uses: LanceMcCarthy/Action-AzureBlobUpload@v3 | |
with: | |
connection_string: "${{ secrets.AZURE_DVLUP_BLOB_CONNECTION_STRING }}" | |
container_name: general-app-files | |
source_folder: ${{ env.AppxPackageDirectory }} | |
destination_folder: Installers/MediaFileManager | |
clean_destination_folder: true | |
is_recursive: true | |
# ZIP up the sideload packages for GitHub release using Powershell | |
- name: Create SideLoadPackages.zip | |
run: Compress-Archive -Path ${{ env.AppxPackageDirectory }} -DestinationPath ${{ env.ArtifactsFilePath }} | |
# Remove the .pfx now that we're done with code signing | |
- name: Remove the .pfx | |
run: Remove-Item -path "${{ env.WapProjectDirectory }}\${{ env.SigningCertificate }}" | |
# ************************| GITHUB RELEASE |************************ # | |
# Create a new GitHub Release tagged with the build version number (via https://github.com/actions/create-release) | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v.${{ steps.version-creator.outputs.APP_VERSION }}" | |
release_name: "Media File Manager (Release Preview) v.${{ steps.version-creator.outputs.APP_VERSION }}" | |
draft: false | |
prerelease: true | |
body_path: .github\other\preview_releasebody.md | |
# Add SideLoad artifacts to GitHub Release (via https://github.com/actions/upload-release-asset) | |
- name: Uploading SideLoad Release asset | |
id: upload-sideload-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.ArtifactsFilePath }} | |
asset_name: SideLoadPackages.zip | |
asset_content_type: application/zip |