Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal --logger "trx;LogFileName=test-results.trx"

- name: Pack (verify NuGet package)
run: dotnet pack src/MiniPdf/MiniPdf.csproj --no-build --configuration Release --output ./nupkg

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/nuget-publish.yml
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

Comment on lines +34 to +35
Copy link

Copilot AI Feb 22, 2026

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 with v and doesn't validate the result. If the release tag is missing the prefix (or is just v), the version passed to dotnet pack can 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.

Suggested change
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
run: |
RAW_TAG="${GITHUB_REF_NAME}"
VERSION="${RAW_TAG#v}"
if [ -z "$VERSION" ]; then
echo "Error: Extracted version is empty. Ensure the release tag is of the form 'v<version>' (e.g., 'v1.2.3')."
exit 1
fi
if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
echo "Error: Extracted version '$VERSION' is not a valid SemVer/NuGet version (expected format: MAJOR.MINOR.PATCH[-PRERELEASE])."
exit 1
fi
echo "Using version: $VERSION"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"

Copilot uses AI. Check for mistakes.
- 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
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow sets PackageVersion from the Git tag, but the PR description instructs maintainers to update <Version> in MiniPdf.csproj. As-is, those can diverge (CI packing uses the csproj version, while publishing uses the tag). Consider either (1) relying on the csproj <Version> and dropping the -p:PackageVersion=... override, or (2) adding a validation step that fails if the tag version doesn't match the csproj version, and update the publish instructions accordingly.

Copilot uses AI. Check for mistakes.

- 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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ A minimal, zero-dependency .NET library for generating PDF documents from text a

## Getting Started

### Install via NuGet

```bash
dotnet add package MiniPdf
```

### Requirements

- .NET 9.0 or later
Expand Down
11 changes: 10 additions & 1 deletion src/MiniPdf/MiniPdf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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="\" />
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PackagePath="\" uses a Windows-style separator and can end up creating an unexpected folder name inside the .nupkg on non-Windows platforms. For packing the README at the package root (to match PackageReadmeFile), use an empty PackagePath (or /) instead.

Suggested change
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<None Include="..\..\README.md" Pack="true" PackagePath="" />

Copilot uses AI. Check for mistakes.
</ItemGroup>

</Project>
Loading