Skip to content
name: .NET Build and Test
on:
push:
env:
App_Name: FileRenamerDiff
Solution_Directory: src
Solution_Path: src/FileRenamerDiff.sln
App_Project_Path: src/FileRenamerDiff/FileRenamerDiff.csproj
Test_Directory: UnitTests
CodeCov_Result: "lcov.xml"
jobs:
build:
strategy:
matrix:
configuration: [Debug, Release]
runs-on:
windows-latest
steps:
# Dump for debug workflow
- name: Dump Github Context
env:
GitHub_Context: ${{ toJson(github) }}
run: echo "${GitHub_Context}"
- 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: 6.0.x
# Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.2
# Restore before build and test
- name: Restore
run: dotnet restore ${{ env.Solution_Path }}
- name: Build with dotnet
run: dotnet build ${{ env.App_Project_Path }} --no-restore
env:
Configuration: ${{ matrix.configuration }}
# Execute all unit tests in the solution
- name: Execute unit tests
run: >
dotnet test ${{ env.Solution_Path }}
--verbosity normal --no-restore
--collect:"XPlat Code Coverage"
/p:CollectCoverage=true /p:CoverletOutputFormat=opencover
/p:ExcludeByFile="**.Designer.cs%2c**.xaml*%2c**.g.cs%2c**.xaml"
-p:coverletOutput=${{ env.CodeCov_Result }}
env:
Configuration: ${{ matrix.configuration }}
- name: Send coverage result to codecov
uses: codecov/codecov-action@v2.0.3
with:
files: ${{ env.Solution_Directory }}/${{ env.Test_Directory }}/${{ env.CodeCov_Result }}
create-release:
runs-on: windows-latest
needs: [build]
if: "contains( github.ref , 'tags/v')"
steps:
- name: echos
shell: bash
run: |
echo $RELEASE_VERSION
echo version=${GITHUB_REF/refs\/tags\/v/}
echo "version=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
echo "app_x86_name=${{ env.App_Name }}_app_win-x86_ver${{ env.version }}" >> $GITHUB_ENV
echo "app_x64_name=${{ env.App_Name }}_app_win-x64_ver${{ env.version }}" >> $GITHUB_ENV
pwd
- name: confirm env value
shell: bash
run: |
echo "env.version=${{ env.version }}"
echo "app_x86_name=${{ env.app_x86_name }}"
echo "app_x64_name=${{ env.app_x64_name }}"
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: dotnet publish x86
run: dotnet publish ${{ env.App_Project_Path }} -c Release -r win-x86 --self-contained true -p:PublishTrimmed=false -p:PublishSingleFile=true -p:PublishReadyToRun=true -o outputs\${{ env.app_x86_name }}
- name: dotnet publish x64
run: dotnet publish ${{ env.App_Project_Path }} -c Release -r win-x64 --self-contained true -p:PublishTrimmed=false -p:PublishSingleFile=true -p:PublishReadyToRun=true -o outputs\${{ env.app_x64_name }}
- name: Archive publish files
uses: actions/upload-artifact@v1
with:
name: FileRenamerDiff_apps
path: outputs
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: v${{ env.version }}
release_name: Ver ${{ env.version }}
body: |
- Change design
- Bug fix
draft: true
prerelease: false
- name: Archive packages
shell: pwsh
run: |
Compress-Archive -Path outputs\${{ env.app_x86_name }} -DestinationPath ${{ env.app_x86_name }}.zip
Compress-Archive -Path outputs\${{ env.app_x64_name }} -DestinationPath ${{ env.app_x64_name }}.zip
- name: Upload Release Asset
uses: csexton/release-asset-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
release-url: ${{ steps.create_release.outputs.upload_url }}
files: |
${{ env.app_x86_name }}.zip
${{ env.app_x64_name }}.zip