-
Notifications
You must be signed in to change notification settings - Fork 19
73 lines (66 loc) · 2.42 KB
/
Copy pathpublish.yml
File metadata and controls
73 lines (66 loc) · 2.42 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
name: Publish NuGet Packages
on:
workflow_dispatch:
inputs:
version:
description: 'Package Version'
required: true
default: ''
workflow_run:
workflows: ["Code Validation"]
branches: [main]
types: [completed]
jobs:
publish:
name: Publish NuGet
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success' &&
!contains(github.event.workflow_run.head_commit.message, '[skip publish]'))
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute Next Version
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
latest=$(git tag --list 'v*' --sort=-version:refname | head -n 1)
if [ -z "$latest" ]; then
next="1.0.0"
else
version="${latest#v}"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
patch=$(echo "$version" | cut -d. -f3)
next="${major}.${minor}.$((patch + 1))"
fi
echo "version=${next}" >> "$GITHUB_OUTPUT"
fi
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Pack Solution
run: dotnet pack -p:PackageOutputPath="${GITHUB_WORKSPACE}/packages" -p:IncludeSymbols=false -p:RepositoryCommit=${GITHUB_SHA} -p:PackageVersion="${{ steps.version.outputs.version }}" -c Release
- name: NuGet login (OIDC)
id: nuget-login
uses: NuGet/login@v1
with:
user: jaredpar
- name: Publish NuPkg Files
run: dotnet nuget push "$GITHUB_WORKSPACE/packages/*.nupkg" --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create Tag and Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.version.outputs.version }}" \
--title "Release v${{ steps.version.outputs.version }}" \
--notes "Create release ${{ steps.version.outputs.version }}"