Skip to content

chore: migrate build to GitHub Actions #26

chore: migrate build to GitHub Actions

chore: migrate build to GitHub Actions #26

Workflow file for this run

name: "build"
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
paths:
- "src/**"
- ".github/workflows/build.yml"
jobs:
package:
name: pack
runs-on: ubuntu-latest
outputs:
version: "${{ steps.gitversion.outputs.nuGetVersion }}"
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: "5.x"
preferLatestVersion: true
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
updateAssemblyInfo: true
useConfigFile: true
configFilePath: gitversion.yml
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-quality: "ga"
- name: Build library
run: >
dotnet build src/Indicators.csproj
--configuration Release
--property:Version=${{ steps.gitversion.outputs.nuGetVersion }}
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Pack for NuGet
run: >
dotnet pack src/Indicators.csproj
--configuration Release
--no-build
--include-symbols
--output NuGet
-p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersion }}
- name: Save NuGet package
uses: actions/upload-artifact@v3
with:
name: packages
path: NuGet
- name: Show version
run: |
{
echo "### Identified semantic version"
echo "| Variable | Value |"
echo "| --------------- | ----------------------------------------------- |"
echo "| Major | ${{ steps.gitversion.outputs.major }} |"
echo "| Minor | ${{ steps.gitversion.outputs.minor }} |"
echo "| Patch | ${{ steps.gitversion.outputs.patch }} |"
echo "| PreReleaseTag | ${{ steps.gitversion.outputs.preReleaseTag }} |"
echo "| MajorMinorPatch | ${{ steps.gitversion.outputs.majorMinorPatch }} |"
echo "| SemVer | ${{ steps.gitversion.outputs.semVer }} |"
echo "| NuGetVersion | ${{ steps.gitversion.outputs.nuGetVersion }} |"
} >> $GITHUB_STEP_SUMMARY
testing:
name: test
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-quality: "ga"
- name: Build solution
run: >
dotnet build
--configuration Release
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Test library
run: >
dotnet test
--configuration Release
--no-build
--verbosity normal
--results-directory "TestResults"
--collect "Code Coverage"
- name: Save test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: TestResults
if: ${{ always() }}