-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (59 loc) · 1.9 KB
/
template-publish-package.yml
File metadata and controls
73 lines (59 loc) · 1.9 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: pipeline ci/cd - publish federation package
on:
workflow_call:
inputs:
working_directory:
description: project directory to restore/build/pack
required: true
type: string
dotnet_version:
description: .NET SDK version
required: false
type: string
default: 9.0.x
publish_package:
description: if false, runs restore/build/pack without pushing
required: false
type: boolean
default: true
secrets:
NUGET_API_KEY:
required: true
jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: setup gitversion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: semantic versioning
uses: gittools/actions/gitversion/execute@v0
id: gitversion
- name: setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet_version }}
- name: restore dependencies
run: dotnet restore
- name: build
run: dotnet build --configuration Release --no-restore
- name: test
run: dotnet test --configuration Release --no-restore --no-build
- name: set version and pack
id: pack
run: |
VERSION="${{ steps.gitversion.outputs.semVer }}"
echo "use version: $VERSION"
dotnet pack -c Release -p:PackageVersion=$VERSION -o ./output --no-build
echo "package_version=$VERSION" >> $GITHUB_OUTPUT
- name: push package to nuget
if: ${{ inputs.publish_package }}
run: dotnet nuget push ./output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate