Skip to content

update publish action #17

update publish action

update publish action #17

Workflow file for this run

name: Release generation
on:
push:
tags:
- "v*.*.*"
jobs:
build:
runs-on: windows-latest
env:
Configuration: Release
Appx_Bundle: Always
Appx_Package_Build_Mode: StoreUpload
Solution_Name: ${{github.workspace}}\src\Gpt.Labs.sln
Project_Name: Gpt_Labs
x64_Packages_Folder_Path: ${{github.workspace}}\packages\x64
x86_Packages_Folder_Path: ${{github.workspace}}\packages\x86
arm64_Packages_Folder_Path: ${{github.workspace}}\packages\arm64
Source_Folder_Path: ${{github.workspace}}\packages\source
Boundle_Folder_Path: ${{github.workspace}}\packages\bundle
Project_Folder_Path: ${{github.workspace}}\src\Gpt.Labs
Pfx_Name: GptLabs_SideloadingKey.pfx
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.2
- name: Get application version
id: versionStep
run: |
$xml = [XML](Get-Content $env:Project_Folder_Path\Package.appxmanifest)
$version = $xml.Package.Identity.Version
echo "Version=$version" >> $env:GITHUB_OUTPUT
- name: Restore the application
run: |
msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
- name: Decode the pfx
id: decodePfxStep
run: |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
$certificatePath = Join-Path -Path $env:Project_Folder_Path -ChildPath $env:Pfx_Name
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
$secure_string_pwd = ConvertTo-SecureString "${{ secrets.Pfx_Key }}" -AsPlainText -Force
$thumbprint = (Import-PfxCertificate -FilePath "$certificatePath" -CertStoreLocation Cert:\CurrentUser\My -Password $secure_string_pwd).Thumbprint
echo "Thumbprint=$thumbprint" >> $env:GITHUB_OUTPUT
- name: Replace App Center Secret
id: replaceAppCenterSecret
run: |
(Get-Content $env:Project_Folder_Path\App.xaml.cs) | Foreach-Object {$_ -replace "{APP_CENTER_SECRET}", "${{ secrets.App_Center_Secret }}"} | Set-Content $env:Project_Folder_Path\App.xaml.cs
- name: Create the x64 app package
run: |
msbuild `
$env:Solution_Name `
/t:$env:Project_Name `
/p:Configuration=$env:Configuration `
/p:Platform=$env:Platform `
/p:AppxBundlePlatforms=$env:Platform `
/p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode `
/p:AppxBundle=$env:Appx_Bundle `
/p:AppxPackageSigningEnabled=true `
/p:PackageCertificateKeyFile=$env:Project_Folder_Path\$env:Pfx_Name `
/p:PackageCertificatePassword=${{ secrets.Pfx_Key }} `
/p:PackageCertificateThumbprint=${{steps.decodePfxStep.outputs.Thumbprint}} `
/p:GenerateAppxPackageOnBuild=true `
/p:AppxSymbolPackageEnabled=true `
/p:AppxPackageDir=$env:x64_Packages_Folder_Path\
env:
Platform: x64
- name: Create the x86 app package
run: |
msbuild `
$env:Solution_Name `
/t:$env:Project_Name `
/p:Configuration=$env:Configuration `
/p:Platform=$env:Platform `
/p:AppxBundlePlatforms=$env:Platform `
/p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode `
/p:AppxBundle=$env:Appx_Bundle `
/p:AppxPackageSigningEnabled=true `
/p:PackageCertificateKeyFile=$env:Project_Folder_Path\$env:Pfx_Name `
/p:PackageCertificatePassword=${{ secrets.Pfx_Key }} `
/p:PackageCertificateThumbprint=${{steps.decodePfxStep.outputs.Thumbprint}} `
/p:GenerateAppxPackageOnBuild=true `
/p:AppxSymbolPackageEnabled=true `
/p:AppxPackageDir=$env:x86_Packages_Folder_Path\
env:
Platform: x86
- name: Create the arm64 app package
run: |
msbuild `
$env:Solution_Name `
/t:$env:Project_Name `
/p:Configuration=$env:Configuration `
/p:Platform=$env:Platform `
/p:AppxBundlePlatforms=$env:Platform `
/p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode `
/p:AppxBundle=$env:Appx_Bundle `
/p:AppxPackageSigningEnabled=true `
/p:PackageCertificateKeyFile=$env:Project_Folder_Path\$env:Pfx_Name `
/p:PackageCertificatePassword=${{ secrets.Pfx_Key }} `
/p:PackageCertificateThumbprint=${{steps.decodePfxStep.outputs.Thumbprint}} `
/p:GenerateAppxPackageOnBuild=true `
/p:AppxSymbolPackageEnabled=true `
/p:AppxPackageDir=$env:arm64_Packages_Folder_Path\
env:
Platform: arm64
- name: Generate the msixbundle folder with all the msix files
run: |
New-Item -Path $env:Boundle_Folder_Path -ItemType Directory -Force
$x64MsixFiles = Get-ChildItem -Path $env:x64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Filter *.msix
$x86MsixFiles = Get-ChildItem -Path $env:x86_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Filter *.msix
$arm64MsixFiles = Get-ChildItem -Path $env:arm64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Filter *.msix
$x64MsixFiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$x86MsixFiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$arm64MsixFiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
- name: MSIX Bundler
uses: LanceMcCarthy/Action-MsixBundler@v1.0.1
with:
msix-folder: ${{env.Boundle_Folder_Path}}
msixbundle-filepath: ${{env.Boundle_Folder_Path}}\Gpt.Labs_${{steps.versionStep.outputs.Version}}_x64_x86_arm64.msixbundle
msixbundle-version: ${{steps.versionStep.outputs.Version}}
sdk-version: 10.0.22621.0
architecture: x64
enable-bundle-signing: true
certificate-path: ${{env.Project_Folder_Path}}\${{env.Pfx_Name}}
certificate-private-key: ${{secrets.Pfx_Key}}
signing-hash-algorithm: SHA256
- name: Cleanup redundant and secret files
run: |
Remove-Item -path $env:Project_Folder_Path\$env:Pfx_Name
$msixFiles = Get-ChildItem -Path $env:Boundle_Folder_Path -Recurse -Exclude *.msixbundle
$msixFiles | ForEach-Object {
Remove-Item -Path $_
}
- name: Copy optional files
run: |
$optionalFiles = Get-ChildItem -Path $env:x64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Recurse -Include *.cer,*.ps1,*.msixsym
$optionalFiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$dependenciesDirectory = Get-ChildItem -Path $env:x64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Directory -Recurse -Include Dependencies
$dependenciesDirectory | ForEach-Object {
Copy-Item -Recurse -Path $_ -Destination $env:Boundle_Folder_Path
}
$resourceDirectory = Get-ChildItem -Path $env:x64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Directory -Recurse -Include Add-AppDevPackage.resources
$resourceDirectory | ForEach-Object {
Copy-Item -Recurse -Path $_ -Destination $env:Boundle_Folder_Path
}
$x86symfiles = Get-ChildItem -Path $env:x86_Packages_Folder_Path -Recurse -Include *.msixsym
$x86symfiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$arm64symfiles = Get-ChildItem -Path $env:arm64_Packages_Folder_Path -Recurse -Include *.msixsym
$arm64symfiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$oldCertName = (Get-Item -Path "$env:Boundle_Folder_Path\*.cer").Name
$newCertName = $oldCertName.Replace("x64","x64_x86_arm64")
Rename-Item -Path "$env:Boundle_Folder_Path\$oldCertName" -NewName $newCertName
- name: Compress MSIX Bundler
run: |
New-Item -Path $env:Source_Folder_Path -ItemType Directory -Force
Compress-Archive -Path "$env:Boundle_Folder_Path\*" -DestinationPath "GPT.Labs_MSIXBUNDLE_v${{steps.versionStep.outputs.Version}}_x64_x86_arm64.zip"
- name: Release publish
uses: softprops/action-gh-release@v0.1.15
with:
name: ${{steps.versionStep.outputs.Version}}
generate_release_notes: true
draft: false
prerelease: false
files: |
GPT.Labs_MSIXBUNDLE_v${{steps.versionStep.outputs.Version}}_x64_x86_arm64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}