-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (57 loc) · 1.73 KB
/
pack.yml
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
name: publish-nuget
on:
workflow_run:
workflows: [ "Build" ]
types: [ requested ]
branches: [ master ]
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
env:
BUILD_CONFIG: 'Release'
jobs:
pack:
runs-on: ubuntu-latest
steps:
- name: Determine version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
else
echo "VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
fi
echo "$GITHUB_ENV"
- name: 'Validate SemVer'
run: |
if [[ ! "$VERSION" =~ ^([0-9]+\.){2}[0-9]+$ ]]; then
echo "The version does not match the SemVer format (X.Y.Z). Please provide a valid version."
exit 1
fi
- name: 'Print version'
run: |
echo "$VERSION"
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
- name: Pack
run: |
dotnet pack \
--output ./artifacts \
--configuration $BUILD_CONFIG \
/p:PackageVersion=${{ env.VERSION }}
- name: Install dotnet-validate
run: dotnet tool install --global dotnet-validate --version 0.0.1-preview.304
- name: Validate NuGet package
run: dotnet-validate package local ./artifacts/**.nupkg
- name: Publish packages
run: |
dotnet nuget push ./artifacts/**.nupkg \
--source 'https://api.nuget.org/v3/index.json' \
--api-key ${{secrets.NUGET_TOKEN}} \
--skip-duplicate \