From b3d55660b14160c215d00add0b411dc6743a4119 Mon Sep 17 00:00:00 2001 From: Mitch Capper Date: Mon, 18 Jul 2022 13:24:38 -0700 Subject: [PATCH] Fix GitHub build workflow to error on fail Fixes dnSpyEx#86 Switch to matrix use to simplify build and speed up process --- .github/workflows/build.yml | 64 +++++++++++++++---------------------- build.ps1 | 6 +++- 2 files changed, 30 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78c883d4e4..f9696a4f8f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,22 @@ jobs: build: name: Build runs-on: windows-2022 + defaults: + run: + shell: pwsh + strategy: + matrix: + platform: [netframework, net-x86, net-x64] + include: + - platform: netframework + package-name: netframework + build-dir: net48 + - platform: net-x86 + package-name: net-win32 + build-dir: net6.0-windows\win-x86\publish + - platform: net-x64 + package-name: net-win64 + build-dir: net6.0-windows\win-x64\publish steps: - uses: actions/checkout@v2 @@ -31,47 +47,17 @@ jobs: - uses: microsoft/setup-msbuild@v1.0.2 # Build each tfm separately since building all requires too much disk space - - name: Build dnSpy (.NET Framework) - shell: pwsh - run: | - .\build.ps1 netframework - New-Item -ItemType Directory -Path C:\builtfiles\dnSpy-netframework -Force > $null - Copy-Item -Path dnSpy\dnSpy\bin\Release\net48\* -Destination C:\builtfiles\dnSpy-netframework -Recurse - .\clean-all.cmd + - name: Build dnSpy (${{matrix.platform}}) + run: .\build.ps1 ${{matrix.platform}} + - name: Create output directory + run: New-Item -ItemType Directory -Path C:\builtfiles\dnSpy-${{matrix.platform}} -Force > $null + continue-on-error: true + - name: Copy release files for upload + run: Copy-Item -Path dnSpy\dnSpy\bin\Release\${{matrix.build-dir}}\* -Destination C:\builtfiles\dnSpy-${{matrix.platform}} -Recurse - uses: actions/upload-artifact@v2 if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') with: - name: dnSpy-netframework - path: C:\builtfiles\dnSpy-netframework - if-no-files-found: error - - - name: Build dnSpy (.NET x86) - shell: pwsh - run: | - .\build.ps1 net-x86 - New-Item -ItemType Directory -Path C:\builtfiles\dnSpy-net-win32 -Force > $null - Copy-Item -Path dnSpy\dnSpy\bin\Release\net6.0-windows\win-x86\publish\* -Destination C:\builtfiles\dnSpy-net-win32 -Recurse - .\clean-all.cmd - - - uses: actions/upload-artifact@v2 - if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - with: - name: dnSpy-net-win32 - path: C:\builtfiles\dnSpy-net-win32 - if-no-files-found: error - - - name: Build dnSpy (.NET x64) - shell: pwsh - run: | - .\build.ps1 net-x64 - New-Item -ItemType Directory -Path C:\builtfiles\dnSpy-net-win64 -Force > $null - Copy-Item -Path dnSpy\dnSpy\bin\Release\net6.0-windows\win-x64\publish\* -Destination C:\builtfiles\dnSpy-net-win64 -Recurse - .\clean-all.cmd - - - uses: actions/upload-artifact@v2 - if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - with: - name: dnSpy-net-win64 - path: C:\builtfiles\dnSpy-net-win64 + name: dnSpy-${{matrix.package-name}} + path: C:\builtfiles\dnSpy-${{matrix.platform}} if-no-files-found: error diff --git a/build.ps1 b/build.ps1 index dc714e649c..378629e3d4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,4 +1,8 @@ -param([string]$buildtfm = 'all', [switch]$NoMsbuild) +param( + [ValidateSet("all","netframework","net-x86","net-x64")] + [string]$buildtfm = 'all', + [switch]$NoMsbuild + ) $ErrorActionPreference = 'Stop' $netframework_tfm = 'net48'