Skip to content

Commit 5c71bcb

Browse files
oschwaldclaude
andcommitted
Replace PowerShell release script with bash
The release script no longer publishes to NuGet directly. Instead, publishing is handled by the release.yml GitHub Actions workflow using trusted publishing. Also adds plan.md with manual setup instructions for the GitHub environment and NuGet.org trusted publishing policy. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 89aec05 commit 5c71bcb

File tree

4 files changed

+109
-60
lines changed

4 files changed

+109
-60
lines changed

README.dev.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
To publish the to NuGet:
1+
## Releasing
22

3-
1. Update release notes.
4-
2. Run `.\dev-bin\release.ps1`.
3+
1. Create a release branch from main.
4+
2. Update `releasenotes.md` with the version and today's date.
5+
3. Run `./dev-bin/release.sh`.
6+
4. Approve the release in the GitHub Actions workflow (requires `nuget` environment approval).

dev-bin/release.ps1

Lines changed: 0 additions & 57 deletions
This file was deleted.

dev-bin/release.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
set -eu -o pipefail
4+
5+
# Check that we're not on the main branch
6+
current_branch=$(git branch --show-current)
7+
if [ "$current_branch" = "main" ]; then
8+
echo "Error: Releases should not be done directly on the main branch."
9+
echo "Please create a release branch and run this script from there."
10+
exit 1
11+
fi
12+
13+
# Fetch latest changes and check that we're not behind origin/main
14+
echo "Fetching from origin..."
15+
git fetch origin
16+
17+
if ! git merge-base --is-ancestor origin/main HEAD; then
18+
echo "Error: Current branch is behind origin/main."
19+
echo "Please merge or rebase with origin/main before releasing."
20+
exit 1
21+
fi
22+
23+
changelog=$(cat releasenotes.md)
24+
25+
regex='([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?) \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)'
26+
27+
if [[ ! $changelog =~ $regex ]]; then
28+
echo "Could not find version/date in releasenotes.md!"
29+
exit 1
30+
fi
31+
32+
version="${BASH_REMATCH[1]}"
33+
date="${BASH_REMATCH[3]}"
34+
35+
if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then
36+
echo "$date is not today!"
37+
exit 1
38+
fi
39+
40+
tag="v$version"
41+
42+
if [ -n "$(git status --porcelain)" ]; then
43+
echo ". is not clean." >&2
44+
exit 1
45+
fi
46+
47+
# Update version in csproj
48+
sed -i "s|<VersionPrefix>[^<]*</VersionPrefix>|<VersionPrefix>$version</VersionPrefix>|" MaxMind.Db/MaxMind.Db.csproj
49+
50+
# Build and test
51+
dotnet build -c Release
52+
dotnet test -c Release
53+
54+
echo $'\nDiff:'
55+
git diff
56+
57+
read -e -p "Commit changes and create release? (y/n) " should_continue
58+
59+
if [ "$should_continue" != "y" ]; then
60+
echo "Aborting"
61+
exit 1
62+
fi
63+
64+
git commit -m "Prepare for $version" -a
65+
66+
git push
67+
68+
gh release create --target "$(git branch --show-current)" -t "$version" "$tag"

plan.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# NuGet Trusted Publishing Setup
2+
3+
This document describes the manual setup required to enable NuGet trusted publishing.
4+
5+
## 1. Create GitHub Environment with Approval
6+
7+
1. Go to repository **Settings → Environments**
8+
2. Click **New environment**
9+
3. Name it `nuget`
10+
4. Configure protection rules:
11+
- Check **Required reviewers**
12+
- Add appropriate team members or individuals who can approve releases
13+
- Optionally set **Wait timer** (e.g., 5 minutes) for additional safety
14+
5. Click **Save protection rules**
15+
16+
## 2. Create NuGet.org Trusted Publishing Policy
17+
18+
1. Log into nuget.org with the `maxmind` organization account
19+
2. Navigate to **Account → Trusted Publishing**
20+
3. Click **Add trusted publishing policy**
21+
4. Configure the policy:
22+
- **Repository Owner**: `maxmind`
23+
- **Repository**: `MaxMind-DB-Reader-dotnet`
24+
- **Workflow File**: `release.yml`
25+
- **Environment**: `nuget`
26+
5. Select `maxmind` as the package owner
27+
6. Save the policy
28+
29+
Note: The policy will be in "pending" state until the first successful publish, then becomes permanently active.
30+
31+
## Security Benefits
32+
33+
- No long-lived NuGet API keys stored in GitHub secrets
34+
- OIDC tokens are short-lived (~1 hour) and single-use
35+
- Environment protection rules provide approval workflow before publishing
36+
- Clear audit trail of who approved each release

0 commit comments

Comments
 (0)