Skip to content

Commit 76639a9

Browse files
committed
Added CI/CD pipeline for auto pushing nuget packages
1 parent 9b2fa00 commit 76639a9

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build and Publish NuGet
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
tags: [ 'v*' ]
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
id-token: write
12+
13+
jobs:
14+
publish:
15+
runs-on: windows-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '6.0.x'
22+
23+
- name: Setting up NuGet auth
24+
shell: pwsh
25+
run: |
26+
dotnet nuget add source https://nuget.pkg.github.com/Empty-Solution/index.json --name github --store-password-in-clear-text
27+
dotnet nuget update source github --username ${{ github.actor }} --password ${{ secrets.NUGET_TOKEN }} --store-password-in-clear-text
28+
29+
- name: Getting version
30+
id: version
31+
shell: pwsh
32+
run: |
33+
if ($env:GITHUB_REF -match "refs/tags/v(.+)") {
34+
$VERSION = $matches[1]
35+
} else {
36+
$VERSION = "1.0.0-alpha"
37+
}
38+
echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT
39+
40+
- name: Packing and Pushing
41+
working-directory: ./src
42+
shell: pwsh
43+
run: |
44+
dotnet pack -p:Version=${{ steps.version.outputs.VERSION }} --configuration Release
45+
dotnet nuget push "**/*.nupkg" --source github --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate

src/NuGet.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)