-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add NuGet package support #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: NuGet Publish | ||
|
|
||
| on: | ||
| release: | ||
| types: [ published ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
|
|
||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
|
|
||
| - name: Build | ||
| run: dotnet build --no-restore --configuration Release | ||
|
|
||
| - name: Test | ||
| run: dotnet test --no-build --configuration Release --verbosity normal | ||
|
|
||
| - name: Extract version from tag | ||
| id: version | ||
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Pack | ||
| run: dotnet pack src/MiniPdf/MiniPdf.csproj --no-build --configuration Release -p:PackageVersion=${{ steps.version.outputs.VERSION }} --output ./nupkg | ||
|
Comment on lines
+32
to
+37
|
||
|
|
||
| - name: Push to NuGet.org | ||
| run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,9 +9,18 @@ | |||||
| <!-- NuGet Package Metadata --> | ||||||
| <PackageId>MiniPdf</PackageId> | ||||||
| <Version>0.1.0</Version> | ||||||
| <Authors>shps951023</Authors> | ||||||
| <Description>A minimal, zero-dependency .NET library for generating PDF documents from text and Excel files.</Description> | ||||||
| <PackageTags>pdf;excel;xlsx;converter;text</PackageTags> | ||||||
| <PackageTags>pdf;excel;xlsx;converter;text;minipdf</PackageTags> | ||||||
| <PackageLicenseExpression>MIT</PackageLicenseExpression> | ||||||
| <PackageProjectUrl>https://github.com/shps951023/MiniPdf</PackageProjectUrl> | ||||||
| <RepositoryUrl>https://github.com/shps951023/MiniPdf.git</RepositoryUrl> | ||||||
| <RepositoryType>git</RepositoryType> | ||||||
| <PackageReadmeFile>README.md</PackageReadmeFile> | ||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <ItemGroup> | ||||||
| <None Include="..\..\README.md" Pack="true" PackagePath="\" /> | ||||||
|
||||||
| <None Include="..\..\README.md" Pack="true" PackagePath="\" /> | |
| <None Include="..\..\README.md" Pack="true" PackagePath="" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VERSION=${GITHUB_REF_NAME#v}assumes the tag is prefixed withvand doesn't validate the result. If the release tag is missing the prefix (or is justv), the version passed todotnet packcan become invalid/empty and fail in a confusing way. Consider adding a small validation step to assert the extracted version is non-empty and matches an expected NuGet/SemVer pattern before packing.