Merge pull request #198 from LanceMcCarthy/release-sideload #16
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 (Microsoft Store) | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- release-microsoft-store | |
paths: | |
- "src/**/*" | |
- ".github/workflows/cd_release_msstore.yml" | |
jobs: | |
build: | |
runs-on: windows-latest | |
env: | |
NugetConfigPath: src\nuget.config | |
WappProjectPath: src\MediaFileManager\PackageProject\PackageProject.wapproj | |
CommonProjectPath: src\MediaFileManager\MediaFileManager.Common\MediaFileManager.Common.csproj | |
WpfProjectPath: src\MediaFileManager\MediaFileManager.Desktop\MediaFileManager.Desktop.csproj | |
SolutionPath: src\MediaFileManager\MediaFileManager.sln | |
Configuration: Release | |
AppxBundlePlatforms: "x86|x64|arm64" | |
TFM: net6.0-windows10.0.19041.0 | |
AppxBundleMode: Always | |
AppxBuildMode: StoreUpload | |
AppxPackageSigningEnabled: False | |
GenerateAppInstallerFile: False | |
HoursBetweenUpdateChecks: 6 | |
AppxPackageDirectory: D:\a\MediaFileManager\MediaFileManager\src\MediaFileManager\PackageProject\StoreUploadPackages\ | |
ArtifactsFilePath: D:\a\MediaFileManager\MediaFileManager\src\MediaFileManager\PackageProject\StoreUploadPackages\ReleasePackages.zip | |
AppInstUri: https://dvlup.blob.core.windows.net/general-app-files/Installers/MediaFileManager/ | |
TELERIK_NUGET_KEY: ${{ secrets.TELERIK_NUGET_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
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 Microsoft Store | |
- 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 = "${{ env.PackageIdentity_Name }}" | |
$manifest.Package.Identity.Publisher = "${{ env.PackageIdentity_Publisher }}" | |
$manifest.Package.Properties.DisplayName = "${{ env.PackageProperties_DisplayName }}" | |
$manifest.Package.Properties.PublisherDisplayName = "${{ env.PackageProperties_PublisherDisplayName }}" | |
$manifest.Package.Applications.Application.VisualElements.DisplayName = "${{ env.ApplicationVisualElements_DisplayName }}" | |
$manifest.save("src\MediaFileManager\PackageProject\Package.appxmanifest") | |
env: | |
PackageIdentity_Name: "61469LanceLotSoftware.MediaFileManager" | |
PackageIdentity_Publisher: "CN=51B5A8B2-5D86-4826-BBE2-C92E963A4C02" | |
PackageProperties_DisplayName: "Media File Manager" | |
PackageProperties_PublisherDisplayName: "Lancelot Software" | |
ApplicationVisualElements_DisplayName: "Media File Manager" | |
# 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 |************************ # | |
# Build using StoreUpload instructions, no code signing required (Microsoft signs it during certification) | |
- name: Build wapproj for Microsoft Store | |
run: msbuild "${{ env.WappProjectPath }}" /t:Restore /p:AppxPackageDir="${{ env.AppxPackageDirectory }}" /p:AppxBundlePlatforms="${{ env.AppxBundlePlatforms }}" /p:Configuration=${{ env.Configuration }} /p:UapAppxPackageBuildMode=${{ env.AppxBuildMode }} /p:AppxBundle=${{ env.AppxBundleMode }} /p:AppxPackageSigningEnabled=${{ env.AppxPackageSigningEnabled }} /p:GenerateAppInstallerFile=${{ env.GenerateAppInstallerFile }} | |
env: | |
CertPrivateKey: ${{ secrets.LancelotSoftwareCert_Key }} | |
CertThumbprint: ${{ secrets.LancelotSoftwareCert_Thumbprint }} | |
# ************************| GitHub Release |************************ # | |
# ZIP up the sideload packages for GitHub release using Powershell | |
- name: Create ReleasePackages.zip | |
run: Compress-Archive -Path ${{ env.AppxPackageDirectory }} -DestinationPath ${{ env.ArtifactsFilePath }} | |
- 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 v.${{ steps.version-creator.outputs.APP_VERSION }}" | |
draft: false | |
prerelease: false | |
body_path: .github\other\releasebody.md | |
- name: Uploading Release asset | |
id: upload-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: ReleasePackages.zip | |
asset_content_type: application/zip | |
# ************************| Microsoft Store Release |************************ # | |
- name: Submit to Partner Center (aka DevCenter) | |
shell: pwsh | |
run: | | |
$bundlePlatformsSafe = "${{ env.AppxBundlePlatforms }}".Replace("|", "_") | |
$uploadBundlePath = "${{ env.AppxPackageDirectory }}PackageProject_${{ steps.version-creator.outputs.APP_VERSION }}_" + $bundlePlatformsSafe + "_bundle.msixupload" | |
./.scripts/SubmitToMsftStore.ps1 $uploadBundlePath | |
env: | |
PartnerCenterClientId: ${{ secrets.PARTNER_CENTER_CLIENT_ID }} | |
PartnerCenterClientSecret: ${{ secrets.PARTNER_CENTER_CLIENT_SECRET }} | |
PartnerCenterStoreId: ${{ secrets.PARTNER_CENTER_STORE_ID }} | |
PartnerCenterTenantId: ${{ secrets.PARTNER_CENTER_TENANT_ID }} |