-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (56 loc) · 1.86 KB
/
main.yml
File metadata and controls
73 lines (56 loc) · 1.86 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 Package
env:
PROJECT_PATH: src/SharedKernel.Postgres/SharedKernel.Postgres.csproj
OUTPUT_DIR: nupkgs
NUGET_SOURCE: https://api.nuget.org/v3/index.json
on:
push:
branches: [main]
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Restore
run: dotnet restore ${{ env.PROJECT_PATH }}
- name: Build
run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration Release
# - name: Test
# run: dotnet test --no-build --configuration Release --verbosity normal
- name: Pack
run: dotnet pack ${{ env.PROJECT_PATH }} --no-build --configuration Release --output ${{ env.OUTPUT_DIR }}
- name: Publish
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
shell: bash
run: |
set -euo pipefail
if [ -z "${NUGET_API_KEY:-}" ]; then
echo "NUGET_API_KEY secret is not set."
exit 1
fi
shopt -s nullglob
nupkgs=( "${{ env.OUTPUT_DIR }}"/*.nupkg )
snupkgs=( "${{ env.OUTPUT_DIR }}"/*.snupkg )
if [ ${#nupkgs[@]} -eq 0 ]; then
echo "No .nupkg files found in ${{ env.OUTPUT_DIR }}"
ls -la "${{ env.OUTPUT_DIR }}" || true
exit 1
fi
dotnet nuget push "${nupkgs[@]}" \
--api-key "$NUGET_API_KEY" \
--source "${{ env.NUGET_SOURCE }}" \
--skip-duplicate
if [ ${#snupkgs[@]} -gt 0 ]; then
dotnet nuget push "${snupkgs[@]}" \
--api-key "$NUGET_API_KEY" \
--source "${{ env.NUGET_SOURCE }}" \
--skip-duplicate
fi