Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacrlevin committed Dec 20, 2023
1 parent 2827482 commit 0ecd161
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 270 deletions.
249 changes: 46 additions & 203 deletions .github/workflows/Sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,219 +2,66 @@ name: Build and Sign

on:
workflow_dispatch:
inputs:
matrix:
description: 'Matrix of Channel Names to Sign'
required: true
default: '{}'
type: string

jobs:
Build_WPF:
name: Build WPF
runs-on: windows-latest
strategy:
workflow_call:
inputs:
matrix:
ChannelName:
- Nightly
description: 'Matrix of Channel Names to Sign'
required: true
default: '{}'
type: string
jobs:

Code_Signing:
permissions:
id-token: write # Required for requesting the JWT
environment:
name: Code_Signing
# url: ${{ steps.deploy_staging.outputs.webapp-url }}
name: Code Sign Web
runs-on: windows-latest

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
BuildConfiguration: Release
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
GitHubReleaseUrl: https://github.com/isaacrlevin/presencelight/releases/download/Desktop-
Win10RID: net8.0-windows10.0.19041
# strategy:
# matrix:
# include:
# - ChannelName: Windows_x64_x86
# - ChannelName: Windows_ARM
# - ChannelName: macOS
# - ChannelName: Linux_ARM
# - ChannelName: Linux_ARM64
# - ChannelName: Linux_Musl_x64
# - ChannelName: Linux_Musl_ARM_x64

strategy:
matrix: ${{ fromJson(inputs.Matrix) }}
steps:

- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: setup-msbuild
uses: microsoft/setup-msbuild@v1

- name: Use .NET Core SDK 8.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
include-prerelease: true

- name: Nerdbank.GitVersioning
uses: dotnet/nbgv@v0.3.1
with:
setCommonVars: true

- run: echo "BuildNumber - ${{ env.GitBuildVersionSimple }}"

- name: Create Directory for Channel
run: mkdir ${{ github.workspace }}\${{ matrix.ChannelName }}
shell: powershell

- name: Add Version File to Artifact
run : |
New-Item -Path ${{ github.workspace }}\.chocolatey -Name "version.txt" -ItemType "file" -Value "${{ env.GitBuildVersionSimple }}"
New-Item -Path ${{ github.workspace }}\Build -Name "version.txt" -ItemType "file" -Value "${{ env.GitBuildVersionSimple }}"
New-Item -Path ${{ github.workspace }}\${{ matrix.ChannelName }} -Name "version.txt" -ItemType "file" -Value "${{ env.GitBuildVersionSimple }}"
shell: powershell

- name: Update AppxManifest version
run: |
# Update appxmanifest. This must be done before build.
[xml]$manifest= get-content ".\src\DesktopClient\PresenceLight.Package\Package.appxmanifest"
$manifest.Package.Identity.Version = "${{ env.GitBuildVersionSimple }}.0"
$manifest.save(".\src\DesktopClient\PresenceLight.Package\Package.appxmanifest")
shell: powershell
if: ${{ success() && matrix.ChannelName == 'Release' }}

- name: Update Nightly AppxManifest version
run: |
# Update appxmanifest. This must be done before build.
[xml]$manifest = Get-Content ".\src\DesktopClient\PresenceLight.Package\Package-Nightly.appxmanifest"
$manifest.Package.Identity.Version = "${{ env.GitBuildVersionSimple }}.0"
$manifest.Save(".\src\DesktopClient\PresenceLight.Package\Package-Nightly.appxmanifest")
shell: powershell
if: ${{ success() && matrix.ChannelName == 'Nightly' }}

- name: Update appsettings.json for Standalone Version
run: |
# Update AppSettings.json. This must be done before build.
$appsettings= get-content ".\src\DesktopClient\PresenceLight\appsettings.json" -raw | ConvertFrom-Json
$appsettings.isAppPackaged = "false"
$appsettings | ConvertTo-Json -depth 32| set-content '.\src\DesktopClient\PresenceLight\appsettings.json'
shell: powershell
if: ${{ success() && matrix.ChannelName == 'Standalone' }}

- name: Update appsettings.json for AppPackage Version
run: |
# Update AppSettings.json. This must be done before build.
$appsettings= get-content ".\src\DesktopClient\PresenceLight\appsettings.json" -raw | ConvertFrom-Json
$appsettings.isAppPackaged = "true"
$appsettings | ConvertTo-Json -depth 32| set-content '.\src\DesktopClient\PresenceLight\appsettings.json'
shell: powershell
if: ${{ success() && matrix.ChannelName != 'Standalone' }}

- name: Add Secrets to appsettings.json
run: |
# Update AppSettings.json. This must be done before build.
$appsettings= get-content ".\src\DesktopClient\PresenceLight\appsettings.json" -raw | ConvertFrom-Json
$appsettings.aadSettings.clientId = "${{ secrets.ApplicationId }}"
$appsettings.appVersion = "${{ env.GitBuildVersionSimple }}"
$appsettings.lightSettings.lifx.LIFXClientId = "${{ secrets.LIFXClientId }}"
$appsettings.lightSettings.lifx.LIFXClientSecret = "${{ secrets.LIFXClientSecret }}"
$appsettings.applicationInsights.instrumentationkey = "${{ secrets.InstrumentationKey }}"
$appsettings.lightSettings.hue.RemoteHueClientId = "${{ secrets.RemoteHueClientId }}"
$appsettings.lightSettings.hue.RemoteHueClientSecret = "${{ secrets.RemoteHueClientSecret }}"
$appsettings.lightSettings.hue.RemoteHueClientAppName = "${{ secrets.RemoteHueClientAppName }}"
$appsettings | ConvertTo-Json -depth 32| set-content '.\src\DesktopClient\PresenceLight\appsettings.json'
shell: powershell
if: ${{ success() && github.event_name != 'pull_request' }}

- name: Update Badge Versions
run: |
# Update badges
[xml]$badge = Get-Content ".\Build\ci_badge.svg"
$badge.svg.g[1].text[2].InnerText = "${{ env.GitBuildVersionSimple }}.0"
$badge.svg.g[1].text[3].InnerText = "${{ env.GitBuildVersionSimple }}.0"
$badge.Save("${{ github.workspace }}\${{ matrix.ChannelName }}\ci_badge.svg")
[xml]$badge = Get-Content ".\Build\store_badge.svg"
$badge.svg.g[1].text[2].InnerText = "${{ env.GitBuildVersionSimple }}.0"
$badge.svg.g[1].text[3].InnerText = "${{ env.GitBuildVersionSimple }}.0"
$badge.Save("${{ github.workspace }}\${{ matrix.ChannelName }}\stable_badge.svg")
shell: powershell

- name: Build Standalone Presence Light x86
run: |
dotnet restore .\src\DesktopClient\PresenceLight\PresenceLight.csproj
dotnet publish .\src\DesktopClient\PresenceLight\PresenceLight.csproj -c ${{ env.BuildConfiguration }} /p:PublishProfile=Properties/PublishProfiles/WinX86.pubxml
if: ${{ success() && matrix.ChannelName == 'Standalone' }}

- name: Build Standalone Presence Light x64
run: |
dotnet restore .\src\DesktopClient\PresenceLight\PresenceLight.csproj
dotnet publish .\src\DesktopClient\PresenceLight\PresenceLight.csproj -c ${{ env.BuildConfiguration }} /p:PublishProfile=Properties/PublishProfiles/WinX64.pubxml
if: ${{ success() && matrix.ChannelName == 'Standalone' }}

- name: Build Standalone Presence Light ARM64
run: |
dotnet restore .\src\DesktopClient\PresenceLight\PresenceLight.csproj
dotnet publish .\src\DesktopClient\PresenceLight\PresenceLight.csproj -c ${{ env.BuildConfiguration }} /p:PublishProfile=Properties/PublishProfiles/WinARM64.pubxml
if: ${{ success() && matrix.ChannelName == 'Standalone' }}

- name: Zip Standalone PresenceLight x86 Files
run: |
Compress-Archive -Path '.\src\DesktopClient\PresenceLight\bin\${{ env.BuildConfiguration }}\${{ env.Win10RID }}\win-x86\publish\*' `
-DestinationPath ${{ github.workspace }}\${{ matrix.ChannelName }}\PresenceLight.${{ env.GitBuildVersionSimple }}-x86.zip
shell: powershell
if: ${{ success() && matrix.ChannelName == 'Standalone' }}

- name: Zip Standalone PresenceLight x64 Files
run: |
Compress-Archive -Path '.\src\DesktopClient\PresenceLight\bin\${{ env.BuildConfiguration }}\${{ env.Win10RID }}\win-x64\publish\*' `
-DestinationPath ${{ github.workspace }}\${{ matrix.ChannelName }}\PresenceLight.${{ env.GitBuildVersionSimple }}-x64.zip
shell: powershell
if: ${{ success() && matrix.ChannelName == 'Standalone' }}

- name: Zip Standalone PresenceLight ARM Files
run: |
Compress-Archive -Path '.\src\DesktopClient\PresenceLight\bin\${{ env.BuildConfiguration }}\${{ env.Win10RID }}\win-arm64\publish\*' `
-DestinationPath ${{ github.workspace }}\${{ matrix.ChannelName }}\PresenceLight.${{ env.GitBuildVersionSimple }}-win-arm64.zip
shell: powershell
if: ${{ success() && matrix.ChannelName == 'Standalone' }}

- name: Build Appx Package
run: |
#dotnet restore .\src\DesktopClient\PresenceLight\PresenceLight.csproj
#msbuild /t:restore .\src\DesktopClient\PresenceLight.Package\PresenceLight.Package.wapproj
msbuild '.\src\DesktopClient\PresenceLight.Package\PresenceLight.Package.wapproj' /p:VersionNumber=${{ env.GitBuildVersionSimple }} `
/p:ChannelName=${{ matrix.ChannelName }} /p:configuration='${{ env.BuildConfiguration }}' /p:IncludeSymbols=true `
/p:AppxPackageDir="${{ github.workspace }}\${{ matrix.ChannelName }}\\"
if: ${{ success() && matrix.ChannelName != 'Standalone' }}

- name: Publish ${{ matrix.ChannelName }} Arifacts
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}\${{ matrix.ChannelName }}
name: ${{ matrix.ChannelName }}

- name: Publish signing scripts
uses: actions/upload-artifact@v2
with:
path: Build
name: SigningScripts
if: ${{ success() && matrix.ChannelName == 'Nightly' }}

- name: Publish .chocolatey scripts
uses: actions/upload-artifact@v2
with:
path: .chocolatey
name: Chocolatey
if: ${{ success() && matrix.ChannelName == 'Nightly' }}

sign:
needs: Build_WPF
runs-on: windows-latest
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
id-token: write # Required for requesting the JWT

steps:
- name: Download Artifacts
- name: Download ${{ matrix.ChannelName }} Artifacts
uses: actions/download-artifact@v2
with:
path: "${{ github.workspace }}/ToSign"
name: ${{ matrix.ChannelName }}
path: ${{ github.workspace }}\ToSign\${{ matrix.ChannelName }}

- uses: actions/download-artifact@v2
name: Download Signing Scripts Artifacts
with:
name: SigningScripts
path: "${{ github.workspace }}/SigningScripts"

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x

- name: Install Sign CLI tool
run: dotnet tool install --tool-path . sign --version 0.9.0-beta.23063.3

- name: Azure Login
uses: azure/login@v1
with:
Expand All @@ -224,24 +71,20 @@ jobs:
shell: pwsh
run: >
./sign code azure-key-vault
**/*.appxbundle
'**/*.{exe,zip}'
--timestamp-url "http://timestamp.digicert.com"
--base-directory "${{ github.workspace }}/ToSign/Nightly"
--file-list "${{ github.workspace }}/SigningScripts/filelist.txt"
--base-directory "${{ github.workspace }}/ToSign"
--file-list "${{ github.workspace }}/SigningScripts/filelist.txt"
--publisher-name "Isaac Levin"
--description "PresenceLight"
--description-url "https://github.com/isaacrlevin/presencelight"
--azure-key-vault-managed-identity true
--azure-key-vault-url "${{ secrets.KEY_VAULT_URL }}"
--azure-key-vault-certificate "${{ secrets.KEY_VAULT_CERTIFICATE_ID }}"
--verbosity Trace
- name: Publish Signed Nightly Packages
- name: Publish Signed ${{ matrix.ChannelName }} Packages
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/ToSign/Nightly
name: NightlySigned

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
path: ${{ github.workspace }}\ToSign\${{ matrix.ChannelName }}
name: '${{ matrix.ChannelName }}_Signed'
Loading

0 comments on commit 0ecd161

Please sign in to comment.