|
| 1 | +# Publishing to NuGet |
| 2 | + |
| 3 | +This repository includes a GitHub Action workflow that automatically builds, tests, and publishes the NuGet package. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. **NuGet API Key**: You need to create an API key from [NuGet.org](https://www.nuget.org/account/apikeys) |
| 8 | +2. **GitHub Secret**: Add your NuGet API key as a repository secret: |
| 9 | + - Go to repository Settings → Secrets and variables → Actions |
| 10 | + - Click "New repository secret" |
| 11 | + - Name: `NUGET_API_KEY` |
| 12 | + - Value: Your NuGet API key |
| 13 | + |
| 14 | +## Publishing Methods |
| 15 | + |
| 16 | +### Method 1: Automatic Publishing via Git Tags (Recommended) |
| 17 | + |
| 18 | +The workflow automatically triggers when you push a version tag: |
| 19 | + |
| 20 | +```bash |
| 21 | +# Create and push a version tag |
| 22 | +git tag v1.0.0 |
| 23 | +git push origin v1.0.0 |
| 24 | + |
| 25 | +# Or create with annotation |
| 26 | +git tag -a v1.0.0 -m "Release version 1.0.0" |
| 27 | +git push origin v1.0.0 |
| 28 | +``` |
| 29 | + |
| 30 | +The workflow will: |
| 31 | +- Extract version from the tag (e.g., `v1.0.0` → `1.0.0`) |
| 32 | +- Build and test the project |
| 33 | +- Create NuGet package with the version |
| 34 | +- Publish to NuGet.org |
| 35 | +- Create a GitHub Release with the package attached |
| 36 | + |
| 37 | +### Method 2: Manual Publishing via GitHub UI |
| 38 | + |
| 39 | +You can manually trigger the workflow from GitHub: |
| 40 | + |
| 41 | +1. Go to repository → Actions → "Publish NuGet Package" |
| 42 | +2. Click "Run workflow" |
| 43 | +3. Enter the version number (e.g., `1.0.1`) |
| 44 | +4. Click "Run workflow" |
| 45 | + |
| 46 | +## Version Numbering |
| 47 | + |
| 48 | +Follow [Semantic Versioning](https://semver.org/): |
| 49 | +- **MAJOR.MINOR.PATCH** (e.g., 1.2.3) |
| 50 | +- **MAJOR**: Breaking changes |
| 51 | +- **MINOR**: New features (backward compatible) |
| 52 | +- **PATCH**: Bug fixes (backward compatible) |
| 53 | + |
| 54 | +Examples: |
| 55 | +- `v1.0.0` - Initial release |
| 56 | +- `v1.1.0` - Added new feature |
| 57 | +- `v1.1.1` - Bug fix |
| 58 | +- `v2.0.0` - Breaking changes |
| 59 | + |
| 60 | +## Testing Before Publishing |
| 61 | + |
| 62 | +Always test the package build locally before publishing: |
| 63 | + |
| 64 | +```bash |
| 65 | +# Build the project |
| 66 | +dotnet build --configuration Release |
| 67 | + |
| 68 | +# Run tests |
| 69 | +dotnet test --configuration Release |
| 70 | + |
| 71 | +# Create package (without publishing) |
| 72 | +dotnet pack --configuration Release --output ./artifacts |
| 73 | + |
| 74 | +# Inspect the package |
| 75 | +unzip -l ./artifacts/WebNet.LiteGraphExtensions.GraphRepositories.*.nupkg |
| 76 | +``` |
| 77 | + |
| 78 | +## Workflow Details |
| 79 | + |
| 80 | +The GitHub Action workflow (`publish-nuget.yml`) performs these steps: |
| 81 | + |
| 82 | +1. **Checkout**: Gets the repository code |
| 83 | +2. **Setup .NET**: Installs .NET 10.0 |
| 84 | +3. **Extract Version**: Gets version from tag or input |
| 85 | +4. **Restore**: Restores NuGet dependencies |
| 86 | +5. **Build**: Builds in Release configuration |
| 87 | +6. **Test**: Runs all unit tests |
| 88 | +7. **Pack**: Creates NuGet package with metadata |
| 89 | +8. **Publish**: Pushes to NuGet.org |
| 90 | +9. **Artifacts**: Uploads package to GitHub |
| 91 | +10. **Release**: Creates GitHub release (for tag pushes) |
| 92 | + |
| 93 | +## Package Metadata |
| 94 | + |
| 95 | +The package includes: |
| 96 | +- **PackageId**: WebNet.LiteGraphExtensions.GraphRepositories |
| 97 | +- **Title**: LiteGraph Repository Extensions |
| 98 | +- **Description**: Full implementation descriptions |
| 99 | +- **Tags**: litegraph, graph, database, repository, duckdb, fastdb, litedb |
| 100 | +- **License**: MIT |
| 101 | +- **README**: Included in package |
| 102 | +- **Symbols**: Debug symbols included (.snupkg) |
| 103 | + |
| 104 | +## Troubleshooting |
| 105 | + |
| 106 | +### Build Fails |
| 107 | +- Ensure all tests pass locally |
| 108 | +- Check .NET version compatibility |
| 109 | +- Verify all dependencies are restored |
| 110 | + |
| 111 | +### Authentication Fails |
| 112 | +- Verify `NUGET_API_KEY` secret is set correctly |
| 113 | +- Check API key hasn't expired on NuGet.org |
| 114 | +- Ensure API key has "Push" permissions |
| 115 | + |
| 116 | +### Version Already Exists |
| 117 | +- NuGet doesn't allow overwriting versions |
| 118 | +- Increment the version number |
| 119 | +- Delete the tag and recreate with new version |
| 120 | + |
| 121 | +### Package Not Appearing |
| 122 | +- NuGet indexing can take 10-15 minutes |
| 123 | +- Check workflow logs for errors |
| 124 | +- Verify package passed validation |
| 125 | + |
| 126 | +## Updating Package |
| 127 | + |
| 128 | +To publish an update: |
| 129 | + |
| 130 | +```bash |
| 131 | +# Make your changes |
| 132 | +git add . |
| 133 | +git commit -m "Your changes" |
| 134 | +git push |
| 135 | + |
| 136 | +# Create new version tag |
| 137 | +git tag v1.0.1 |
| 138 | +git push origin v1.0.1 |
| 139 | +``` |
| 140 | + |
| 141 | +## Rolling Back |
| 142 | + |
| 143 | +If you need to unlist a version: |
| 144 | + |
| 145 | +1. Go to [NuGet.org](https://www.nuget.org/) |
| 146 | +2. Find your package |
| 147 | +3. Select the version |
| 148 | +4. Click "Unlist" |
| 149 | + |
| 150 | +Note: Unlisted packages can still be installed if version is specified explicitly. |
| 151 | + |
| 152 | +## GitHub Release |
| 153 | + |
| 154 | +Each tagged release creates a GitHub Release with: |
| 155 | +- Release notes (auto-generated from commits) |
| 156 | +- NuGet package (.nupkg) attached |
| 157 | +- Symbols package (.snupkg) attached |
| 158 | + |
| 159 | +View releases at: `https://github.com/YOUR_USERNAME/WebNet.LiteGraphExtensions.GraphRepositories/releases` |
0 commit comments