From cbedd7b986168654fd526443d6b2b2a14862b819 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:46:19 +1100 Subject: [PATCH 1/8] start setting up new CI on actions --- .github/workflows/dotnet-desktop.yml | 115 +++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 .github/workflows/dotnet-desktop.yml diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml new file mode 100644 index 0000000..fcd1042 --- /dev/null +++ b/.github/workflows/dotnet-desktop.yml @@ -0,0 +1,115 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will build, test, sign and package a WPF or Windows Forms desktop application +# built on .NET Core. +# To learn how to migrate your existing application to .NET Core, +# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework +# +# To configure this workflow: +# +# 1. Configure environment variables +# GitHub sets default environment variables for every workflow run. +# Replace the variables relative to your project in the "env" section below. +# +# 2. Signing +# Generate a signing certificate in the Windows Application +# Packaging Project or add an existing signing certificate to the project. +# Next, use PowerShell to encode the .pfx file using Base64 encoding +# by running the following Powershell script to generate the output string: +# +# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte +# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' +# +# Open the output file, SigningCertificate_Encoded.txt, and copy the +# string inside. Then, add the string to the repo as a GitHub secret +# and name it "Base64_Encoded_Pfx." +# For more information on how to configure your signing certificate for +# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing +# +# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key". +# See "Build the Windows Application Packaging project" below to see how the secret is used. +# +# For more information on GitHub Actions, refer to https://github.com/features/actions +# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, +# refer to https://github.com/microsoft/github-actions-for-desktop-apps + +name: .NET Core Desktop + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + + strategy: + matrix: + configuration: [Debug, Release] + + runs-on: windows-latest # For a list of available runner types, refer to + # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on + + env: + Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln. + Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. + Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. + Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj. + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # Install the .NET Core workload + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.101 + + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16 + + # Execute all unit tests in the solution + - name: Execute unit tests + run: dotnet test + + # Restore the application to populate the obj folder with RuntimeIdentifiers + - name: Restore the application + run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + env: + Configuration: ${{ matrix.configuration }} + + # Decode the base 64 encoded pfx and save the Signing_Certificate + - name: Decode the pfx + run: | + $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") + $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx + [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) + + # Create the app package by building and packaging the Windows Application Packaging project + - name: Create the app package + run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} + env: + Appx_Bundle: Always + Appx_Bundle_Platforms: x86|x64 + Appx_Package_Build_Mode: StoreUpload + Configuration: ${{ matrix.configuration }} + + # Remove the pfx + - name: Remove the pfx + run: Remove-Item -path $env:Wap_Project_Directory\$env:Signing_Certificate + + # Upload the MSIX package: https://github.com/marketplace/actions/upload-artifact + - name: Upload build artifacts + uses: actions/upload-artifact@v2 + with: + name: MSIX Package + path: ${{ env.Wap_Project_Directory }}\AppPackages From 33f87e9932d808b4955c2acb5ce287ec6f54e777 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:52:18 +1100 Subject: [PATCH 2/8] Update dotnet-desktop.yml --- .github/workflows/dotnet-desktop.yml | 50 +++------------------------- 1 file changed, 5 insertions(+), 45 deletions(-) diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml index fcd1042..5b96e2a 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/dotnet-desktop.yml @@ -50,16 +50,9 @@ jobs: strategy: matrix: - configuration: [Debug, Release] + configuration: [Release] - runs-on: windows-latest # For a list of available runner types, refer to - # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on - - env: - Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln. - Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. - Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. - Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj. + runs-on: windows-latest steps: - name: Checkout @@ -76,40 +69,7 @@ jobs: # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16 - - # Execute all unit tests in the solution - - name: Execute unit tests run: dotnet test - - # Restore the application to populate the obj folder with RuntimeIdentifiers - - name: Restore the application - run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration - env: - Configuration: ${{ matrix.configuration }} - - # Decode the base 64 encoded pfx and save the Signing_Certificate - - name: Decode the pfx - run: | - $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") - $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx - [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) - - # Create the app package by building and packaging the Windows Application Packaging project - - name: Create the app package - run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} - env: - Appx_Bundle: Always - Appx_Bundle_Platforms: x86|x64 - Appx_Package_Build_Mode: StoreUpload - Configuration: ${{ matrix.configuration }} - - # Remove the pfx - - name: Remove the pfx - run: Remove-Item -path $env:Wap_Project_Directory\$env:Signing_Certificate - - # Upload the MSIX package: https://github.com/marketplace/actions/upload-artifact - - name: Upload build artifacts - uses: actions/upload-artifact@v2 - with: - name: MSIX Package - path: ${{ env.Wap_Project_Directory }}\AppPackages + + - name: Build + run: msbuild Rebuilder.sln /p:Configuration=Release From cb3098ac90adb468d2ea2814496a076ec02c2734 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:53:26 +1100 Subject: [PATCH 3/8] Update dotnet-desktop.yml --- .github/workflows/dotnet-desktop.yml | 45 +--------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml index 5b96e2a..ed00e95 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/dotnet-desktop.yml @@ -1,42 +1,4 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow will build, test, sign and package a WPF or Windows Forms desktop application -# built on .NET Core. -# To learn how to migrate your existing application to .NET Core, -# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework -# -# To configure this workflow: -# -# 1. Configure environment variables -# GitHub sets default environment variables for every workflow run. -# Replace the variables relative to your project in the "env" section below. -# -# 2. Signing -# Generate a signing certificate in the Windows Application -# Packaging Project or add an existing signing certificate to the project. -# Next, use PowerShell to encode the .pfx file using Base64 encoding -# by running the following Powershell script to generate the output string: -# -# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte -# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' -# -# Open the output file, SigningCertificate_Encoded.txt, and copy the -# string inside. Then, add the string to the repo as a GitHub secret -# and name it "Base64_Encoded_Pfx." -# For more information on how to configure your signing certificate for -# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing -# -# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key". -# See "Build the Windows Application Packaging project" below to see how the secret is used. -# -# For more information on GitHub Actions, refer to https://github.com/features/actions -# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, -# refer to https://github.com/microsoft/github-actions-for-desktop-apps - -name: .NET Core Desktop +name: CI on: push: @@ -48,10 +10,6 @@ jobs: build: - strategy: - matrix: - configuration: [Release] - runs-on: windows-latest steps: @@ -69,7 +27,6 @@ jobs: # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16 - run: dotnet test - name: Build run: msbuild Rebuilder.sln /p:Configuration=Release From feeaeab2d2be0baa5615ff13dfa3d7b15af7b1c8 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 16 Dec 2020 13:02:26 +1100 Subject: [PATCH 4/8] i guess we're enabling this to allow msbuild to work --- .github/workflows/dotnet-desktop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml index ed00e95..2bde778 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/dotnet-desktop.yml @@ -11,6 +11,9 @@ jobs: build: runs-on: windows-latest + + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true steps: - name: Checkout From ae9763eedf669df7739139c46dfd7d89cd2a167c Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 16 Dec 2020 13:28:48 +1100 Subject: [PATCH 5/8] ci: try uploading artifact --- .github/workflows/dotnet-desktop.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml index 2bde778..4a81085 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/dotnet-desktop.yml @@ -33,3 +33,9 @@ jobs: - name: Build run: msbuild Rebuilder.sln /p:Configuration=Release + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v2.2.1 + with: + path: + Rebuilder/obj/Release/Rebuilder.exe From cf21f166e08793e980b92f82cc4fe40c8a1cfd6b Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 16 Dec 2020 13:43:27 +1100 Subject: [PATCH 6/8] try to upload to releases page on push --- .github/workflows/{dotnet-desktop.yml => ci.yml} | 7 +++++++ 1 file changed, 7 insertions(+) rename .github/workflows/{dotnet-desktop.yml => ci.yml} (78%) diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/ci.yml similarity index 78% rename from .github/workflows/dotnet-desktop.yml rename to .github/workflows/ci.yml index 4a81085..3c1176a 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/ci.yml @@ -39,3 +39,10 @@ jobs: with: path: Rebuilder/obj/Release/Rebuilder.exe + + - name: Upload to Releases + shell: bash + if: github.event_name == 'push' + run: | + wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh + ./upload.sh Rebuilder/obj/Release/Rebuilder.exe From 7b22f34e6b68ba0d3a2148fa8cf7fe3c5a4da092 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 16 Dec 2020 13:45:41 +1100 Subject: [PATCH 7/8] use curl instead of wget --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c1176a..f5dacae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,5 +44,5 @@ jobs: shell: bash if: github.event_name == 'push' run: | - wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh + curl -fLOSs --retry 2 --retry-delay 60 https://github.com/probonopd/uploadtool/raw/master/upload.sh ./upload.sh Rebuilder/obj/Release/Rebuilder.exe From 6b9223a892d74afcae14135bb0fffd53b8ab7503 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 16 Dec 2020 13:51:32 +1100 Subject: [PATCH 8/8] added upload key --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5dacae..2ca70a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,9 @@ jobs: - name: Upload to Releases shell: bash if: github.event_name == 'push' + env: + GITHUB_TOKEN: ${{ secrets.UPLOAD_KEY }} + TRAVIS_REPO_SLUG: itsmattkc/LEGOIslandRebuilder run: | curl -fLOSs --retry 2 --retry-delay 60 https://github.com/probonopd/uploadtool/raw/master/upload.sh ./upload.sh Rebuilder/obj/Release/Rebuilder.exe