Skip to content

Commit

Permalink
Merge branch 'trunk' into add/outbox-collection
Browse files Browse the repository at this point in the history
  • Loading branch information
pfefferle authored Jan 20, 2025
2 parents 315493a + 6362851 commit bb41713
Show file tree
Hide file tree
Showing 46 changed files with 1,010 additions and 223 deletions.
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [Untitled]

### Changed

* Improved content negotiation and AUTHORIZED_FETCH support for third-party plugins

## [4.7.2] - 2025-01-17

### Fixed

* More robust handling of `_activityPubOptions` in scripts, using a `useOptions()` helper.
* Flush post caches after Followers migration.

### Added

* Support for WPML post locale

### Removed

Expand Down Expand Up @@ -1213,8 +1228,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* initial

[Unreleased]: https://github.com/Automattic/wordpress-activitypub/compare/4.7.1...trunk
[Unreleased]: https://github.com/Automattic/wordpress-activitypub/compare/4.7.2...trunk
<!-- Add new release below and update "Unreleased" link -->
[4.7.2]: https://github.com/Automattic/wordpress-activitypub/compare/4.7.1...4.7.2
[4.7.1]: https://github.com/Automattic/wordpress-activitypub/compare/4.7.0...4.7.1
[4.7.0]: https://github.com/Automattic/wordpress-activitypub/compare/4.6.0...4.7.0
[4.6.0]: https://github.com/Automattic/wordpress-activitypub/compare/4.5.1...4.6.0
Expand Down
4 changes: 2 additions & 2 deletions activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: ActivityPub
* Plugin URI: https://github.com/Automattic/wordpress-activitypub
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
* Version: 4.7.1
* Version: 4.7.2
* Author: Matthias Pfefferle & Automattic
* Author URI: https://automattic.com/
* License: MIT
Expand All @@ -19,7 +19,7 @@

use WP_CLI;

\define( 'ACTIVITYPUB_PLUGIN_VERSION', '4.7.1' );
\define( 'ACTIVITYPUB_PLUGIN_VERSION', '4.7.2' );

// Plugin related constants.
\define( 'ACTIVITYPUB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
Expand Down
177 changes: 177 additions & 0 deletions bin/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#!/usr/bin/env node

const { execSync } = require('child_process');
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

const question = (query) => new Promise((resolve) => rl.question(query, resolve));

const exec = (command) => {
try {
return execSync(command, { stdio: 'inherit' });
} catch (error) {
console.error(`Error executing command: ${command}`);
process.exit(1);
}
};

const execWithOutput = (command) => {
try {
return execSync(command, { stdio: 'pipe' }).toString().trim();
} catch (error) {
console.error(`Error executing command: ${command}`);
process.exit(1);
}
};

const updateVersionInFile = (filePath, version, patterns) => {
let content = fs.readFileSync(filePath, 'utf8');

patterns.forEach(({ search, replace }) => {
content = content.replace(
search,
typeof replace === 'function' ? replace(version) : replace
);
});

fs.writeFileSync(filePath, content);
};

const updateChangelog = (version) => {
const date = new Date().toISOString().split('T')[0];
const content = fs.readFileSync('CHANGELOG.md', 'utf8');

// Update the Unreleased section
let updated = content.replace(
/## \[Unreleased\]/,
`## [${version}] - ${date}`
);

// Update the comparison links at the bottom
const prevVersion = content.match(/compare\/(\d+\.\d+\.\d+)\.\.\.trunk/)[1];
updated = updated.replace(
/\[Unreleased\]: .*\n/,
`[Unreleased]: https://github.com/Automattic/wordpress-activitypub/compare/${version}...trunk\n`
);

// Add the new version comparison link
const newVersionLink = `[${version}]: https://github.com/Automattic/wordpress-activitypub/compare/${prevVersion}...${version}\n`;
updated = updated.replace(
/<!-- Add new release below and update "Unreleased" link -->\n/,
`<!-- Add new release below and update "Unreleased" link -->\n${newVersionLink}`
);

fs.writeFileSync('CHANGELOG.md', updated);
};

async function createRelease(version) {
// Create and checkout release branch
const branchName = `release/${version}`;
exec(`git checkout -b ${branchName}`);

// Update version numbers in files
updateVersionInFile('activitypub.php', version, [
{
search: /Version: \d+\.\d+\.\d+/,
replace: `Version: ${version}`
},
{
search: /ACTIVITYPUB_PLUGIN_VERSION', '\d+\.\d+\.\d+/,
replace: `ACTIVITYPUB_PLUGIN_VERSION', '${version}`
}
]);

updateVersionInFile('readme.txt', version, [
{
search: /Stable tag: \d+\.\d+\.\d+/,
replace: `Stable tag: ${version}`
},
{
search: /= Unreleased =/,
replace: `= ${version} =`
}
]);

updateVersionInFile('includes/class-migration.php', version, [
{
search: /version_compare\([^,]+,\s*['"]unreleased['"]/gi,
replace: (match) => match.replace(/unreleased/i, version)
}
]);

// Update CHANGELOG.md
updateChangelog(version);

// Stage and commit changes
exec('git add .');
exec(`git commit -m "Release ${version}"`);

// Push to remote
exec(`git push -u origin ${branchName}`);

// Get current user's GitHub username
const currentUser = execWithOutput('gh api user --jq .login');

// Create PR using GitHub CLI and capture the URL
console.log('\nCreating draft PR...');
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`);

// Open PR in browser
exec(`open ${prUrl}`);
}

async function release() {
try {
// Check if gh CLI is installed
try {
execSync('gh --version', { stdio: 'ignore' });
} catch (error) {
console.error('GitHub CLI (gh) is not installed. Please install it first:');
console.error('https://cli.github.com/');
process.exit(1);
}

// Store current branch
const currentBranch = execWithOutput('git rev-parse --abbrev-ref HEAD');

while (true) {
// Get new version
const version = await question('\nWhat version would you like to release? (x.x.x): ');
if (!/^\d+\.\d+\.\d+$/.test(version)) {
console.error('Invalid version format. Please use x.x.x');
continue;
}

// Check if release branch already exists
const branchExists = execWithOutput(`git branch --list release/${version}`);
if (branchExists) {
console.error(`\nError: Branch release/${version} already exists.`);
// Return to original branch if we're not already there
if (currentBranch !== execWithOutput('git rev-parse --abbrev-ref HEAD')) {
exec(`git checkout ${currentBranch}`);
}
continue;
}

// Ensure we're on trunk branch and up to date
exec('git checkout trunk');
exec('git pull origin trunk');

await createRelease(version);
break;
}

} catch (error) {
console.error('An error occurred:', error);
process.exit(1);
} finally {
rl.close();
}
}

release();
2 changes: 1 addition & 1 deletion build/editor-plugin/plugin.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'cdcc2ad2e5f7b1d547fe');
<?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '6b15195803d2f5a2c116');
2 changes: 1 addition & 1 deletion build/editor-plugin/plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/follow-me/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '62610556ba8e5f129fdf');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '83f77c18c3da9f51d14b');
Loading

0 comments on commit bb41713

Please sign in to comment.