-
Notifications
You must be signed in to change notification settings - Fork 3
147 lines (119 loc) · 4.81 KB
/
release-pr.yml
File metadata and controls
147 lines (119 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Release PR Validation
# Special workflow for release PRs created by release-please
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
check-if-release-pr:
name: Check if Release PR
runs-on: ubuntu-latest
outputs:
is-release-pr: ${{ steps.check.outputs.is-release-pr }}
steps:
- name: Check if this is a release PR
id: check
run: |
if [[ "${{ github.event.pull_request.user.login }}" == "github-actions[bot]" ]] && \
[[ "${{ github.event.pull_request.title }}" == *"chore: release"* ]]; then
echo "is-release-pr=true" >> $GITHUB_OUTPUT
echo "✅ This is a release PR created by release-please"
else
echo "is-release-pr=false" >> $GITHUB_OUTPUT
echo "ℹ️ This is a regular PR"
fi
validate-release-pr:
name: Validate Release PR
runs-on: ubuntu-latest
needs: check-if-release-pr
if: needs.check-if-release-pr.outputs.is-release-pr == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
install-dependencies: 'true'
- name: Validate release readiness
run: |
echo "🔍 Validating release readiness..."
# Run comprehensive tests
echo "Running comprehensive tests..."
npm test
# Test ESLint plugin
echo "Testing ESLint plugin..."
node test-validation/test-eslint-plugin.js
# Verify lib/validators sync
echo "Verifying validator synchronization..."
sync_issues=0
for validator in lib/validators/*.js; do
basename=$(basename "$validator")
eslint_validator="eslint-plugin-codekeeper/lib/validators/$basename"
if [ ! -f "$eslint_validator" ]; then
echo "❌ Missing: $eslint_validator"
sync_issues=$((sync_issues + 1))
continue
fi
if ! diff -q "$validator" "$eslint_validator" >/dev/null; then
echo "❌ Difference detected: $validator vs $eslint_validator"
sync_issues=$((sync_issues + 1))
fi
done
if [ $sync_issues -gt 0 ]; then
echo "❌ Found $sync_issues synchronization issues"
echo "Please run: cp -r lib/ eslint-plugin-codekeeper/"
exit 1
fi
echo "✅ Release validation completed successfully"
- name: Comment on release PR
uses: actions/github-script@v7
with:
script: |
const comment = `## 🚀 Release Validation Results
✅ **All validation tests passed**
✅ **ESLint plugin tests passed**
✅ **Validator synchronization verified**
This release is ready to be merged!
### What happens when you merge:
1. **Automated Release Creation**: GitHub releases will be created automatically
2. **ESLint Plugin Publishing**: Plugin will be published to GitHub Packages
3. **Release Assets**: Downloadable archives will be generated
4. **Changelog Update**: Changelog will be updated with conventional commit messages
### Release Contents:
- 🛡️ **Main Project**: Validation scripts, examples, documentation
- 🔌 **ESLint Plugin**: Latest validation rules for ESLint integration
Ready to ship! 🚢`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
auto-approve-release-pr:
name: Auto-approve Release PR
runs-on: ubuntu-latest
needs: [check-if-release-pr, validate-release-pr]
if: needs.check-if-release-pr.outputs.is-release-pr == 'true'
steps:
- name: Auto-approve release PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Auto-approve the release PR since it's generated by automation
// and has passed all validation tests
try {
await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
event: 'APPROVE',
body: '🤖 Auto-approving release PR after successful validation'
});
console.log('✅ Release PR auto-approved');
} catch (error) {
console.log('ℹ️ Could not auto-approve (may already be approved):', error.message);
}