Skip to content

Commit e6616c7

Browse files
authored
Merge pull request #8 from Monnify/dev
Automate version bumps and tagging with release-please
2 parents 1ff1247 + 010291b commit e6616c7

4 files changed

Lines changed: 83 additions & 8 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: release-please
2+
3+
# Maintains a standing "release PR" that accumulates Conventional Commits since the last
4+
# release and computes the next semver bump from them (feat: -> minor, fix: -> patch,
5+
# "BREAKING CHANGE:" footer -> major). Merging that PR creates and pushes a vX.Y.Z tag,
6+
# which is what actually triggers release.yml's build/test/pack/publish pipeline - this
7+
# workflow only ever decides the version number and creates the tag, nothing here touches
8+
# NuGet or creates a GitHub Release (skip-github-release in release-please-config.json,
9+
# since release.yml's own publish job already creates the Release after a successful
10+
# publish - having both would create two Releases for the same tag).
11+
on:
12+
push:
13+
branches: [main]
14+
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
19+
jobs:
20+
release-please:
21+
runs-on: ubuntu-latest
22+
steps:
23+
# Deliberately NOT the default GITHUB_TOKEN: GitHub blocks the default token's
24+
# pushes from triggering other workflows (loop prevention), which would silently
25+
# break this chain at the exact point it needs to trigger release.yml. Needs a
26+
# fine-grained PAT (Contents: read/write) stored as the RELEASE_PLEASE_TOKEN secret.
27+
- uses: googleapis/release-please-action@v4
28+
with:
29+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.1.0"
3+
}

CONTRIBUTING.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
- Public members need XML doc comments (enforced via `GenerateDocumentationFile`).
2626
- Run `dotnet format` before submitting a PR; CI verifies formatting.
2727

28+
## Commit messages / PR titles
29+
30+
This repo follows [Conventional Commits](https://www.conventionalcommits.org/)
31+
(`feat: ...`, `fix: ...`, `chore: ...`, etc., with a `BREAKING CHANGE:` footer
32+
when needed). This isn't just a style preference — `release-please` (see
33+
below) parses these to decide the next version number and to write the
34+
changelog automatically, so it needs to be the PR title if you squash-merge,
35+
or every commit message if you merge/rebase.
36+
2837
## Pull request checklist
2938

3039
- [ ] Tests added/updated and passing (`dotnet test`)
@@ -34,15 +43,39 @@
3443

3544
## Versioning and releasing
3645

37-
Versioning is computed by Nerdbank.GitVersioning from `version.json` and git
38-
history — every commit gets a meaningful prerelease version
39-
(`0.1.18-alpha.gb301a5cb61`-style) automatically; there's no manual version
40-
bump.
46+
The version number and the release tag are both decided automatically by
47+
[release-please](.github/workflows/release-please.yml), not by hand:
48+
49+
1. Every PR merged to `main` is analyzed by `release-please` for Conventional
50+
Commits since the last release. It maintains a single standing **Release
51+
PR** that accumulates these, with the computed next version
52+
(`fix:` → patch, `feat:` → minor, `BREAKING CHANGE:` → major) and an
53+
auto-written `CHANGELOG.md` section.
54+
2. Merging that Release PR creates and pushes a `vX.Y.Z` tag.
55+
3. That tag push is what triggers [release.yml](.github/workflows/release.yml),
56+
which builds, tests, and packs, then **requires manual approval** before
57+
publishing: the publish job runs under a `nuget-release` GitHub Environment
58+
(already configured with required reviewers).
59+
60+
Don't create or push a `vX.Y.Z` tag by hand — that races with
61+
`release-please`'s own bookkeeping in `.release-please-manifest.json` and can
62+
leave it confused about what's already shipped.
63+
64+
`release-please` pushes its tag using a fine-grained PAT in the
65+
`RELEASE_PLEASE_TOKEN` repo secret, not the default `GITHUB_TOKEN` - GitHub
66+
blocks the default token's pushes from triggering other workflows (its
67+
built-in loop-prevention), which would otherwise silently break the chain
68+
right before it reaches `release.yml`. `skip-github-release: true` in
69+
`release-please-config.json` stops `release-please` from also creating a
70+
GitHub Release itself - `release.yml`'s own publish job already creates one
71+
after a successful NuGet push, and having both would create two Releases for
72+
the same tag.
4173

42-
Pushing a `vX.Y.Z` tag triggers [release.yml](.github/workflows/release.yml),
43-
which builds, tests, and packs, then **requires manual approval** before
44-
publishing: the publish job runs under a `nuget-release` GitHub Environment
45-
(already configured with required reviewers).
74+
Nerdbank.GitVersioning still computes the actual assembly/package version
75+
from `version.json` and git history at build time, the same as before -
76+
`release-please` only decides *which* tag to create; once that tag exists and
77+
matches `version.json`'s `publicReleaseRefSpec`, NBGV treats it as the public
78+
release version directly.
4679

4780
Publishing itself uses [NuGet Trusted Publishing](https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing)
4881
(OIDC) rather than a stored API key — the workflow exchanges a short-lived

release-please-config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"skip-github-release": true,
4+
"packages": {
5+
".": {
6+
"release-type": "simple",
7+
"changelog-path": "CHANGELOG.md"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)