Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a release page #407

Open
wants to merge 89 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
03f8c50
Squash merge try/release-page
StevenDufresne Nov 18, 2024
401dfdb
Remove releases reference.
StevenDufresne Nov 18, 2024
38e8bb9
Turn around if not published.
StevenDufresne Nov 18, 2024
a030569
remove changelog for now.
StevenDufresne Nov 18, 2024
ec5a507
Clean up build artifacts.
StevenDufresne Nov 18, 2024
3569a1c
Update with current state.
StevenDufresne Nov 18, 2024
1cfb49d
Cleanup, finish subnav.
StevenDufresne Nov 18, 2024
c637479
Hook up the release menu options.
StevenDufresne Nov 19, 2024
f409cfa
Make CPT queryable.
StevenDufresne Nov 19, 2024
8096572
Add playground url.
StevenDufresne Nov 19, 2024
6556218
Fix some bugs; add safety measures around deletion and updates
tellyworth Nov 21, 2024
4f10405
Don't call this yet
tellyworth Nov 22, 2024
440da78
Handle duplicate CPTs; includes non-functional code for debugging
tellyworth Nov 22, 2024
3804b5c
Fix bug where post_parent was zeroed on update; remove debug and safe…
tellyworth Nov 22, 2024
05ea0dd
Add a CLI script for creating/updating release CPTs during testing.
tellyworth Nov 22, 2024
4273bc2
Update meta details about blocks.
StevenDufresne Nov 25, 2024
b018770
Add code to create a draft post for trunk releases
tellyworth Nov 25, 2024
6de3c3e
Update the release-menu-options to use navigation.
StevenDufresne Nov 25, 2024
aaf5ca9
Add build changes.
StevenDufresne Nov 25, 2024
52eaa95
Remove the experimental modules.
StevenDufresne Nov 25, 2024
86bb938
Update blocks to add 'View changes' feature.
StevenDufresne Nov 26, 2024
26508c4
Make the query work.
StevenDufresne Nov 26, 2024
d795ae9
Create a draft release when trunk changes exist after the most recent…
tellyworth Nov 26, 2024
47142a6
Use `trunk` as the post title for draft posts
tellyworth Nov 26, 2024
48586dc
Get the release draft connected.
StevenDufresne Nov 27, 2024
b44f4d9
Add a Plugin_Check class, and run it during svn import for trunk chan…
tellyworth Nov 27, 2024
9737eb4
Update confirmation control.
StevenDufresne Nov 27, 2024
baff928
Fix bug in get_releases()
tellyworth Nov 27, 2024
e2bbd56
Merge branch 'try/release-page' of https://github.com/StevenDufresne/…
tellyworth Nov 27, 2024
301c20c
Add code to publish a release from a draft, and create the svn tag
tellyworth Nov 28, 2024
00657b9
Add a `--publish` option to the update-release-cpt script
tellyworth Nov 28, 2024
0ce7e11
Start working on release check blocks
StevenDufresne Nov 28, 2024
b03e024
Update the release tag after successfully tagging a release
tellyworth Nov 28, 2024
f7b465f
Merge branch 'try/release-page' of https://github.com/StevenDufresne/…
tellyworth Nov 28, 2024
49cc968
Update draft post and run plugin-check on any `trunk` commit
tellyworth Nov 28, 2024
bb788d2
Add in plugin check errors to checks section.
StevenDufresne Nov 28, 2024
7722c0f
Update the release tag and not the version for trunk urls.
StevenDufresne Nov 28, 2024
4fa1b0f
Store `release_commit_log` postmeta for drafts
tellyworth Nov 29, 2024
2e3f1a0
Merge branch 'try/release-page' of https://github.com/StevenDufresne/…
tellyworth Nov 29, 2024
7660a7c
Store tested/requires headers during import
tellyworth Dec 2, 2024
e2d7267
Remove unused var
tellyworth Dec 3, 2024
f5cc81a
Backfill release CPTs during import
tellyworth Dec 3, 2024
373d7a1
Fix formatting.
StevenDufresne Nov 28, 2024
db00205
Add a commit section.
StevenDufresne Dec 2, 2024
08c957f
Big ui changes.
StevenDufresne Dec 4, 2024
af729aa
Add untested Plugin_Publish API endpoint
tellyworth Dec 5, 2024
06b583f
Fix dumb errors in the REST publish endpoint
tellyworth Dec 9, 2024
0d8a2a8
Add a quick script for displaying release info
tellyworth Dec 9, 2024
6ff94b3
Have the save setup.
StevenDufresne Dec 10, 2024
7caa48e
Revert "Have the save setup."
StevenDufresne Dec 10, 2024
c949b07
Setup the saving sate.
StevenDufresne Dec 10, 2024
c0e5ee2
Clean up the blocks.
StevenDufresne Dec 10, 2024
059248f
Fix download link.
StevenDufresne Dec 10, 2024
e14dd08
Update trunk title.
StevenDufresne Dec 10, 2024
b990988
Store revision_final and revision_prior
tellyworth Dec 11, 2024
c9ed3be
Include commit log in all release cpts
tellyworth Dec 11, 2024
7f81b2d
In get-release-info.php, display revision range and commit log
tellyworth Dec 11, 2024
59955cf
Improve update-release-cpt.php to use svn tag data directly
tellyworth Dec 11, 2024
887908d
Improve the get-release-info script
tellyworth Dec 11, 2024
08d911d
Add translator message.
StevenDufresne Dec 10, 2024
d209588
Clean up publish render.
StevenDufresne Dec 10, 2024
96b8549
Run the linter.
StevenDufresne Dec 12, 2024
0fd427a
Move the error messge to context.
StevenDufresne Dec 12, 2024
4aa28a3
merger import warnings into plugin check errors.
StevenDufresne Dec 12, 2024
617e483
Remove accident file.
StevenDufresne Dec 12, 2024
0a7c933
More cleanup
StevenDufresne Dec 12, 2024
ff4acff
Remove the extra spaces.
StevenDufresne Dec 12, 2024
a95c089
Change from a form to solve the redirect issue.
StevenDufresne Dec 12, 2024
5bec9ce
Fix bug in script output
tellyworth Dec 12, 2024
275f9bc
Release release flags.
StevenDufresne Dec 12, 2024
5664787
Fix svn log handling
tellyworth Dec 12, 2024
2712e3d
Merge branch 'try/release-page' of https://github.com/StevenDufresne/…
tellyworth Dec 12, 2024
c76f963
Move away from a form and fix validation.
StevenDufresne Dec 12, 2024
308d256
Fix heading issues.
StevenDufresne Dec 12, 2024
bbcb39e
Make the secondary font size smaller.
StevenDufresne Dec 12, 2024
b5a4972
Fix fatal when no release exists
tellyworth Dec 12, 2024
aac8681
Merge branch 'try/release-page' of https://github.com/StevenDufresne/…
tellyworth Dec 12, 2024
467b836
Revert block-config.php
StevenDufresne Dec 12, 2024
3769219
Rename endpoint to publish.
StevenDufresne Dec 12, 2024
10f850d
Refactor to save commits if there are no releases yet.
StevenDufresne Dec 12, 2024
5247cde
Add tested for new drafts.
StevenDufresne Dec 12, 2024
a6c4716
Handle errors better.
StevenDufresne Dec 13, 2024
66594d0
Clean up errors.
StevenDufresne Dec 13, 2024
69a49b8
Improve error messages, return errors to view.
StevenDufresne Dec 13, 2024
e03c880
Fix the css.
StevenDufresne Dec 13, 2024
2da94f0
Fix the changelog links.
StevenDufresne Dec 13, 2024
64706a1
Remove faileds on import warnings and plugin_check.
StevenDufresne Dec 13, 2024
1fbb6a9
Update heading.
StevenDufresne Dec 13, 2024
50ea6d5
Darken secondary text.
StevenDufresne Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
797 changes: 797 additions & 0 deletions taq

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static function load_routes() {
new Routes\Plugin_Upload();
new Routes\Plugin_Blueprint();
new Routes\Plugin_Review();
new Routes\Plugin_Publish();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* An API endpoint for publishing plugin releases.
*
* @package WordPressdotorg_Plugin_Directory
*/

namespace WordPressdotorg\Plugin_Directory\API\Routes;

use WP_REST_Response;
use WP_REST_Server;
use WordPressdotorg\Plugin_Directory\Plugin_Directory;
use WordPressdotorg\Plugin_Directory\Plugin_Release;
use WordPressdotorg\Plugin_Directory\API\Base;

/**
* An API endpoint for publishing a release of a plugin.
*
* @package WordPressdotorg_Plugin_Directory
*/
class Plugin_Publish extends Base {

/**
* Plugin_Publish constructor.
*/
public function __construct() {
register_rest_route(
'plugins/v2',
'/plugin/(?P<plugin_slug>[^/]+)/release', // FIXME: 'release' or 'publish' or something else?
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array( $this, 'publish_release' ),
'args' => array(
'plugin_slug' => array(
'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
),
),
'permission_callback' => array( $this, 'permission_can_access_plugin' ),
)
);
}

/**
* Validate that the user can manage a given plugin.
*/
public function permission_can_access_plugin( $request ) {
$plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] );
return current_user_can( 'plugin_manage_releases', $plugin );
}

/**
* A simple endpoint to publish a release.
*
* @param WP_REST_Request $request The request object.
* @return WP_REST_Response
*/
public function publish_release( $request ) {

$plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] );
// Will return either a WP_Error, or the post ID of the published release CPT.
// Maybe it should return the version string instead, or an object with more details? The whole CPT?
$result = Plugin_Release::instance()->publish_release( $plugin );

return new WP_REST_Response( $result );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
namespace WordPressdotorg\Plugin_Directory;

// CLI script for printing release CPT details for a plugin
// Usage: php get-release-info.php --plugin hello-dolly

// Intended for use while testing; this can probably be removed once everything is live; or turned into a fixer script.

// This script should only be called in a CLI environment.
if ( 'cli' != php_sapi_name() ) {
die();
}

ob_start();

$opts = getopt( '', array( 'url:', 'abspath:', 'plugin:', 'changed-tags:', 'async', 'publish' ) );

// Guess the default parameters:
if ( empty( $opts ) && $argc == 2 ) {
$opts['plugin'] = $argv[1];
$argv[1] = '--plugin ' . $argv[1];
}
if ( empty( $opts['url'] ) ) {
$opts['url'] = 'https://wordpress.org/plugins/';
}
if ( empty( $opts['abspath'] ) && false !== strpos( __DIR__, 'wp-content' ) ) {
$opts['abspath'] = substr( __DIR__, 0, strpos( __DIR__, 'wp-content' ) );
}

if ( empty( $opts['changed-tags'] ) ) {
$opts['changed-tags'] = array( 'trunk' );
} else {
$opts['changed-tags'] = explode( ',', $opts['changed-tags'] );
}

$opts['async'] = isset( $opts['async'] );
$opts['publish'] = isset( $opts['publish'] );

foreach ( array( 'url', 'abspath', 'plugin' ) as $opt ) {
if ( empty( $opts[ $opt ] ) ) {
fwrite( STDERR, "Missing Parameter: $opt\n" );
fwrite( STDERR, "Usage: php {$argv[0]} --plugin hello-dolly --abspath /home/example/public_html --url https://wordpress.org/plugins/\n" );
fwrite( STDERR, "Optional: --async to queue a job to import, --create to create a Post if none exist.\n" );
fwrite( STDERR, "--url and --abspath will be guessed if possible.\n" );
die();
}
}

// Bootstrap WordPress
$_SERVER['HTTP_HOST'] = parse_url( $opts['url'], PHP_URL_HOST );
$_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH );

require rtrim( $opts['abspath'], '/' ) . '/wp-load.php';

if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) {
fwrite( STDERR, "Error! This site doesn't have the Plugin Directory plugin enabled.\n" );
if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
fwrite( STDERR, "Run the following command instead:\n" );
fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . ' --url ' . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
}
die();
}

$plugin_slug = $opts['plugin'];
$start_time = microtime( 1 );

$plugin = Plugin_Directory::get_plugin_post( $plugin_slug );
if ( ! $plugin ) {
fwrite( STDERR, "Plugin not found: $plugin_slug\n" );
die();
}

echo "Showing releases for $plugin_slug ($plugin->ID)...\n";

$releases = Plugin_Release::instance()->get_releases( $plugin );
if ( is_wp_error( $releases ) ) {
fwrite( STDERR, "Failed to update releases for $plugin_slug: " . $updated->get_error_message() . "\n" );
die();
}

foreach( $releases as $release ) {
echo "ID: " . $release->ID . "\n";
echo "Status: " . $release->post_status . "\n";
echo "Release version: " . $release->post_title . "\n";
echo "Tag: " . $release->release_tag . "\n";
echo "Post date GMT: " . $release->post_date_gmt . "\n";
if ( $release->release_date ) {
echo "Date: " . ( new \DateTime( '@' . $release->release_date ) )->format( 'Y-m-d H:i:s' ) . "\n";
}
echo "Committers: " . implode( ', ', $release->release_committer ) . "\n";
echo "Zips built: " . ( $release->release_zips_built ? 'Yes' : 'No' ) . "\n";
echo "Confirmations required: " . ( $release->release_confirmations_required ? 'Yes' : 'No' ) . "\n";
echo "Release revision: " . $release->revision_final . "\n";
echo "Previous version rev: " . $release->revision_prior . "\n";
if ( $release->release_commit_log ) {
echo "Commit log:\n";
foreach( $release->release_commit_log as $commit ) {
echo " " . ( new \DateTime( '@' . $commit['date'] ) )->format( 'Y-m-d' ) . " - ";
echo " " . $commit['author'] . ' r' . $commit['revision'] . " - " . \wp_trim_words( $commit['message'] ) . "\n";
}
}
echo "-----------------------------------\n";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
namespace WordPressdotorg\Plugin_Directory;

// CLI script for creating/updating plugin release CPTs for a specific plugin.
// Usage: php update-release-cpt.php --plugin hello-dolly

// Intended for use while testing; this can probably be removed once everything is live; or turned into a fixer script.

// This script should only be called in a CLI environment.
if ( 'cli' != php_sapi_name() ) {
die();
}

ob_start();

$opts = getopt( '', array( 'url:', 'abspath:', 'plugin:', 'changed-tags:', 'async', 'publish' ) );

// Guess the default parameters:
if ( empty( $opts ) && $argc == 2 ) {
$opts['plugin'] = $argv[1];
$argv[1] = '--plugin ' . $argv[1];
}
if ( empty( $opts['url'] ) ) {
$opts['url'] = 'https://wordpress.org/plugins/';
}
if ( empty( $opts['abspath'] ) && false !== strpos( __DIR__, 'wp-content' ) ) {
$opts['abspath'] = substr( __DIR__, 0, strpos( __DIR__, 'wp-content' ) );
}

if ( empty( $opts['changed-tags'] ) ) {
$opts['changed-tags'] = array( 'trunk' );
} else {
$opts['changed-tags'] = explode( ',', $opts['changed-tags'] );
}

$opts['async'] = isset( $opts['async'] );
$opts['publish'] = isset( $opts['publish'] );

foreach ( array( 'url', 'abspath', 'plugin' ) as $opt ) {
if ( empty( $opts[ $opt ] ) ) {
fwrite( STDERR, "Missing Parameter: $opt\n" );
fwrite( STDERR, "Usage: php {$argv[0]} --plugin hello-dolly --abspath /home/example/public_html --url https://wordpress.org/plugins/\n" );
fwrite( STDERR, "Optional: --async to queue a job to import, --create to create a Post if none exist.\n" );
fwrite( STDERR, "--url and --abspath will be guessed if possible.\n" );
die();
}
}

// Bootstrap WordPress
$_SERVER['HTTP_HOST'] = parse_url( $opts['url'], PHP_URL_HOST );
$_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH );

require rtrim( $opts['abspath'], '/' ) . '/wp-load.php';

if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) {
fwrite( STDERR, "Error! This site doesn't have the Plugin Directory plugin enabled.\n" );
if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
fwrite( STDERR, "Run the following command instead:\n" );
fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . ' --url ' . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
}
die();
}

$plugin_slug = $opts['plugin'];
$start_time = microtime( 1 );

$plugin = Plugin_Directory::get_plugin_post( $plugin_slug );
if ( ! $plugin ) {
fwrite( STDERR, "Plugin not found: $plugin_slug\n" );
die();
}

if ( empty( $plugin->releases ) ) {
fwrite( STDERR, "No releases found for $plugin_slug\n" );
die();
}

echo "Updating releases for $plugin_slug...\n";

$updated = Plugin_Release::instance()->maybe_backfill_releases( $plugin, true ); // true = force update
if ( is_wp_error( $updated ) ) {
fwrite( STDERR, "Failed to update releases for $plugin_slug: " . $updated->get_error_message() . "\n" );
die();
}
echo "Updated " . number_format( $updated ) . " releases for $plugin_slug\n";

if ( $opts['publish'] ) {
$published = Plugin_Release::instance()->publish_release( $plugin );
if ( is_wp_error( $published ) ) {
fwrite( STDERR, "Failed to publish releases for $plugin_slug: " . $published->get_error_message() . "\n" );
die();
}
echo "Published release post ID = " . $published . "\n";
}

Loading