Skip to content

Commit b700a7d

Browse files
committed
Pipeline to publish on nuget.org
1 parent d4174a6 commit b700a7d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will build, pack and deploy the solution on Nuget
2+
3+
name: 'publish_nuget.yml'
4+
5+
on:
6+
push:
7+
tags:
8+
- '[0-9]+.[0-9]+'
9+
branches:
10+
- master
11+
12+
jobs:
13+
publish:
14+
if: startsWith(github.ref, 'refs/tags/') && github.ref_type == 'tag' && github.ref_name != ''
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Ensure tag is on master
19+
run: |
20+
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})
21+
if ! git merge-base --is-ancestor $TAG_COMMIT origin/master; then
22+
echo "Tag is not on master branch. Skipping publish."
23+
exit 1
24+
fi
25+
- name: Setup .NET 8.
26+
uses: actions/setup-dotnet@v4
27+
with:
28+
dotnet-version: '8.0.x'
29+
- name: Build
30+
run: dotnet build --configuration Release
31+
- name: Pack
32+
run: dotnet pack src/Html2OpenXml/HtmlToOpenXml.csproj --configuration Release --output ./nupkg
33+
- name: Push nuget to NuGet.org
34+
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
35+
- name: Create Release and Upload Artifact to Release
36+
run: gh release create ${{github.ref_name}} -t "Release ${{github.ref_name}}" *.nupkg --generate-notes --draft

0 commit comments

Comments
 (0)