Skip to content

fixing build

fixing build #34

name: "01 - Build, Test, Publish"
on:
push:
# run on all commits
pull_request:
# run on all pull requests
workflow_dispatch:
# allows you to run this workflow manually from the Actions tab
jobs:
build_test_publish:
#runs-on: ubuntu-latest
runs-on: windows-latest
defaults:
run:
shell: pwsh
env:
BUILD_PATH: ./src
CONFIG_NAME: Release
PROJECT_PATH: ./BHBackup.WpfApp/BHBackup.WpfApp.csproj
# relative to BUILD_PATH
PUBLISH_PATH: ../.build/app
RUNTIME: win-x64
steps:
- uses: actions/checkout@v4
with:
# needed for gitversion to work
fetch-depth: 0
- name: gitversion setup
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: gitversion executen
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: dotnet info
working-directory: ${{ env.BUILD_PATH }}
run: dotnet --info
- name: dotnet restore
working-directory: ${{ env.BUILD_PATH }}
run: |
dotnet restore `
--runtime "${{ env.RUNTIME }}"
- name: dotnet build
working-directory: ${{ env.BUILD_PATH }}
run: |
# /p:AssemblyVersion => "File version" property
# e.g. "1.2.3+45" -> "1.2.3.45"
$assemblyVersion = "${{ steps.gitversion.outputs.FullSemVer }}".Replace("+", ".");
# /p:yVersion => "Product version" property
# e.g. "1.2.3+45" -> "1.2.3+45"
$productVersion = "${{ steps.gitversion.outputs.FullSemVer }}"
dotnet build "${{ env.PROJECT_PATH }}" `
--configuration "${{ env.CONFIG_NAME }}" `
--no-restore `
--runtime "${{ env.RUNTIME }}" `
--self-contained true `
--property:PublishSingleFile=true `
--property:AssemblyVersion=$assemblyVersion `
--property:Version=$productVersion `
--property:DebugType=embedded
- name: dotnet test
working-directory: ${{ env.BUILD_PATH }}
run: |
dotnet test `
--configuration "${{ env.CONFIG_NAME }}" `
--no-build `
--filter "TestCategory!=Performance"
- name: dotnet publish
working-directory: ${{ env.BUILD_PATH }}
run: |
# windows
dotnet publish "${{ env.PROJECT_PATH }}" `
--configuration "${{ env.CONFIG_NAME }}" `
--no-build `
--runtime "${{ env.RUNTIME }}" `
--output "${{ env.PUBLISH_PATH }}/win-x64" `
--self-contained true `
--property:PublishSingleFile=true `
--property:DebugType=embedded
#--property:PublishTrimmed=true
Move-Item `
-Path "${{ env.PUBLISH_PATH }}/win-x64/BHBackup.WpfApp.exe" `
-Destination "${{ env.PUBLISH_PATH }}/win-x64/BHBackup-gui-win-x64.exe"
#- name: zip release
# working-directory: ${{ env.BUILD_PATH }}
# run: |
# & "C:\Program Files\7-Zip\7z.exe" a "FancyMouse-preview-v0.0.0.zip" "${{ env.PUBLISH_PATH }}"
- name: upload release
uses: actions/upload-artifact@v4
with:
name: BHBackup-v${{ steps.gitversion.outputs.FullSemVer }}
path: .build/app/win-x64
- name: dotnet tool jb inspectcode
working-directory: ${{ env.BUILD_PATH }}
run: |
dotnet new tool-manifest
dotnet tool install jetbrains.resharper.globaltools
dotnet tool run jb inspectcode "./BHBackup.sln" -output="../.build/out/jb-inspectcode.xml" --no-build
- name: upload jb-inspectcode.xml
uses: actions/upload-artifact@v3
with:
name: jb-inspectcode.xml
path: .build/out/jb-inspectcode.xml