-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (57 loc) · 2.11 KB
/
publish-package.yml
File metadata and controls
70 lines (57 loc) · 2.11 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
name: publish-package
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [main]
paths-ignore:
- 'test/**'
env:
PipelineEnvironment: true
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setting up build version
run: |
echo "BUILD_VERSION=4.0.${GITHUB_RUN_NUMBER}" >> "${GITHUB_ENV}"
- uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- run: dotnet restore
name: Install dependencies
- run: dotnet build --configuration Release --no-restore
name: Build
- name: Test
id: test
run: |
dotnet test test/Serilog.Sinks.XUnit.Injectable.Tests.csproj --verbosity Normal
- name: Pack
run: dotnet pack --no-build --configuration Release --output .
- name: Publish to nuGet
run: dotnet nuget push **/*.nupkg --source 'https://api.nuget.org/v3/index.json' --api-key ${{ secrets.NUGET__TOKEN }} --skip-duplicate
- name: Add GitHub NuGet Source
run: |
dotnet nuget add source https://nuget.pkg.github.com/soenneker/index.json \
--name "github" \
--username "any" \
--password "${{ secrets.GH__TOKEN }}" \
--store-password-in-clear-text
- name: Publish to GitHub Packages
run: |
dotnet nuget push ./*.nupkg \
--source "github" \
--api-key "${{ secrets.GH__TOKEN }}"
- name: Create GitHub Release
run: |
changelog=$(git log -20 --pretty=format:"- %s")
tag_name="v${BUILD_VERSION}"
jq -n --arg tag_name "$tag_name" --arg name "$tag_name" --arg body "$changelog" \
'{tag_name:$tag_name,name:$name,body:$body,draft:false,prerelease:false}' > payload.json
curl -s -X POST \
-H "Authorization: Bearer ${{ secrets.GH__TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/releases \
-d @payload.json