Automated Dependency Updates #93
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Pipeline | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
pipeline: | |
name: Build, Test and Publish | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
language: [ 'csharp' ] | |
steps: | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@v4 | |
- name: Setup .NET 8.0 | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Setup .NET 6.0 | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Initialize | |
id: initialize | |
run: | | |
NAME=$(echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]') | |
VERSION_PREFIX=$(date +'%Y.%m.%d').${GITHUB_RUN_NUMBER} | |
BRANCH_CURRENT=${GITHUB_REF#refs/*/} | |
BRANCH_CURRENT=${BRANCH_CURRENT//[^a-zA-Z0-9]/-} | |
if [[ ${GITHUB_EVENT_NAME} == 'pull_request' ]]; then | |
BRANCH_BASE=${GITHUB_BASE_REF#refs/*/} | |
BRANCH_BASE=${BRANCH_BASE/[^a-zA-Z0-9]//-} | |
BRANCH_COMPARE=${GITHUB_HEAD_REF#refs/*/} | |
BRANCH_COMPARE=${BRANCH_COMPARE//[^a-zA-Z0-9]/-} | |
VERSION_SUFFIX="merge-${BRANCH_BASE}-${BRANCH_COMPARE}" | |
elif [[ ${GITHUB_EVENT_NAME} == ${{ github.event.repository.default_branch }} ]]; then | |
VERSION_SUFFIX="${BRANCH_CURRENT}" | |
fi | |
if [[ $VERSION_SUFFIX == '' ]]; then | |
DOCKER_TAG=$VERSION_PREFIX | |
else | |
DOCKER_TAG=$VERSION_PREFIX-$VERSION_SUFFIX | |
fi | |
echo "::set-output name=name::$(eval printf "%s" "$NAME")" | |
echo "::set-output name=version_prefix::$(eval printf "%s" "$VERSION_PREFIX")" | |
echo "::set-output name=version_suffix::$(eval printf "%s" "$VERSION_SUFFIX")" | |
echo "::set-output name=docker_tag::$(eval printf "%s" "$DOCKER_TAG")" | |
echo "::set-output name=branch::$(eval printf "%s" "$BRANCH_CURRENT")" | |
shell: bash | |
- name: Restore | |
id: restore | |
run: dotnet restore -v minimal | |
- name: Build | |
id: build | |
run: dotnet build --no-restore -c Release -v minimal -p:VersionPrefix=${VERSION_PREFIX} -p:VersionSuffix=${VERSION_SUFFIX} | |
env: | |
VERSION_PREFIX: ${{ steps.initialize.outputs.version_prefix }} | |
VERSION_SUFFIX: ${{ steps.initialize.outputs.version_suffix }} | |
- name: Test | |
id: test | |
run: dotnet test --no-restore --no-build -c Release -v minimal -p:CollectCoverage=true -p:CoverletOutput=../results/ -p:MergeWith="../results/coverage.json" -p:CoverletOutputFormat=opencover%2cjson -m:1 | |
env: | |
VERSION_PREFIX: ${{ steps.initialize.outputs.version_prefix }} | |
VERSION_SUFFIX: ${{ steps.initialize.outputs.version_suffix }} | |
- name: Analysis | |
id: analysis | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./tests/results/coverage.net8.0.opencover.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Pack | |
id: pack | |
run: dotnet pack ./src/**/*.csproj --no-restore -c Release -v quiet -o nuget -p:ContinuousIntegrationBuild=true -p:VersionPrefix=${VERSION_PREFIX} -p:VersionSuffix=${VERSION_SUFFIX} | |
env: | |
VERSION_PREFIX: ${{ steps.initialize.outputs.version_prefix }} | |
VERSION_SUFFIX: ${{ steps.initialize.outputs.version_suffix }} | |
- name: Setup | |
id: setup | |
uses: nuget/setup-nuget@v1 | |
with: | |
nuget-api-key: ${{ secrets.NUGET_API_KEY }} | |
- name: Publish | |
id: publish | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: nuget push nuget/*.nupkg -src https://api.nuget.org/v3/index.json |