|
| 1 | +# Publishing EtabSharp to NuGet |
| 2 | + |
| 3 | +This guide explains how to publish the EtabSharp NuGet package and the CI/CD setup. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- GitHub repository with admin access |
| 8 | +- NuGet.org account (create at https://www.nuget.org/users/account/LogOn) |
| 9 | + |
| 10 | +## Step 1: Create NuGet API Key |
| 11 | + |
| 12 | +1. Go to https://www.nuget.org/account/apikeys |
| 13 | +2. Click **Create** to generate a new API key |
| 14 | +3. Give it a name like "EtabSharp-CI-CD" and set expiration (optional) |
| 15 | +4. Copy the generated key (you won't see it again) |
| 16 | + |
| 17 | +## Step 2: Add GitHub Secret |
| 18 | + |
| 19 | +1. Go to your GitHub repository: https://github.com/tadodev/EtabSharp |
| 20 | +2. Navigate to **Settings** ? **Secrets and variables** ? **Actions** |
| 21 | +3. Click **New repository secret** |
| 22 | +4. Name: `NUGET_API_KEY` |
| 23 | +5. Value: Paste the API key from Step 1 |
| 24 | +6. Click **Add secret** |
| 25 | + |
| 26 | +## Step 3: Create a Release |
| 27 | + |
| 28 | +The CI/CD pipeline is triggered when you create a Git tag in the format `v*` (e.g., `v0.1.0-beta`, `v1.0.0`). |
| 29 | + |
| 30 | +### Option A: Using Git Command Line |
| 31 | + |
| 32 | +For the first beta release: |
| 33 | +```bash |
| 34 | +git tag v0.1.0-beta |
| 35 | +git push origin v0.1.0-beta |
| 36 | +``` |
| 37 | + |
| 38 | +For future releases: |
| 39 | +```bash |
| 40 | +git tag v1.0.0 |
| 41 | +git push origin v1.0.0 |
| 42 | +``` |
| 43 | + |
| 44 | +### Option B: Using GitHub Web Interface |
| 45 | + |
| 46 | +1. Go to your repository's **Releases** page |
| 47 | +2. Click **Draft a new release** |
| 48 | +3. Tag version: Enter `v0.1.0-beta` (for first release) or `v1.0.0` for stable versions |
| 49 | +4. Release title: Enter `Release v0.1.0-beta` |
| 50 | +5. Check "Set as a pre-release" for beta/rc versions |
| 51 | +6. Add release notes describing changes |
| 52 | +7. Click **Publish release** |
| 53 | + |
| 54 | +## What Happens Automatically |
| 55 | + |
| 56 | +When you create a tag matching `v*`: |
| 57 | + |
| 58 | +1. ? GitHub Actions checks out your code |
| 59 | +2. ? Builds the project in Release mode |
| 60 | +3. ? Runs all tests |
| 61 | +4. ? Extracts version from tag |
| 62 | +5. ? Updates the project version in `.csproj` |
| 63 | +6. ? Packs the NuGet package |
| 64 | +7. ? Publishes to NuGet.org |
| 65 | +8. ? Creates a GitHub Release (marked as prerelease for beta versions) |
| 66 | + |
| 67 | +## Monitoring the Build |
| 68 | + |
| 69 | +1. Go to your repository's **Actions** tab |
| 70 | +2. Select the **Publish NuGet Package** workflow |
| 71 | +3. Monitor the build progress in real-time |
| 72 | +4. View detailed logs if any step fails |
| 73 | + |
| 74 | +## Versioning Strategy |
| 75 | + |
| 76 | +### Semantic Versioning with Prerelease Indicators |
| 77 | + |
| 78 | +- `v0.1.0-beta` - Beta release (current) |
| 79 | +- `v0.1.0-rc.1` - Release candidate |
| 80 | +- `v1.0.0` - Major version 1.0 (stable) |
| 81 | +- `v1.0.1` - Patch version (bug fixes) |
| 82 | +- `v1.1.0` - Minor version (new features) |
| 83 | +- `v2.0.0` - Major version (breaking changes) |
| 84 | + |
| 85 | +The workflow automatically detects prerelease versions (containing `-`) and marks the GitHub release appropriately. |
| 86 | + |
| 87 | +### Updating Release Notes |
| 88 | + |
| 89 | +Update your package release notes in `src/EtabSharp/EtabSharp.csproj` before each release: |
| 90 | + |
| 91 | +```xml |
| 92 | +<PackageReleaseNotes> |
| 93 | + v0.1.0-beta - Initial beta release |
| 94 | + - Added feature X |
| 95 | + - Fixed bug Y |
| 96 | +</PackageReleaseNotes> |
| 97 | +``` |
| 98 | + |
| 99 | +## Continuous Integration (Tests) |
| 100 | + |
| 101 | +The `Tests` workflow automatically runs on: |
| 102 | +- Every push to `master`, `main`, or `develop` branches |
| 103 | +- Every pull request to these branches |
| 104 | + |
| 105 | +This ensures code quality before merging or publishing. |
| 106 | + |
| 107 | +## Manual Local Testing Before Publishing |
| 108 | + |
| 109 | +```bash |
| 110 | +# Build the project |
| 111 | +dotnet build -c Release |
| 112 | + |
| 113 | +# Run tests |
| 114 | +dotnet test -c Release |
| 115 | + |
| 116 | +# Pack the NuGet package |
| 117 | +dotnet pack src/EtabSharp/EtabSharp.csproj -c Release -o ./nuget |
| 118 | + |
| 119 | +# Verify the package (optional) |
| 120 | +dotnet nuget locals all --list |
| 121 | +``` |
| 122 | + |
| 123 | +## Troubleshooting |
| 124 | + |
| 125 | +### Workflow Failed? |
| 126 | + |
| 127 | +1. Check the **Actions** tab for error logs |
| 128 | +2. Common issues: |
| 129 | + - API key expired ? Generate a new one and update the secret |
| 130 | + - Tests failed ? Fix the issues and push new code |
| 131 | + - ETABSv1.dll not found ? This is expected in CI (mock it in tests) |
| 132 | + |
| 133 | +### Package Not on NuGet? |
| 134 | + |
| 135 | +- Check https://www.nuget.org/packages/EtabSharp/ |
| 136 | +- It may take a few minutes to appear after publishing |
| 137 | +- Beta versions will show under "Pre-release versions" |
| 138 | +- Verify via: `dotnet package search EtabSharp --prerelease` |
| 139 | + |
| 140 | +## Using Your Published Package |
| 141 | + |
| 142 | +Once published, install the beta version: |
| 143 | + |
| 144 | +```bash |
| 145 | +dotnet add package EtabSharp --version 0.1.0-beta |
| 146 | +``` |
| 147 | + |
| 148 | +Or in `.csproj`: |
| 149 | + |
| 150 | +```xml |
| 151 | +<PackageReference Include="EtabSharp" Version="0.1.0-beta" /> |
| 152 | +``` |
| 153 | + |
| 154 | +For future stable releases: |
| 155 | +```bash |
| 156 | +dotnet add package EtabSharp --version 1.0.0 |
| 157 | +``` |
| 158 | + |
| 159 | +## Additional Resources |
| 160 | + |
| 161 | +- [NuGet.org Policies](https://learn.microsoft.com/en-us/nuget/policies/policy-faq) |
| 162 | +- [Semantic Versioning](https://semver.org/) |
| 163 | +- [GitHub Actions Documentation](https://docs.github.com/actions) |
| 164 | +- [NuGet Package Best Practices](https://learn.microsoft.com/en-us/nuget/create-packages/package-authoring-best-practices) |
0 commit comments