ci: better dotnet publish in build workflow

- Executable is now compiled using Ready to Run. This increases the size
  of the executable but makes the code much faster.
- `src` directory is no longer the cwd
- The matrix build in build.yml now runs on its respective platform to
  avoid cross compilation. Cross compiling does not work with the
  ReadyToRun optimization on, see:
  https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run#cross-platformarchitecture-restrictions
- publish and zip steps in the workflow have been put in a powershell
  script for reusability and to keep the workflow YAML minimal.
recyclarr
Robert Dailey 3 years ago
parent 1b09094aa1
commit eaeb06eb26

@ -13,10 +13,6 @@ on:
env:
dotnetVersion: 5.0.x
defaults:
run:
working-directory: src
jobs:
test:
name: Test
@ -33,7 +29,7 @@ jobs:
dotnet-version: ${{ env.dotnetVersion }}
- name: Test
run: dotnet test --configuration Release --logger GitHubActions
run: dotnet test src --configuration Release --logger GitHubActions
build:
name: Build
@ -41,10 +37,16 @@ jobs:
strategy:
fail-fast: true
matrix:
runtime: [win-x64, linux-x64, osx-x64]
include:
- runtime: win-x64
image: windows-latest
- runtime: linux-x64
image: ubuntu-latest
- runtime: osx-x64
image: macos-latest
# Must run on Windows so that version info gets properly set in host EXE. See:
# https://github.com/dotnet/runtime/issues/3828
runs-on: windows-latest
runs-on: ${{ matrix.image }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
@ -59,26 +61,15 @@ jobs:
with:
dotnet-version: ${{ env.dotnetVersion }}
- name: Publish
run: >
dotnet publish Trash
--configuration Release
--output publish
--runtime ${{ matrix.runtime }}
--self-contained true
-p:PublishSingleFile=true
-p:PublishTrimmed=true
-p:IncludeNativeLibrariesForSelfExtract=true
- name: Zip Binary
- name: Publish & Zip
shell: pwsh
run: Compress-Archive publish/trash* trash-${{ matrix.runtime }}.zip
run: ci/PublishAndZip.ps1 ${{ matrix.runtime }}
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: trash
path: src/trash-*.zip
path: publish/zip/trash-*.zip
release:
name: Release

@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Executable is now compiled using [Ready to Run]. This substantially increases the size of the
executable but makes the code much faster.
[Ready to Run]: https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run
## [1.3.0] - 2021-04-23
### Added

@ -0,0 +1,21 @@
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]
$runtime
)
$ErrorActionPreference = "Stop"
dotnet publish src\Trash `
--output publish\$runtime `
--configuration Release `
--runtime $runtime `
--self-contained true `
-p:PublishSingleFile=true `
-p:PublishTrimmed=true `
-p:IncludeNativeLibrariesForSelfExtract=true `
-p:PublishReadyToRun=true
New-Item -ItemType Directory -Force -Path publish\zip
Compress-Archive publish\$runtime\trash* publish\zip\trash-$runtime.zip -Force

@ -3,7 +3,7 @@
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningLevel>9999</WarningLevel>
<TreatWarningsAsErrors />
<!-- <TreatWarningsAsErrors>true</TreatWarningsAsErrors> -->
<DebugType>embedded</DebugType>
<!-- Rider does not support `AllEnabledByDefault` yet. See:
https://youtrack.jetbrains.com/issue/RIDER-55142

Loading…
Cancel
Save