|
| 1 | +name: Publish Random Dad Jokes Extension |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "dadjokes/v*.*.*" |
| 7 | + |
| 8 | +env: |
| 9 | + project: CmdPalRandomDadJokeExtension |
| 10 | + packageName: MichaelJolley.RandomDadJokesForCmdPal |
| 11 | + tag_prefix: "dadjokes/v" |
| 12 | + |
| 13 | +jobs: |
| 14 | + build_sign_release: |
| 15 | + # This job builds the appx packages and signs them using the trusted signing service |
| 16 | + runs-on: windows-latest |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + env: |
| 20 | + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Setup .NET SDK |
| 25 | + uses: actions/setup-dotnet@v4 |
| 26 | + with: |
| 27 | + dotnet-version: 9.0.x |
| 28 | + |
| 29 | + - name: Update Version in manifest |
| 30 | + working-directory: "./src/${{ env.project }}" |
| 31 | + run: | |
| 32 | + $version = "${{github.ref_name}}.0" -replace '^${{ env.tag_prefix }}', '' |
| 33 | + |
| 34 | + $xmlFilePath = "Package.appxmanifest" |
| 35 | + [xml]$xml = Get-Content $xmlFilePath |
| 36 | + $xml.Package.Identity.Version = $version |
| 37 | + $xml.Save($xmlFilePath) |
| 38 | + Write-Output "Version updated to $version in $xmlFilePath" |
| 39 | + |
| 40 | + - name: Build |
| 41 | + run: | |
| 42 | + dotnet build --configuration Release -p:GenerateAppxPackageOnBuild=true -p:Platform=x64 |
| 43 | + dotnet build --configuration Release -p:GenerateAppxPackageOnBuild=true -p:Platform=arm64 |
| 44 | + |
| 45 | + - name: Move misx Packages |
| 46 | + run: | |
| 47 | + # Move the misx packages to one folder for signing |
| 48 | + $msixs = Get-ChildItem -Path $Env:GITHUB_WORKSPACE -Recurse -File -Filter "${{ env.project }}*.msix" -exclude "Microsoft.WindowsAppRuntime.*.msix" |
| 49 | +
|
| 50 | + # write the path of each msix (relative to the git root) |
| 51 | + Write-Host "Found the following msix's:" |
| 52 | + foreach($msix in $msixs) { |
| 53 | + Write-Host "*" $msix.Name "`n" |
| 54 | + } |
| 55 | +
|
| 56 | + $DestinationFolder = Join-Path $Env:GITHUB_WORKSPACE "tmp" |
| 57 | + |
| 58 | + if(Test-Path $DestinationFolder) { |
| 59 | + Remove-Item -Path $DestinationFolder -Recurse -Force | Out-Null |
| 60 | + } |
| 61 | + if(-not (Test-Path $DestinationFolder)) { |
| 62 | + New-Item -ItemType Directory -Path $DestinationFolder -Force | Out-Null |
| 63 | + } |
| 64 | +
|
| 65 | + Write-Host "Copying msix's to $DestinationFolder..." |
| 66 | +
|
| 67 | + foreach($msix in $msixs) { |
| 68 | + Copy-Item -Path $msix -Destination $DestinationFolder -Force |
| 69 | + } |
| 70 | + |
| 71 | + - name: Sign files with Trusted Signing |
| 72 | + uses: azure/trusted-signing-action@v0 |
| 73 | + with: |
| 74 | + azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 75 | + azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 76 | + azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} |
| 77 | + endpoint: https://eus.codesigning.azure.net/ |
| 78 | + trusted-signing-account-name: baldbeardedbuilder |
| 79 | + certificate-profile-name: baldbeardedbuilder |
| 80 | + files-folder: ${{ github.workspace }}\tmp # This is where the msix files are copied to for signing |
| 81 | + files-folder-filter: msix |
| 82 | + file-digest: SHA256 |
| 83 | + timestamp-rfc3161: http://timestamp.acs.microsoft.com |
| 84 | + timestamp-digest: SHA256 |
| 85 | + |
| 86 | + - uses: ncipollo/release-action@v1 |
| 87 | + name: Create Release |
| 88 | + with: |
| 89 | + artifacts: "${{ github.workspace }}/tmp/*.msix" # Path to the signed msix files to upload as artifacts for the release. Use glob pattern to match all files in the tmp folder. |
| 90 | + name: ${{ github.ref_name }} |
| 91 | + allowUpdates: true |
| 92 | + tag: ${{ github.ref_name }} |
| 93 | + |
| 94 | + # publish: |
| 95 | + # runs-on: windows-latest |
| 96 | + # needs: build_sign_release |
| 97 | + # permissions: |
| 98 | + # packages: write |
| 99 | + # contents: write |
| 100 | + # steps: |
| 101 | + # - name: Submit extensions to Winget |
| 102 | + # run: | |
| 103 | + # $wingetPackage = "MichaelJolley.CmdPalRandomDadJokeExtension" |
| 104 | + # $gitToken = $Env:GITHUB_TOKEN |
| 105 | + |
| 106 | + # $github = Invoke-RestMethod -uri "https://api.github.com/repos/michaeljolley/CmdPalExtensions/releases" |
| 107 | + # $targetRelease = $github | Where-Object -Property name -match 'Release'| Select -First 1 |
| 108 | + # _0.0.4.0_x64.msix |
| 109 | + # $installerX64Url = $targetRelease | Select -ExpandProperty assets -First 1 | Where-Object -Property name -match 'CmdPalRandomDadJokeExtension*x64' | Select -ExpandProperty browser_download_url |
| 110 | + # # $installerArmUrl = $targetRelease | Select -ExpandProperty assets -First 1 | Where-Object -Property name -match 'CmdPalRandomDadJokeExtension*arm64' | Select -ExpandProperty browser_download_url |
| 111 | + # $ver = $targetRelease.tag_name -ireplace '^v' |
| 112 | + |
| 113 | + # # getting latest wingetcreate file |
| 114 | + # iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe |
| 115 | + # .\wingetcreate.exe update $wingetPackage -s -v $ver -u "$installerX64Url|machine" -t $gitToken |
0 commit comments