-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (40 loc) · 1.66 KB
/
publish-dotnet.yml
File metadata and controls
52 lines (40 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Publish .NET Library to NuGet
on:
release:
types:
- published
jobs:
publish-prism:
name: Build and publish Prism library to NuGet
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v4
- name: Set up .NET environment
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0' # Adjust if using a different version
- name: Create Generated directory
run: mkdir -p Generated
- name: Restore dependencies
run: dotnet restore Prism.csproj
- name: Set Version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)" >> $GITHUB_ENV
echo "MINOR_VERSION=$(echo $VERSION | cut -d. -f2)" >> $GITHUB_ENV
- name: Generate Version File
run: |
echo "namespace Polypheny.Prism { public static class Version { public const string Major = \"$MAJOR_VERSION\"; public const string Minor = \"$MINOR_VERSION\"; } }" > Generated/Version.cs
# Assumes Generated directory is committed or added during build
- name: Build the project
run: dotnet build Prism.csproj --no-restore -c Release
- name: Test the project
run: dotnet test Prism.csproj --no-build -c Release
- name: Pack the project
run: dotnet pack Prism.csproj --no-build -c Release --output ./nupkgs
- name: Publish to NuGet
run: dotnet nuget push "./nupkgs/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate