-
Notifications
You must be signed in to change notification settings - Fork 18
62 lines (56 loc) · 2.1 KB
/
publish.yml
File metadata and controls
62 lines (56 loc) · 2.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
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
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
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: Publish NuPkg Files
run: dotnet nuget push "$GITHUB_WORKSPACE/packages/*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
- 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 }}"