From a5b11e6ae513e8affcd9baa0a80f4436cd1443ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20W=C3=A4scher?= Date: Sat, 11 May 2024 00:02:58 +0200 Subject: [PATCH] Create ci.yml --- .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ff851a8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: .NET Build, Test, and Publish Nuget Package + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Fetch all history for all tags and branches + run: | + git config remote.origin.url https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git fetch --prune --unshallow + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.7 + with: + versionSpec: '5.x' + + - name: Use GitVersion + id: gitversion # step id used as reference for output values + uses: gittools/actions/gitversion/execute@v0.9.7 + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: | + 3.1.x + 6.0.x + 8.0.x + + - name: Restore dependencies + run: dotnet restore src/FluentDragDrop.sln + + - name: Build + run: dotnet build --no-restore --configuration=Release /p:Version=${{steps.gitversion.outputs.semVer}} + + - name: Test + run: dotnet test --no-build --configuration=Release --verbosity normal + + - name: pack nuget packages + run: dotnet pack --output nupkgs --configuration=Release --no-restore --no-build /p:PackageVersion=${{steps.gitversion.outputs.semVer}} + + - name: Create a GitHub release + uses: ncipollo/release-action@v1 + with: + tag: ${{steps.gitversion.outputs.semVer}} + name: Release ${{steps.gitversion.outputs.semVer}} + if: github.event_name != 'pull_request' + + - name: upload nuget package + if: github.event_name != 'pull_request' + run: dotnet nuget push nupkgs/FluentDragDrop*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json