Build and Publish WinUI3 App #16
This file contains hidden or 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 and Upload | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version number (e.g., 1.0.0.1)' | |
| required: true | |
| type: string | |
| prerelease: | |
| description: 'If pre_release' | |
| required: true | |
| type: boolean | |
| env: | |
| DOTNET_VERSION: '8.0.x' | |
| jobs: | |
| build-and-upload: | |
| name: Build and Upload to Store | |
| runs-on: windows-2022 | |
| env: | |
| Solution_Name: RailGo.sln | |
| SigningKey_Path: SigningKey.pfx | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install .NET Core | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: ${{env.DOTNET_VERSION}} | |
| - name: Setup MSBuild.exe | |
| uses: microsoft/setup-msbuild@v1 | |
| - name: Restore the application | |
| run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration | |
| env: | |
| Configuration: Release | |
| - name: Update Manifest Version | |
| shell: pwsh | |
| run: | | |
| $AppxManifestPath = "RailGo/Package.appxmanifest" | |
| $newVersion = "${{ github.event.inputs.version }}" | |
| Write-Output "Setting new version: $newVersion" | |
| [xml]$xmlMSIX = Get-Content $AppxManifestPath | |
| $identityNode = $xmlMSIX.Package.Identity | |
| $identityNode.Version = $newVersion | |
| $xmlMSIX.Save($AppxManifestPath) | |
| - name: Create the MSIX Package | |
| run: msbuild $env:Solution_Name /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 /p:AppxPackageSigningEnabled=false | |
| env: | |
| Appx_Bundle: Always | |
| Appx_Bundle_Platforms: x86|x64|ARM64 | |
| Appx_Package_Build_Mode: SideloadOnly | |
| Appx_Package_Dir: AppxPackages\ | |
| Configuration: Release | |
| - name: Sign .msix | |
| shell: pwsh | |
| 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] | |
| } | |
| # Get File | |
| $msixFile = Get-Item -Path "RailGo/AppxPackages/*/*.msix" | |
| # Sign .msix | |
| $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.SIGNING_CERT }}") | |
| [IO.File]::WriteAllBytes("${{ env.SigningKey_Path }}", $pfx_cert_byte) | |
| & $signtool sign /f "${{ env.SigningKey_Path }}" /fd SHA256 /td SHA256 "$msixFile" | |
| Remove-Item "${{ env.SigningKey_Path }}" | |
| - name: Upload to Microsoft Store | |
| uses: isaacrlevin/windows-store-action@1.0 | |
| with: | |
| tenant-id: ${{ secrets.PARTNER_CENTER_TENANT_ID }} | |
| client-id: ${{ secrets.PARTNER_CENTER_CLIENT_ID }} | |
| client-secret: ${{ secrets.PARTNER_CENTER_CLIENT_SECRET }} | |
| app-id: ${{ secrets.PARTNER_CENTER_APP_ID }} | |
| package-path: "RailGo/AppxPackages/" | |
| delete-pending: true | |
| delete-packages: true | |
| skip-polling: true | |
| packages-keep: 9 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2.2.1 | |
| with: | |
| files: | | |
| ./RailGo/AppxPackages/*/*.msix | |
| body_path: ./CHANGELOG.md | |
| name: "RailGo Release v${{ github.event.inputs.version }}" | |
| tag_name: "v${{ github.event.inputs.version }}" | |
| prerelease: ${{ github.event.inputs.prerelease }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |