Skip to content

Commit 7e2b289

Browse files
authored
Created Release
1 parent 56ed6a6 commit 7e2b289

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Publish NuGet Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '0.*.*'
7+
8+
env:
9+
ARTIFACTS_PATH: 'artifacts/packages'
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
global-json-file: global.json
23+
24+
- name: Extract version from tag
25+
id: get_version
26+
run: |
27+
VERSION=${GITHUB_REF#refs/tags/}
28+
# Extract numeric version (e.g., "0.1.0" from "0.1.0-preview")
29+
NUMERIC_VERSION=$(echo $VERSION | sed 's/-.*$//')
30+
# Ensure we have 4 parts for AssemblyVersion (add .0 if needed)
31+
ASSEMBLY_VERSION=$(echo $NUMERIC_VERSION | awk -F. '{printf "%s.%s.%s.%s", $1, $2, $3, ($4 != "" ? $4 : "0")}')
32+
33+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
34+
echo "NUMERIC_VERSION=$NUMERIC_VERSION" >> $GITHUB_OUTPUT
35+
echo "ASSEMBLY_VERSION=$ASSEMBLY_VERSION" >> $GITHUB_OUTPUT
36+
echo "Full version: $VERSION"
37+
echo "Numeric version: $NUMERIC_VERSION"
38+
echo "Assembly version: $ASSEMBLY_VERSION"
39+
40+
- name: Restore dependencies
41+
run: dotnet restore
42+
43+
- name: Build solution
44+
run: |
45+
dotnet build \
46+
--configuration Release \
47+
--no-restore \
48+
-p:Version=${{ steps.get_version.outputs.VERSION }} \
49+
-p:AssemblyVersion=${{ steps.get_version.outputs.ASSEMBLY_VERSION }} \
50+
-p:FileVersion=${{ steps.get_version.outputs.NUMERIC_VERSION }} \
51+
-p:InformationalVersion=${{ steps.get_version.outputs.VERSION }}
52+
53+
- name: Pack NuGet package
54+
run: |
55+
dotnet pack \
56+
--configuration Release \
57+
--no-build \
58+
--output ${{ env.ARTIFACTS_PATH }} \
59+
-p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \
60+
-p:Version=${{ steps.get_version.outputs.VERSION }}
61+
62+
- name: Upload artifacts
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: nuget-packages
66+
path: ${{ env.ARTIFACTS_PATH }}/*.nupkg
67+
68+
- name: Publish to NuGet
69+
run: |
70+
dotnet nuget push "${{ env.ARTIFACTS_PATH }}/*.nupkg" \
71+
--api-key ${{ secrets.NUGET_API_KEY }} \
72+
--source https://api.nuget.org/v3/index.json \
73+
--skip-duplicate

0 commit comments

Comments
 (0)