Skip to content

Commit 0d3dcf5

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 7e8b186 commit 0d3dcf5

File tree

3 files changed

+73
-60
lines changed

3 files changed

+73
-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"

0 commit comments

Comments
 (0)