Skip to content

Commit fbc0e94

Browse files
committed
Publish nuget from action
1 parent fc08093 commit fbc0e94

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

‎.github/workflows/build.yml‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,42 @@ jobs:
2525
- uses: actions/upload-artifact@v4
2626
with:
2727
name: nupkg
28-
path: "**/*.nupkg"
28+
path: src/ExcelNumberFormat/bin/Release/*.nupkg
29+
if-no-files-found: error
30+
31+
publish:
32+
needs: build
33+
if: startsWith(github.ref, 'refs/tags/v')
34+
runs-on: ubuntu-latest
35+
permissions:
36+
id-token: write
37+
steps:
38+
- uses: actions/download-artifact@v4
39+
with:
40+
name: nupkg
41+
path: nupkg
42+
43+
- name: Verify tag matches package version
44+
run: |
45+
shopt -s nullglob
46+
files=(nupkg/*.nupkg)
47+
if [ ${#files[@]} -ne 1 ]; then
48+
echo "Expected exactly one nupkg, found ${#files[@]}"; exit 1
49+
fi
50+
expected="nupkg/ExcelNumberFormat.${GITHUB_REF_NAME#v}.nupkg"
51+
if [ "${files[0]}" != "$expected" ]; then
52+
echo "Tag $GITHUB_REF_NAME does not match package ${files[0]} (expected $expected). Update VersionPrefix in the csproj."; exit 1
53+
fi
54+
55+
- uses: actions/setup-dotnet@v4
56+
with:
57+
dotnet-version: 10.0.x
58+
59+
- name: NuGet login (trusted publishing)
60+
id: login
61+
uses: NuGet/login@v1
62+
with:
63+
user: ${{ vars.NUGET_USER }}
64+
65+
- name: Push
66+
run: dotnet nuget push "nupkg/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --skip-duplicate

0 commit comments

Comments
 (0)