Skip to content

fix: resolve dark mode flash (FOUC) on options and translation-hub pages #803

fix: resolve dark mode flash (FOUC) on options and translation-hub pages

fix: resolve dark mode flash (FOUC) on options and translation-hub pages #803

name: PR - Major Version Warning
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- ".changeset/*.md"
permissions:
contents: read
pull-requests: write
issues: write
jobs:
check-major:
name: Check Breaking Changes
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed changeset files
id: changed-files
uses: tj-actions/changed-files@v47
with:
files: ".changeset/*.md"
files_ignore: .changeset/README.md
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Check for major changes
id: check-major
if: steps.changed-files.outputs.any_changed == 'true'
run: |
echo "Checking changeset files for major changes..."
major_files=""
major_packages=""
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "Checking file: $file"
# Extract front matter and check for major (more robust parsing)
if sed -n '/^---$/,/^---$/p' "$file" | grep -q ": major"; then
echo "Found major change in: $file"
major_files="$major_files$file "
# Extract package names with major changes (more precise)
packages=$(sed -n '/^---$/,/^---$/p' "$file" | grep ": major" | sed 's/^"\([^"]*\)": major$/\1/' | tr '\n' ' ')
major_packages="$major_packages$packages"
fi
done
if [ -n "$major_files" ]; then
echo "has_major=true" >> $GITHUB_OUTPUT
echo "major_files=$major_files" >> $GITHUB_OUTPUT
echo "major_packages=$major_packages" >> $GITHUB_OUTPUT
else
echo "has_major=false" >> $GITHUB_OUTPUT
fi
- name: Comment on PR with major version warning
if: steps.check-major.outputs.has_major == 'true' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const majorFiles = ${{ toJSON(steps.check-major.outputs.major_files) }}.trim();
const majorPackages = ${{ toJSON(steps.check-major.outputs.major_packages) }}.trim();
// Check if we already have a major version warning comment
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('⚠️ Major Version Change Detected')
);
const comment = `## ⚠️ Major Version Change Detected
This PR contains **MAJOR** version changes, which means **breaking changes**!
### 📦 Affected Packages
${majorPackages.split(' ').filter(p => p).map(pkg => `- \`${pkg}\``).join('\n')}
### 📁 Related Changeset Files
${majorFiles.split(' ').filter(f => f).map(file => `- \`${file}\``).join('\n')}
### 🔢 Version Impact
Major version changes will:
- Increment the major version number by 1 (e.g., 1.2.3 → 2.0.0)
- Reset minor and patch versions to 0
- Indicate **breaking changes** that may cause existing user code to fail
### ❓ Please Confirm
Please carefully confirm the following:
1. **Does this really contain breaking changes?**
- API removal or modification
- Default behavior changes
- Major dependency updates
2. **Should you use \`minor\` or \`patch\` instead?**
- \`minor\`: New features but backward compatible
- \`patch\`: Bug fixes, backward compatible
3. **Are you ready to release a major version?**
- Updated documentation explaining breaking changes
- Provided migration guide
- Notified users of upcoming major update
### 🛠️ How to Modify
If you need to downgrade the version type:
1. Edit the changeset file, change \`major\` to \`minor\` or \`patch\`
2. Commit the changes
### 📚 References
- [Semantic Versioning](https://semver.org/)
- [Changesets Documentation](https://github.com/changesets/changesets)
---
*This warning is generated by automated checks to prevent accidental breaking version releases.*`;
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
});
} else {
// Create new comment
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
- name: Fail workflow for major changes (fork repos only)
if: steps.check-major.outputs.has_major == 'true' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::⚠️ Major version changes detected in fork repository!"
echo "::error::"
echo "::error::❓ Are you sure this PR contains BREAKING CHANGES?"
echo "::error:: Major versions (1.2.3 → 2.0.0) are only for:"
echo "::error:: • API removals or incompatible changes"
echo "::error:: • Behavior changes that break existing code"
echo "::error:: • Major dependency updates with breaking changes"
echo "::error::"
echo "::error::🚫 Fork repositories cannot submit major version changes due to their breaking nature."
echo "::error:: Major changes require repository maintainer approval and coordination."
echo "::error::"
echo "::error::📝 Please either:"
echo "::error:: 1. Change 'major' to 'minor' or 'patch' in your changeset files"
echo "::error:: 2. Contact repository maintainers to handle this major change"
echo "::error:: 3. Open an issue to discuss the breaking changes first"
echo "::error::"
echo "::error::For more info about semantic versioning: https://semver.org/"
exit 1