Skip to content

Commit ce069c1

Browse files
authored
Create github release on publish
1 parent 8c9e633 commit ce069c1

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ name: Publish
55

66
on: [workflow_dispatch]
77

8+
permissions:
9+
packages: write
10+
contents: write
11+
812
jobs:
913
build:
1014

@@ -29,3 +33,28 @@ jobs:
2933
run: dotnet test --no-build --verbosity normal
3034
- name: Publish
3135
run: dotnet nuget push **/*.nupkg --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate
36+
- name: Prepare release artifacts
37+
id: package
38+
run: |
39+
FILES=$(find . -name "*.nupkg" -o -name "*.snupkg" | grep -v '\.symbols\.nupkg')
40+
echo "files<<EOF" >> $GITHUB_OUTPUT
41+
echo "$FILES" >> $GITHUB_OUTPUT
42+
echo "EOF" >> $GITHUB_OUTPUT
43+
44+
VERSION=$(basename $(echo "$FILES" | grep '\.nupkg$' | head -n 1) | sed -E 's/.*\.([0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.]+)?)\.nupkg/\1/')
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
47+
if [[ "$VERSION" == *-* ]]; then
48+
echo "prerelease=true" >> $GITHUB_OUTPUT
49+
else
50+
echo "prerelease=false" >> $GITHUB_OUTPUT
51+
fi
52+
- name: Create GitHub Release
53+
uses: elgohr/Github-Release-Action@v5
54+
with:
55+
title: v${{ steps.package.outputs.version }}
56+
tag: v${{ steps.package.outputs.version }}
57+
filename: ${{ steps.package.outputs.files }}
58+
prerelease: ${{ steps.package.outputs.prerelease }}
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)