Skip to content

Commit 1c0d0b0

Browse files
authored
Merge pull request #16 from liamgold/feature/code-quality-improvements
Code quality improvements and bug fixes
2 parents 2809af3 + a142959 commit 1c0d0b0

24 files changed

+614
-82
lines changed

.github/RELEASE.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Release Process
2+
3+
This document describes how to publish a new version to NuGet.
4+
5+
## Prerequisites
6+
7+
1. **Configure Trusted Publishing on NuGet.org** (one-time setup):
8+
- Go to: https://www.nuget.org/account/Packages
9+
- Find package: `XperienceCommunity.Sustainability`
10+
- Click "Manage" → "Trusted publishers" → "Add trusted publisher"
11+
- Fill in the form:
12+
- **Policy Name**: Any name (e.g., "GitHub Actions Auto-Publish")
13+
- **Package Owner**: `liamgold` (should be pre-selected)
14+
- **Repository Owner**: `liamgold`
15+
- **Repository**: `xperience-community-sustainability`
16+
- **Workflow File**: `publish.yml`
17+
- **Environment**: (leave blank)
18+
- Click "Create"
19+
20+
This allows GitHub Actions to publish without API keys!
21+
22+
## Publishing a New Version
23+
24+
### 1. Update Version Number
25+
Edit `src/XperienceCommunity.Sustainability.csproj`:
26+
```xml
27+
<Version>2.1.0</Version>
28+
```
29+
30+
### 2. Commit and Push to Main
31+
```bash
32+
git add src/XperienceCommunity.Sustainability.csproj
33+
git commit -m "Bump version to 2.1.0"
34+
git push origin main
35+
```
36+
37+
### 3. Create GitHub Release (creates tag automatically)
38+
1. Go to: https://github.com/liamgold/xperience-community-sustainability/releases/new
39+
2. Choose tag: `v2.1.0`
40+
3. Release title: `v2.1.0`
41+
4. Add release notes describing changes
42+
5. Click "Publish release"
43+
44+
### 5. Automatic Publishing
45+
The GitHub Action will automatically:
46+
- Build the project
47+
- Create the NuGet package
48+
- Publish to NuGet.org
49+
50+
Monitor the workflow at:
51+
https://github.com/liamgold/xperience-community-sustainability/actions
52+
53+
## Workflow Triggers
54+
55+
- **CI (Build & Test)**: Runs on every push to main and on PRs
56+
- **Publish to NuGet**: Runs only when a GitHub Release is published
57+
58+
## Version Strategy
59+
60+
Follow [Semantic Versioning](https://semver.org/):
61+
- **Major** (3.0.0): Breaking changes
62+
- **Minor** (2.1.0): New features, backward compatible
63+
- **Patch** (2.0.1): Bug fixes, backward compatible
64+
65+
## Troubleshooting
66+
67+
### "Package already exists" error
68+
The workflow includes `--skip-duplicate` to handle this gracefully.
69+
70+
### "Authentication failed" or "403 Forbidden"
71+
Make sure Trusted Publishing is configured correctly on NuGet.org (see Prerequisites above).
72+
Verify the owner, repository, and workflow name exactly match.
73+
74+
### Want to publish manually?
75+
```bash
76+
dotnet pack src/XperienceCommunity.Sustainability.csproj --configuration Release
77+
dotnet nuget push src/bin/Release/*.nupkg --api-key YOUR_KEY --source https://api.nuget.org/v3/index.json
78+
```

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
runs-on: windows-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup .NET
15+
uses: actions/setup-dotnet@v4
16+
with:
17+
dotnet-version: 8.0.x
18+
19+
- name: Restore dependencies
20+
run: dotnet restore
21+
22+
- name: Build
23+
run: dotnet build --configuration Release --no-restore
24+
25+
- name: Run tests (if any)
26+
run: dotnet test --no-build --configuration Release --verbosity normal
27+
continue-on-error: true # Continue even if no tests exist

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish to NuGet
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
11+
jobs:
12+
publish:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: 8.0.x
22+
23+
- name: Restore dependencies
24+
run: dotnet restore
25+
26+
- name: Build
27+
run: dotnet build src/XperienceCommunity.Sustainability.csproj --configuration Release --no-restore
28+
29+
- name: Pack
30+
run: dotnet pack src/XperienceCommunity.Sustainability.csproj --configuration Release --no-build --output ./nupkg
31+
32+
- name: Publish to NuGet using Trusted Publishing
33+
run: dotnet nuget push ./nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,7 @@ FodyWeavers.xsd
416416
.idea/usage.statistics.xml
417417
.idea/dictionaries/
418418
.idea/shelf/
419-
/examples/DancingGoat/App_Data/playwright
419+
/examples/DancingGoat/App_Data/playwright
420+
421+
# Claude Code
422+
.claude/

0 commit comments

Comments
 (0)