Skip to content

Merge branch 'develop' of https://github.com/dutchgrit/afasclient int… #33

Merge branch 'develop' of https://github.com/dutchgrit/afasclient int…

Merge branch 'develop' of https://github.com/dutchgrit/afasclient int… #33

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- main
- develop
env:
VALUE: ${{ github.run_number }}
NET_VERSION: 10.0.x
CONFIGURATION: Release
PROJECT: ./src/AfasClient.csproj
PROJECT_TEST: ./test/AfasClient.Test.csproj
PROJECT_NAME: DutchGrit.AfasClient
jobs:
build:
runs-on: windows-latest
outputs:
nugetVersion: ${{ steps.vars.outputs.nugetVersion }}
defaults:
run:
working-directory: src
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set version variables
id: vars
shell: pwsh
run: |
$currentPatch = 1 + [int]${{ env.VALUE }}
echo "currentPatch=$currentPatch" >> $ENV:GITHUB_OUTPUT
if ("${{ github.ref_name }}" -eq "main") {
$nugetVersion = "2.2.0.$currentPatch"
} else {
$nugetVersion = "2.2.0.$currentPatch-beta"
}
echo "nugetVersion=$nugetVersion" >> $ENV:GITHUB_OUTPUT
- name: Replace project version
shell: pwsh
run: |
(Get-Content "${{ env.PROJECT }}") -replace 'Version>1.0.0.0<', "Version>${{ steps.vars.outputs.nugetVersion }}<" | Set-Content "${{ env.PROJECT }}"
(Get-Content ".\src\Properties\AssemblyInfo.cs") -replace '1.0.0.0', "2.2.0.${{ steps.vars.outputs.currentPatch }}" | Set-Content ".\src\Properties\AssemblyInfo.cs"
- name: Setup .NET
uses: actions/setup-dotnet@v5.0.1
with:
dotnet-version: ${{ env.NET_VERSION }}
- name: Dotnet Test
env:
AfasToken: ${{ secrets.TEST_AFAS_TOKEN }}
AfasMemberId: ${{ secrets.TEST_AFAS_MEMBERID }}
AfasEnvironment: ${{ secrets.TEST_AFAS_ENVIRONMENT }}
run: dotnet test ${{ env.PROJECT_TEST }} --configuration ${{ env.CONFIGURATION }}
- name: Build and analyze
shell: powershell
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: |
dotnet build ${{ env.PROJECT }} --configuration ${{ env.CONFIGURATION }}
- name: Dotnet Pack
run: dotnet pack ${{ env.PROJECT }} --configuration ${{ env.CONFIGURATION }}
- name: Upload Artifact
uses: actions/upload-artifact@v4.4.3
with:
name: ${{ env.PROJECT_NAME }}
path: ./src/src/bin/${{ env.CONFIGURATION }}/${{ env.PROJECT_NAME }}.${{ steps.vars.outputs.nugetVersion }}.nupkg
deploy:
needs: build
runs-on: windows-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@v4.1.8
with:
name: ${{ env.PROJECT_NAME }}
- name: Push to NuGet
run: |
dotnet nuget push "${{ env.PROJECT_NAME }}.${{ needs.build.outputs.nugetVersion }}.nupkg" --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json