Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Validate PR

on:
pull_request:
types: [opened, edited, synchronize, labeled, unlabeled]

jobs:
validate:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- name: Ensure PR has a valid type
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title;
const prefixMatch = title.match(/^(\w+)(?:\([^)]*\))?(!)?:/);
const prefix = prefixMatch?.[1]?.toLowerCase();

const validPrefixes = [
'feat', 'fix', 'perf', 'test', 'docs',
'build', 'ci', 'refactor', 'task', 'chore', 'style',
];

const hasValidPrefix = validPrefixes.includes(prefix);
const isBreaking = prefixMatch?.[2] === '!';

const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});

const typeLabels = [
'[Type] Enhancement',
'[Type] Bug',
'[Type] Performance',
'[Type] Automated Testing',
'[Type] Developer Documentation',
'[Type] Build Tooling',
'[Type] Task',
'[Type] Breaking Change',
'[Type] Regression',
];

const hasTypeLabel = labels.some((l) => typeLabels.includes(l.name));

if (hasValidPrefix || hasTypeLabel) {
const method = hasValidPrefix ? 'Conventional Commits prefix' : 'type label';
core.info(`✅ PR has a valid type via ${method}`);
return;
}

core.setFailed(
'PR must have either a Conventional Commits title prefix (e.g. feat:, fix:, docs:) ' +
'or a [Type] label applied manually.\n\n' +
'See docs/code/developer-workflows.md for details.'
);
13 changes: 0 additions & 13 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,5 @@ The script:

After the release is created, it is ready for integration into the WordPress app.

## Release Notes

GitHub automatically generates release notes when a release is created. Notes are organized into the following categories based on PR labels:

- **Breaking Changes** — `[Type] Breaking Change`
- **Features & Enhancements** — `[Type] Enhancement`
- **Bug Fixes** — `[Type] Bug`, `[Type] Regression`
- **Other Changes** — everything else (excludes `[Type] Automated Testing`, `[Type] Build Tooling`, `[Type] Task`, `[Type] Developer Documentation`, and `dependencies`)

Dependabot dependency bump PRs are excluded automatically.

PRs are labeled automatically based on their Conventional Commits title prefix. See the [Developer Workflows](./code/developer-workflows.md) guide for details on the labeling rules.

[^1]: We increment the version before building and without tagging so that (1) the correct version number is included in the build's [error reporting metadata](https://github.com/wordpress-mobile/GutenbergKit/blob/8195901ec8883125dcfa102abf2b6a2a3962af3e/src/utils/exception-parser.js#L99) and (2) the Git tag includes the latest build output.
[^2]: CI tasks create new Android builds for each commit. However, such infrastructure is not yet in place for iOS. Therefore, we must manually create and commit the iOS build.
Empty file added test-pr-423-invalid-prefix.txt
Empty file.
Loading