Corrected the release pipeline #18
This file contains 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 Project | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build_and_test: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ vars.DOTNET_VERSION }} | |
- name: Restore dependencies | |
run: dotnet restore ${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.sln | |
- name: Clean | |
run: dotnet clean ${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.sln --configuration Release | |
- name: Build | |
run: dotnet build ${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.sln --configuration Release --no-restore | |
- name: Test | |
run: dotnet test ${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.sln --configuration Release --no-build --logger "trx;LogFileName=test_results.trx" | |
- name: Publish Test Results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Test Results | |
path: '**/TestResults/*.trx' | |
pack_and_publish: | |
needs: build_and_test | |
if: success() | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '7.0.x' | |
- name: Restore dependencies | |
run: dotnet restore ${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.sln | |
- name: Build | |
run: dotnet build ${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.sln --configuration Release --no-restore | |
- name: Package | |
run: dotnet pack ${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.sln --configuration Release --output nupkgs | |
- name: Setup NuGet CLI | |
run: | | |
curl -L https://dist.nuget.org/win-x86-commandline/latest/nuget.exe --output nuget.exe | |
- name: Create Nuget Config | |
run: | | |
./nuget.exe config | |
./nuget.exe setapikey "${{ secrets.NUGET_API_KEY }}" -verbosity quiet | |
- name: Publish NuGet Package | |
run: nuget push .\nupkgs\*.nupkg | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' |