Skip to content

Commit

Permalink
Release scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Jul 1, 2024
1 parent c9d9ce9 commit 878d2d2
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/build/artifacts/
/build/stage-1/
/build/stage-2/
/build/svn/

# Composer
/vendor/
Expand Down
30 changes: 1 addition & 29 deletions build/scripts/build.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
<?php

/**
* Functions.
*/
function escape_sequence( $code ) {
return "\e[" . $code . 'm';
}
require_once __DIR__ . '/functions.php';

function format_command( $value ) {
return escape_sequence( '36' ) . $value . escape_sequence( '0' );
}

function format_error( $value ) {
return escape_sequence( '31' ) . escape_sequence( '1' ) . 'Error:' . escape_sequence( '0' ) . ' ' . $value;
}

function run_command( $command, $expected_result_code = 0 ) {
echo format_command( $command ), PHP_EOL;

passthru( $command, $result_code );

if ( null !== $expected_result_code && $expected_result_code !== $result_code ) {
exit( $result_code );
}

return $result_code;
}

/**
* Build.
*/
$slug = 'pronamic-pay-with-rabo-smart-pay-for-woocommerce';

$src_dir = realpath( __DIR__ . '/../../' );
Expand Down
25 changes: 25 additions & 0 deletions build/scripts/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

function escape_sequence( $code ) {
return "\e[" . $code . 'm';
}

function format_command( $value ) {
return escape_sequence( '36' ) . $value . escape_sequence( '0' );
}

function format_error( $value ) {
return escape_sequence( '31' ) . escape_sequence( '1' ) . 'Error:' . escape_sequence( '0' ) . ' ' . $value;
}

function run_command( $command, $expected_result_code = 0 ) {
echo format_command( $command ), PHP_EOL;

passthru( $command, $result_code );

if ( null !== $expected_result_code && $expected_result_code !== $result_code ) {
exit( $result_code );
}

return $result_code;
}
10 changes: 10 additions & 0 deletions build/scripts/release-to-github.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

require_once __DIR__ . '/functions.php';

$slug = 'pronamic-pay-with-rabo-smart-pay-for-woocommerce';
$version = '1.0.0';

$zip_file_path = realpath( __DIR__ . "/../artifacts/$slug.$version.zip" );

run_command( "gh release create v$version --title $version $zip_file_path" );
22 changes: 22 additions & 0 deletions build/scripts/release-to-pronamic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

require_once __DIR__ . '/functions.php';

$slug = 'pronamic-pay-with-rabo-smart-pay-for-woocommerce';
$version = '1.0.0';

$gcloud_bucket_name = 'gs://wp.pronamic.download/plugins/' . $slug;

$zip_filename_version = "$slug.$version.zip";

$zip_filename = "$slug.zip";

$zip_file_path = realpath( __DIR__ . '/../artifacts/' . $zip_filename_version );

run_command( "gcloud storage cp $zip_file_path $gcloud_bucket_name/$zip_file_path" );

run_command( "gcloud storage cp $gcloud_bucket_name/$zip_file_path $gcloud_bucket_name/$zip_filename" );

$pronamic_url = 'https://wp.pronamic.directory/wp-json/pronamic-wp-extensions/v1/plugins/' . $slug;

run_command( "curl --netrc --data version=$version --request PATCH $pronamic_url" );
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"version": "@build",
"release": [
"@build",
"vendor/bin/pronamic release-to-github",
"vendor/bin/pronamic release-to-pronamic",
"vendor/bin/pronamic release-to-wp-org"
"@php build/scripts/release-to-github.php",
"@php build/scripts/release-to-pronamic.php"
"vendor/bin/pronamic release-to-wp-org --working-dir=./build/stage-2 --svn-dir=./build/svn"
]
}
}

0 comments on commit 878d2d2

Please sign in to comment.