Skip to content

Commit 349076e

Browse files
committed
- update generate-changeset.yml to output a note about @since / deprecation placeholders that will be updated in the release
1 parent 8c52f63 commit 349076e

File tree

3 files changed

+70
-28
lines changed

3 files changed

+70
-28
lines changed

.github/workflows/generate-changeset.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ jobs:
124124
# For debugging
125125
echo "Generated release notes:"
126126
cat /tmp/release-notes/temp_notes.md
127+
128+
- name: Check for pending @since and deprecated version updates
129+
id: check_since
130+
run: |
131+
# Get the next version from package.json
132+
NEXT_VERSION=$(node -p "require('./package.json').version")
133+
134+
# Run the since-tags script in dry-run mode to check for @since and deprecated version placeholders
135+
node scripts/update-since-tags.js "$NEXT_VERSION" --dry-run || true
136+
137+
# If the summary file exists, read it
138+
if [ -f "/tmp/since-tags-summary.md" ]; then
139+
SINCE_SUMMARY=$(cat /tmp/since-tags-summary.md)
140+
echo "has_updates=true" >> $GITHUB_OUTPUT
141+
echo "summary<<EOF" >> $GITHUB_OUTPUT
142+
echo "$SINCE_SUMMARY" >> $GITHUB_OUTPUT
143+
echo "EOF" >> $GITHUB_OUTPUT
144+
else
145+
echo "has_updates=false" >> $GITHUB_OUTPUT
146+
fi
127147
128148
- name: Check for existing release PR
129149
id: check_pr
@@ -159,6 +179,13 @@ jobs:
159179
PR_BODY="## Upcoming Changes"
160180
PR_BODY="${PR_BODY}"$'\n\n'
161181
PR_BODY="${PR_BODY}$(cat /tmp/release-notes/temp_notes.md)"
182+
183+
# Add @since updates section if there are any
184+
if [[ "${{ steps.check_since.outputs.has_updates }}" == "true" ]]; then
185+
PR_BODY="${PR_BODY}"$'\n\n'
186+
PR_BODY="${PR_BODY}${{ steps.check_since.outputs.summary }}"
187+
fi
188+
162189
PR_BODY="${PR_BODY}"$'\n\n'
163190
PR_BODY="${PR_BODY}This PR contains all changes that will be included in the next release. It is automatically updated when new changesets are added to the develop branch."
164191
@@ -190,6 +217,13 @@ jobs:
190217
PR_BODY="## Upcoming Changes"
191218
PR_BODY="${PR_BODY}"$'\n\n'
192219
PR_BODY="${PR_BODY}$(cat /tmp/release-notes/temp_notes.md)"
220+
221+
# Add @since updates section if there are any
222+
if [[ "${{ steps.check_since.outputs.has_updates }}" == "true" ]]; then
223+
PR_BODY="${PR_BODY}"$'\n\n'
224+
PR_BODY="${PR_BODY}${{ steps.check_since.outputs.summary }}"
225+
fi
226+
193227
PR_BODY="${PR_BODY}"$'\n\n'
194228
PR_BODY="${PR_BODY}This PR contains all changes that will be included in the next release. It is automatically updated when new changesets are added to the develop branch."
195229

.github/workflows/release-management.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,17 @@ jobs:
9292
NEW_VERSION=$(grep -oP "define\('AUTOMATION_TESTS_VERSION', '\K[^']+" constants.php)
9393
echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
9494
95-
- name: Update @since tags
95+
- name: Update @since and deprecated version placeholders
9696
id: update_since_tags
9797
run: |
98-
# Run the since-tags update script with the new version
98+
# Run the since-tags update script with the new version to update @since and deprecated version placeholders
9999
npm run since-tags:update -- ${{ steps.version_bump.outputs.version }}
100100
101101
# Check if summary file exists and has content
102102
if [ -f "/tmp/since-tags-summary.md" ]; then
103103
# Read the summary file
104104
SINCE_SUMMARY=$(cat /tmp/since-tags-summary.md)
105105
106-
# No need to modify the summary here as it's already properly formatted from the script
107-
108106
# Set the output without any encoding (we'll handle that in the release notes step)
109107
echo "has_updates=true" >> $GITHUB_OUTPUT
110108
echo "summary<<EOF" >> $GITHUB_OUTPUT

scripts/update-since-tags.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ const { glob } = require('glob');
44
const chalk = require('chalk');
55

66
/**
7-
* Find files containing @since todo tags
7+
* Find files containing @since and deprecated version placeholder tags
88
*/
99
async function findSinceTodoFiles(pattern = '**/*.php') {
1010
try {
11-
console.log(chalk.blue('\nScanning for @since placeholder tags...'));
11+
console.log(chalk.blue('\nScanning for `@since` and deprecated version placeholder tags...'));
1212

1313
// Define specific directories to scan
1414
const includePaths = [
@@ -67,7 +67,7 @@ async function findSinceTodoFiles(pattern = '**/*.php') {
6767
}
6868

6969
/**
70-
* Get all @since placeholders from a file
70+
* Get all @since and deprecated version placeholders from a file
7171
*/
7272
function getSincePlaceholders(content) {
7373
// Look for both @since placeholders and standalone @next-version
@@ -81,9 +81,9 @@ function getSincePlaceholders(content) {
8181
}
8282

8383
/**
84-
* Update @since placeholders in a file
84+
* Update @since and deprecated version placeholders in a file
8585
*/
86-
function updateSinceTags(filePath, version) {
86+
function updateSinceTags(filePath, version, dryRun = false) {
8787
try {
8888
let content = fs.readFileSync(filePath, 'utf8');
8989
const originalContent = content;
@@ -93,6 +93,11 @@ function updateSinceTags(filePath, version) {
9393
return { updated: false, count: 0 };
9494
}
9595

96+
if (dryRun) {
97+
// In dry run mode, just return what would be updated
98+
return { updated: true, count: placeholderCount };
99+
}
100+
96101
// First replace @since placeholders
97102
content = content.replace(
98103
/@since\s+(todo|tbd|next-version)/gi,
@@ -117,9 +122,9 @@ function updateSinceTags(filePath, version) {
117122
}
118123

119124
/**
120-
* Update all @since todo tags in the project
125+
* Update all @since and deprecated version placeholder tags in the project
121126
*/
122-
async function updateAllSinceTags(version, pattern = '**/*.php') {
127+
async function updateAllSinceTags(version, pattern = '**/*.php', dryRun = false) {
123128
const results = {
124129
updated: [],
125130
errors: [],
@@ -143,36 +148,39 @@ async function updateAllSinceTags(version, pattern = '**/*.php') {
143148

144149
for (const file of files) {
145150
try {
146-
const { updated, count } = updateSinceTags(file, version);
151+
const { updated, count } = updateSinceTags(file, version, dryRun);
147152
if (updated) {
148-
console.log(chalk.gray(`File updated: ${file} (${count} updates)`));
153+
console.log(chalk.gray(`${dryRun ? 'Will update' : 'File updated'}: ${file} (${count} update${count === 1 ? '' : 's'})`));
149154
results.updated.push({ file, count });
150155
results.totalUpdated += count;
151156
}
152157
} catch (error) {
153-
console.error(chalk.red(`Error updating ${file}:`, error.message));
158+
console.error(chalk.red(`Error ${dryRun ? 'checking' : 'updating'} ${file}:`, error.message));
154159
results.errors.push({ file, error: error.message });
155160
}
156161
}
157162

158163
return results;
159164
} catch (error) {
160-
throw new Error(`Error updating @since tags: ${error.message}`);
165+
throw new Error(`Error ${dryRun ? 'checking' : 'updating'} version placeholders: ${error.message}`);
161166
}
162167
}
163168

164169
/**
165170
* Generate a summary for release notes
166171
*/
167-
function generateReleaseNotesSummary(results) {
172+
function generateReleaseNotesSummary(results, isDryRun = false) {
168173
if (results.totalUpdated === 0) {
169174
return '';
170175
}
171176

172-
let summary = '### `@since` Tag Updates\n\n';
173-
summary += `Updated ${results.totalUpdated} \`@since\` placeholder`;
174-
summary += results.totalUpdated === 1 ? '' : 's';
175-
summary += ' in the following files:\n\n';
177+
let summary = isDryRun ?
178+
'### 🔄 Pending `@since` Tag / Deprecation Updates\n\n' :
179+
'### `@since` Tag / Deprecation Updates\n\n';
180+
181+
summary += isDryRun ?
182+
`The following ${results.totalUpdated} version placeholder${results.totalUpdated === 1 ? '' : 's'} will be updated during release:\n\n` :
183+
`Updated ${results.totalUpdated} version placeholder${results.totalUpdated === 1 ? '' : 's'} in the following files:\n\n`;
176184

177185
// Debug logging
178186
console.log(chalk.blue('\nGenerating summary for files:'));
@@ -190,7 +198,7 @@ function generateReleaseNotesSummary(results) {
190198
summary += '\n#### Errors\n\n';
191199
results.errors.forEach(({ file, error }) => {
192200
const relativePath = path.relative(process.cwd(), file);
193-
summary += `- Failed to update \`${relativePath}\`: ${error}\n`;
201+
summary += `- Failed to ${isDryRun ? 'check' : 'update'} \`${relativePath}\`: ${error}\n`;
194202
});
195203
}
196204

@@ -202,26 +210,28 @@ function generateReleaseNotesSummary(results) {
202210
}
203211

204212
/**
205-
* CLI command to update @since tags
213+
* CLI command to update @since and deprecated version placeholder tags
206214
*/
207215
async function main() {
208216
try {
209217
const version = process.argv[2];
218+
const dryRun = process.argv.includes('--dry-run');
219+
210220
if (!version) {
211221
throw new Error('Version argument is required');
212222
}
213223

214-
console.log(chalk.blue('\nUpdating @since placeholder tags...'));
215-
const results = await updateAllSinceTags(version);
224+
console.log(chalk.blue(`\n${dryRun ? 'Checking' : 'Updating'} @since and deprecated version placeholders...`));
225+
const results = await updateAllSinceTags(version, '**/*.php', dryRun);
216226

217227
if (results.updated.length > 0) {
218-
console.log(chalk.green('\n✓ Updated files:'));
228+
console.log(chalk.green(`\n✓ ${dryRun ? 'Files to update' : 'Updated files'}:`));
219229
results.updated.forEach(({ file, count }) => {
220230
console.log(chalk.gray(` - ${path.relative(process.cwd(), file)} (${count} update${count === 1 ? '' : 's'})`));
221231
});
222-
console.log(chalk.green(`\nTotal placeholders updated: ${results.totalUpdated}`));
232+
console.log(chalk.green(`\nTotal placeholders ${dryRun ? 'to update' : 'updated'}: ${results.totalUpdated}`));
223233
} else {
224-
console.log(chalk.yellow('\nNo @since placeholder tags found'));
234+
console.log(chalk.yellow('\nNo @since or deprecated version placeholder tags found'));
225235
}
226236

227237
if (results.errors.length > 0) {
@@ -233,7 +243,7 @@ async function main() {
233243
}
234244

235245
// Generate release notes summary
236-
const summary = generateReleaseNotesSummary(results);
246+
const summary = generateReleaseNotesSummary(results, dryRun);
237247
if (summary) {
238248
// Save summary to a temporary file for the workflow to use
239249
const summaryPath = '/tmp/since-tags-summary.md';

0 commit comments

Comments
 (0)