-
Notifications
You must be signed in to change notification settings - Fork 13
88 lines (75 loc) · 3.1 KB
/
publish.yml
File metadata and controls
88 lines (75 loc) · 3.1 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Publish to NuGet
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Package version (leave empty to use csproj version)"
required: false
type: string
jobs:
publish:
runs-on: ubuntu-latest
environment: release
timeout-minutes: 15
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Determine version
id: version
env:
TAG_NAME: ${{ github.event.release.tag_name }}
INPUT_VERSION: ${{ inputs.version }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == "release" ]]; then
VERSION="$TAG_NAME"
VERSION="${VERSION#v}"
VERSION="${VERSION#.}"
elif [[ -n "$INPUT_VERSION" ]]; then
VERSION="$INPUT_VERSION"
else
VERSION=$(grep -oP '<Version>\K[^<]+' src/Graphify.Cli/Graphify.Cli.csproj)
fi
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "❌ Invalid version: '$VERSION'"; exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "📦 Publishing version: $VERSION"
- name: Restore dependencies
run: dotnet restore graphify-dotnet.slnx
- name: Build in Release mode
run: dotnet build graphify-dotnet.slnx -c Release --no-restore -p:Version=${{ steps.version.outputs.version }}
- name: Ensure xunit configuration is in place
run: |
mkdir -p src/tests/Graphify.Tests/bin/Release/net10.0
mkdir -p src/tests/Graphify.Integration.Tests/bin/Release/net10.0
cp src/tests/Graphify.Tests/xunit.runner.json src/tests/Graphify.Tests/bin/Release/net10.0/xunit.runner.json
cp src/tests/Graphify.Tests/xunit.runner.json src/tests/Graphify.Integration.Tests/bin/Release/net10.0/xunit.runner.json
- name: Run all tests
run: dotnet test graphify-dotnet.slnx -c Release --no-build --verbosity normal
- name: Pack NuGet packages
run: |
dotnet pack src/Graphify/Graphify.csproj -c Release --no-build -p:Version=${{ steps.version.outputs.version }} -o ./nupkg
dotnet pack src/Graphify.Sdk/Graphify.Sdk.csproj -c Release --no-build -p:Version=${{ steps.version.outputs.version }} -o ./nupkg
dotnet pack src/Graphify.Cli/Graphify.Cli.csproj -c Release --no-build -p:Version=${{ steps.version.outputs.version }} -o ./nupkg
- name: NuGet login (OIDC trusted publishing)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Push to NuGet.org
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v4
with:
name: nupkg
path: ./nupkg/*.nupkg