Skip to content

Commit 49ffd66

Browse files
obenlandpfefferle
andauthored
Add support for deprecated version replacements (#1279)
* Add support for deprecated version replacements * Try to fix failing PR command * Updated regex * Make it reviewable PRs --------- Co-authored-by: Matthias Pfefferle <[email protected]>
1 parent 63fb115 commit 49ffd66

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

bin/release.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,20 @@ async function createRelease(version) {
109109
phpFiles.forEach((filePath) => {
110110
updateVersionInFile(filePath, version, [
111111
{
112-
search: /@since unreleased/g,
112+
search: /@since unreleased/gi,
113113
replace: `@since ${version}`
114+
},
115+
{
116+
search: /@deprecated unreleased/gi,
117+
replace: `@deprecated ${version}`
118+
},
119+
{
120+
search: /(?<=_deprecated_function\s*\(\s*__METHOD__,\s*')unreleased(?=',\s*['<=>])/gi,
121+
replace: (match) => match.replace(/unreleased/i, version)
122+
},
123+
{
124+
search: /(?<=\bapply_filters_deprecated\s*\(\s*'.*?'\s*,\s*array\s*\(.*?\)\s*,\s*')unreleased(?=',\s*['<=>])/gi,
125+
replace: (match) => match.replace(/unreleased/i, version)
114126
}
115127
]);
116128
});
@@ -129,11 +141,13 @@ async function createRelease(version) {
129141
const currentUser = execWithOutput('gh api user --jq .login');
130142

131143
// Create PR using GitHub CLI and capture the URL
132-
console.log('\nCreating draft PR...');
133-
const prUrl = execWithOutput(`gh pr create --title "Release ${version}" --body "Release version ${version}" --base trunk --head ${branchName} --draft --reviewer "Automattic/fediverse" --assignee "${currentUser}" --json url --jq .url`);
144+
console.log('\nCreating PR...');
145+
const prUrl = execWithOutput(`gh pr create --title "Release ${version}" --body "Release version ${version}" --base trunk --head ${branchName} --reviewer "Automattic/fediverse" --assignee "${currentUser}"`);
134146

135-
// Open PR in browser
136-
exec(`open ${prUrl}`);
147+
// Open PR in browser if a URL was returned
148+
if (prUrl && prUrl.includes('github.com')) {
149+
exec(`open ${prUrl}`);
150+
}
137151
}
138152

139153
async function release() {

0 commit comments

Comments
 (0)