-
Notifications
You must be signed in to change notification settings - Fork 148
56 lines (48 loc) · 1.73 KB
/
release.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
name: Release
on:
push:
branches:
- main
- dev
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-and-release:
runs-on: windows-latest # Build on Windows to ensure .NET Framework targets
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read version from csproj
id: extract_version
if: github.ref == 'refs/heads/main'
run: |
VERSION=$(grep '<VersionPrefix>' src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj | sed 's/.*<VersionPrefix>\(.*\)<\/VersionPrefix>.*/\1/')
echo "VERSION=$VERSION" >> $GITHUB_ENV
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists"
exit 1
fi
- name: Run build
run: ./Build.ps1 -SkipTests
shell: pwsh
- name: Get last commit message
id: last_commit
if: success() && github.ref == 'refs/heads/main'
run: |
git log -1 --pretty=%B > last_commit_message.txt
# Create GitHub release only on main branch (latest release)
- name: Create Release
if: github.ref == 'refs/heads/main' && success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create v${{ env.VERSION }} \
--title "v${{ env.VERSION }}" \
--notes "$(cat last_commit_message.txt)" \
artifacts/*.nupkg artifacts/*.snupkg
- name: Publish to nuget.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
nuget push artifacts\*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }}