-
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (74 loc) · 2.88 KB
/
Copy pathpublish-release.yml
File metadata and controls
84 lines (74 loc) · 2.88 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
name: Publish Release
on:
workflow_call:
inputs:
solution:
description: "Solution file name"
required: true
type: string
dotnetVersion:
description: ".NET SDK version(s)"
required: true
type: string
hasTests:
description: "Run tests before publish"
required: false
default: true
type: boolean
buildConfiguration:
description: "Build configuration. When 'auto', derived from release tag (vN.* → Release EFN)."
required: false
default: "Release"
type: string
permissions:
contents: write
jobs:
resolve:
runs-on: ubuntu-latest
outputs:
configuration: ${{ steps.cfg.outputs.configuration }}
dotnet_version: ${{ steps.cfg.outputs.dotnet_version }}
version: ${{ steps.cfg.outputs.version }}
steps:
- name: Resolve from tag
id: cfg
run: |
TAG="${{ github.event.release.tag_name }}"
VERSION="${TAG#v}"
if [ "${{ inputs.buildConfiguration }}" = "auto" ]; then
MAJOR="${VERSION%%.*}"
echo "configuration=Release EF${MAJOR}" >> "$GITHUB_OUTPUT"
echo "dotnet_version=${MAJOR}.0.x" >> "$GITHUB_OUTPUT"
else
echo "configuration=${{ inputs.buildConfiguration }}" >> "$GITHUB_OUTPUT"
{
echo "dotnet_version<<EOF"
echo "${{ inputs.dotnetVersion }}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
publish:
needs: [resolve]
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ needs.resolve.outputs.dotnet_version }}
- name: Restore
run: dotnet restore ${{ inputs.solution }} -p:Configuration="${{ needs.resolve.outputs.configuration }}"
- name: Build
run: dotnet build ${{ inputs.solution }} --configuration "${{ needs.resolve.outputs.configuration }}" --no-restore /p:Version=${{ needs.resolve.outputs.version }} /p:InformationalVersion=${{ needs.resolve.outputs.version }}
- name: Test
if: inputs.hasTests == true
run: dotnet test --solution ${{ inputs.solution }} --no-build --configuration "${{ needs.resolve.outputs.configuration }}" --no-restore
- name: Pack
run: dotnet pack ${{ inputs.solution }} --configuration "${{ needs.resolve.outputs.configuration }}" --no-build -o artifacts /p:Version=${{ needs.resolve.outputs.version }} /p:InformationalVersion=${{ needs.resolve.outputs.version }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: artifacts/**/*.nupkg