Skip to content

Commit eec2400

Browse files
committed
Implement CD via tags
1 parent 329d4a1 commit eec2400

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

.github/workflows/dotnet.yml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,50 @@
1-
# This workflow will build a .NET project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3-
4-
name: .NET
1+
name: Build and Test
52

63
on:
74
push:
8-
branches: ["main"]
5+
branches: [ main ]
6+
tags:
7+
- '[0-9]+.[0-9]+.[0-9]+*'
98
pull_request:
10-
branches: ["main"]
9+
branches: [ main ]
1110

1211
jobs:
1312
build:
1413
runs-on: ubuntu-latest
1514

1615
steps:
17-
- uses: actions/checkout@v4
18-
- name: Setup .NET
19-
uses: actions/setup-dotnet@v4
20-
with:
21-
dotnet-version: 8.0.x
22-
- name: Restore dependencies
23-
run: dotnet restore
24-
- name: Build
25-
run: dotnet build --no-restore
26-
- name: Test
27-
run: dotnet test --no-build --verbosity normal
16+
- uses: actions/checkout@v3
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v3
20+
with:
21+
dotnet-version: |
22+
8.0.x
23+
9.0.x
24+
25+
- name: Restore dependencies
26+
run: dotnet restore
27+
28+
- name: Build
29+
run: dotnet build --no-restore
30+
31+
- name: Test
32+
run: dotnet test --no-build --verbosity normal
33+
34+
- name: Get version from tag
35+
if: startsWith(github.ref, 'refs/tags/')
36+
id: get_version
37+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
38+
39+
- name: Build Release configuration
40+
if: startsWith(github.ref, 'refs/tags/')
41+
run: dotnet build --configuration Release /p:Version=${{ steps.get_version.outputs.VERSION }} --no-restore
42+
43+
- name: Pack
44+
if: startsWith(github.ref, 'refs/tags/')
45+
run: dotnet pack --no-build --configuration Release /p:Version=${{ steps.get_version.outputs.VERSION }} --output ./nupkgs
46+
47+
- name: Publish to NuGet
48+
if: startsWith(github.ref, 'refs/tags/')
49+
run: |
50+
dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

src/PgKeyValueDB/PgKeyValueDB.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<Version>1.2.3</Version>
87
<PackageReadmeFile>README.md</PackageReadmeFile>
98
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
109
<RepositoryUrl>https://github.com/bjornharrtell/PgKeyValueDB</RepositoryUrl>

0 commit comments

Comments
 (0)