Skip to content

Commit aac961c

Browse files
authored
Enhance .NET workflow with branch and tag support
Updated GitHub Actions workflow for .NET to include develop branch and tag support for releases. Upgraded action versions and modified the push condition for NuGet packages.
1 parent 73bcbfb commit aac961c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

.github/workflows/dotnet.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,31 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
8-
branches:
9-
- main
7+
- develop
8+
tags:
9+
- 'release/v*'
10+
pull_request: {}
1011
workflow_dispatch:
1112

1213
jobs:
1314
build-and-publish:
14-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-latest
1516
steps:
16-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
1718
- name: Setup .NET
18-
uses: actions/setup-dotnet@v1
19+
uses: actions/setup-dotnet@v3
1920
with:
2021
dotnet-version: 8.0.x
22+
- name: Restore
23+
run: dotnet restore
2124
- name: Build
22-
run: dotnet build --configuration Release
25+
run: dotnet build --configuration Release --no-restore
2326
- name: Pack
2427
run: dotnet pack --no-build --configuration Release PAYNLSDK/PayNLSdk.csproj --output .
2528
- name: Push Nuget
26-
if: ${{ github.ref == 'refs/heads/main' }}
27-
run: |
28-
dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_PUBLISH_KEY }} --skip-duplicate
29-
dotnet nuget push *.snupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_PUBLISH_KEY }} --skip-duplicate
29+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/release/v') }}
30+
env:
31+
NUGET_API_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
32+
run: |
33+
dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" --skip-duplicate
34+
dotnet nuget push *.snupkg --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" --skip-duplicate

0 commit comments

Comments
 (0)