Skip to content

Commit 0ea420c

Browse files
committed
fix(changelog): Warn when custom release.yml lacks semver fields
When a custom .github/release.yml is used without semver fields on categories, PRs appear in the changelog but don't contribute to version bump detection. This causes the changelog preview to show "None" for semver impact. Changes: - Add warning when normalizing custom configs with missing semver fields - Update docs to clarify semver field requirement for version detection - Add tests for the warning behavior Fixes getsentry/sentry-wizard#1191 investigation
1 parent 1bc2c3a commit 0ea420c

File tree

4 files changed

+382
-163
lines changed

4 files changed

+382
-163
lines changed

docs/src/content/docs/configuration.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The command is executed with the following environment variables:
3131
The script should:
3232

3333
- Use these environment variables to perform version replacement
34+
- Replace version occurrences
3435
- Not commit changes
3536
- Not change git state
3637

@@ -105,6 +106,13 @@ Craft extends GitHub's format with two additional fields:
105106
| `commit_patterns` | Array of regex patterns to match commit/PR titles (in addition to labels) |
106107
| `semver` | Version bump type for auto-versioning: `major`, `minor`, or `patch` |
107108

109+
:::caution[Required for Version Detection]
110+
The `semver` field is required for Craft's automatic version detection to work.
111+
If you define a custom `.github/release.yml` without `semver` fields, PRs will
112+
still appear in the changelog but won't contribute to suggested version bumps.
113+
The [changelog preview](/github-actions/#changelog-preview) will show "None" for semver impact.
114+
:::
115+
108116
#### Default Configuration
109117

110118
If `.github/release.yml` doesn't exist, Craft uses these defaults based on [Conventional Commits](https://www.conventionalcommits.org/):

docs/src/content/docs/github-actions.md

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ For a real-world example of using Craft's GitHub Actions, see the [getsentry/pub
1111

1212
Craft offers two ways to automate releases in GitHub Actions:
1313

14-
| Option | Best For | Flexibility |
15-
|--------|----------|-------------|
16-
| **Reusable Workflow** | Quick setup, standard release flow | Low - runs as a complete job |
17-
| **Composite Action** | Custom workflows, pre/post steps | High - composable with other steps |
14+
| Option | Best For | Flexibility |
15+
| --------------------- | ---------------------------------- | ---------------------------------- |
16+
| **Reusable Workflow** | Quick setup, standard release flow | Low - runs as a complete job |
17+
| **Composite Action** | Custom workflows, pre/post steps | High - composable with other steps |
1818

1919
### Option 1: Reusable Workflow (Recommended)
2020

@@ -39,27 +39,27 @@ jobs:
3939
4040
#### Workflow Inputs
4141
42-
| Input | Description | Default |
43-
|-------|-------------|---------|
44-
| `version` | Version to release. Can be a semver string (e.g., "1.2.3"), a bump type ("major", "minor", "patch"), or "auto" for automatic detection. | Uses `versioning.policy` from config |
45-
| `merge_target` | Target branch to merge into. | Default branch |
46-
| `force` | Force a release even when there are release-blockers. | `false` |
47-
| `blocker_label` | Label that blocks releases. | `release-blocker` |
48-
| `publish_repo` | Repository for publish issues (owner/repo format). | `{owner}/publish` |
49-
| `git_user_name` | Git committer name. | GitHub actor |
50-
| `git_user_email` | Git committer email. | Actor's noreply email |
51-
| `path` | The path that Craft will run inside. | `.` |
52-
| `craft_config_from_merge_target` | Use the craft config from the merge target branch. | `false` |
42+
| Input | Description | Default |
43+
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
44+
| `version` | Version to release. Can be a semver string (e.g., "1.2.3"), a bump type ("major", "minor", "patch"), or "auto" for automatic detection. | Uses `versioning.policy` from config |
45+
| `merge_target` | Target branch to merge into. | Default branch |
46+
| `force` | Force a release even when there are release-blockers. | `false` |
47+
| `blocker_label` | Label that blocks releases. | `release-blocker` |
48+
| `publish_repo` | Repository for publish issues (owner/repo format). | `{owner}/publish` |
49+
| `git_user_name` | Git committer name. | GitHub actor |
50+
| `git_user_email` | Git committer email. | Actor's noreply email |
51+
| `path` | The path that Craft will run inside. | `.` |
52+
| `craft_config_from_merge_target` | Use the craft config from the merge target branch. | `false` |
5353

5454
#### Workflow Outputs
5555

56-
| Output | Description |
57-
|--------|-------------|
58-
| `version` | The resolved version being released |
59-
| `branch` | The release branch name |
60-
| `sha` | The commit SHA on the release branch |
56+
| Output | Description |
57+
| -------------- | -------------------------------------------- |
58+
| `version` | The resolved version being released |
59+
| `branch` | The release branch name |
60+
| `sha` | The commit SHA on the release branch |
6161
| `previous_tag` | The tag before this release (for diff links) |
62-
| `changelog` | The changelog for this release |
62+
| `changelog` | The changelog for this release |
6363

6464
### Option 2: Composite Action
6565

@@ -106,7 +106,7 @@ When using auto-versioning, Craft analyzes conventional commits to determine the
106106
name: Auto Release
107107
on:
108108
schedule:
109-
- cron: '0 10 * * 1' # Every Monday at 10 AM
109+
- cron: '0 10 * * 1' # Every Monday at 10 AM
110110
111111
jobs:
112112
release:
@@ -142,8 +142,8 @@ jobs:
142142

143143
### Inputs
144144

145-
| Input | Description | Default |
146-
|-------|-------------|---------|
145+
| Input | Description | Default |
146+
| --------------- | ----------------------------------------- | -------- |
147147
| `craft-version` | Version of Craft to use (tag or "latest") | `latest` |
148148

149149
### Pinning a Specific Version
@@ -157,7 +157,7 @@ jobs:
157157
changelog-preview:
158158
uses: getsentry/craft/.github/workflows/changelog-preview.yml@v2
159159
with:
160-
craft-version: "2.15.0"
160+
craft-version: '2.15.0'
161161
secrets: inherit
162162
```
163163

@@ -171,6 +171,12 @@ jobs:
171171
6. **Posts a comment** - Creates or updates a comment on the PR with the changelog preview
172172
7. **Auto-updates** - The comment is automatically updated when you update the PR (push commits, edit title/description, or change labels)
173173

174+
:::note
175+
The version bump suggestion requires categories in your `.github/release.yml` to have
176+
`semver` fields defined. Without them, the suggested bump will show as "None".
177+
See [Auto Mode configuration](/configuration/#auto-mode) for details.
178+
:::
179+
174180
### Example Comment
175181

176182
The workflow posts a comment like this:
@@ -205,6 +211,7 @@ Entries from this PR are highlighted with a left border (blockquote style).
205211
### PR Trigger Types
206212

207213
The workflow supports these PR event types:
214+
208215
- `opened` - When a PR is created
209216
- `synchronize` - When new commits are pushed
210217
- `reopened` - When a closed PR is reopened
@@ -216,13 +223,16 @@ The workflow supports these PR event types:
216223
The workflow requires specific permissions and secrets to function correctly:
217224

218225
**Permissions** (required):
226+
219227
- `contents: read` - Allows the workflow to checkout your repository and read git history for changelog generation
220228
- `pull-requests: write` - Allows the workflow to post and update comments on pull requests
221229

222230
**Secrets**:
231+
223232
- `secrets: inherit` - Passes your repository's `GITHUB_TOKEN` to the workflow, ensuring it has access to your repository (especially important for private repositories)
224233

225234
**Repository Setup**:
235+
226236
- The repository should have a git history with tags for the changelog to be meaningful
227237

228238
:::note[Why are these permissions needed?]
@@ -248,13 +258,13 @@ You can configure labels to exclude PRs from the changelog. In your `.craft.yml`
248258
```yaml
249259
changelog:
250260
categories:
251-
- title: "New Features ✨"
252-
labels: ["feature", "enhancement"]
253-
- title: "Bug Fixes 🐛"
254-
labels: ["bug", "fix"]
261+
- title: 'New Features ✨'
262+
labels: ['feature', 'enhancement']
263+
- title: 'Bug Fixes 🐛'
264+
labels: ['bug', 'fix']
255265
exclude:
256-
labels: ["skip-changelog", "dependencies"]
257-
authors: ["dependabot[bot]", "renovate[bot]"]
266+
labels: ['skip-changelog', 'dependencies']
267+
authors: ['dependabot[bot]', 'renovate[bot]']
258268
```
259269

260270
PRs with the `skip-changelog` label or from excluded authors will not appear in the changelog.

0 commit comments

Comments
 (0)