Skip to content

Commit

Permalink
Update release processes
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Jun 4, 2024
1 parent 712c192 commit 5d5d0c1
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ composer.local.json
.php-cs-fixer.cache
composer.local.old
pest.log
private-signing-key.pem
build.zip
build.zip.sig
16 changes: 0 additions & 16 deletions build-dev.sh

This file was deleted.

58 changes: 57 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
#!/bin/bash

./build-dev.sh
# This script is used to build and package the plugin for distribution.
# It will clean up the environment, execute Composer, prefix dependencies, finalize the build, archive the build, and sign the archive.

function trim() {
local str="$*"
str="${str#"${str%%[![:space:]]*}"}"
str="${str%"${str##*[![:space:]]}"}"
echo "${str}"
}

function semver {
local SEMVER_REGEX='^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$'
local version=$(trim $1)

if [[ "$version" =~ $SEMVER_REGEX ]]; then
if [ "$#" -eq 2 ]; then
local major=${BASH_REMATCH[0]}
local minor=${BASH_REMATCH[1]}
local patch=${BASH_REMATCH[2]}
local suffix=${BASH_REMATCH[3]}
eval "$2=(\"$major\" \"$minor\" \"$patch\" \"$suffix\")"
fi
else
echo "Error: version '$version' does not match the semver 'X.Y.Z' format."
exit 1
fi
}

printf 'What version are you building? '
read version
echo "Version: $version"
semver "$version" version
filename="Auth0_WordPress_${version}.zip"

echo "# Cleaning up environment..."
rm -f build.zip
rm -f build.zip.sig
rm -rf build
rm -rf vendor
rm composer.lock

echo "# Executing Composer..."
composer update --no-plugins

echo "# Prefixing Dependencies..."
vendor/bin/php-scoper add-prefix --force

echo "# Finalizing Build..."
cd build
composer update --no-dev --optimize-autoloader --no-plugins
rm composer.json
rm composer.lock
cd ..

echo "# Archiving Build..."
zip -vr ${filename} build/ -x "*.DS_Store"

echo "# Signing Build..."
openssl dgst -sign private-signing-key.pem -sha256 -out ${filename}.sig -binary ${filename}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
}
},
"scripts": {
"package": "./build.sh",
"build": "./build.sh",
"pest": "@php vendor/bin/pest --order-by random --fail-on-risky --parallel --no-progress",
"pest:coverage": "@php vendor/bin/pest --order-by random --fail-on-risky --coverage --parallel --no-progress",
"pest:debug": "@php vendor/bin/pest --log-events-verbose-text pest.log --display-errors --fail-on-risky --no-progress",
Expand Down
5 changes: 3 additions & 2 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Finder::create()
->files()
->ignoreVCS(true)
->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.(json|lock)/')
->notName('/.*\\.dist|Makefile|scoper.inc.php|rector.php|opslevel.yml|build.sh|public-signing-key.pub|composer.json|composer.lock/')
->exclude([
'doc',
'test',
Expand All @@ -28,7 +28,8 @@
],

'exclude-namespaces' => [
'/^Auth0\\\\WordPress\\\/',
'/^Auth0\\\\WordPress\\\\/',
'/^Auth0\\\\WordPress/',
'/^Psr\\\/',
],

Expand Down
14 changes: 7 additions & 7 deletions src/Actions/Updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Updates extends Base

public function doUpdateCheck($plugins)
{
trap($plugins);
// trap($plugins);

if (! is_object($plugins)) {
return $plugins;
Expand All @@ -26,12 +26,12 @@ public function doUpdateCheck($plugins)
$plugins->response = [];
}

$plugins->response['auth0/wpAuth0.php'] = (object) [
'slug' => 'auth0',
'new_version' => '5.9',
'url' => 'https://github.com/auth0/wordpress',
'package' => 'https://github.com/auth0/wirdoress/archive/0.2.zip',
];
// $plugins->response['auth0/wpAuth0.php'] = (object) [
// 'slug' => 'auth0',
// 'new_version' => '5.9',
// 'url' => 'https://github.com/auth0/wordpress',
// 'package' => 'https://github.com/auth0/wirdoress/archive/0.2.zip',
// ];

return $plugins;
}
Expand Down
5 changes: 5 additions & 0 deletions updates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"5.3.0": {
"download": "Auth0_WordPress_5.3.0.zip"
}
}
4 changes: 3 additions & 1 deletion wpAuth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
}

// Load dependencies
if (file_exists(plugin_dir_path(__FILE__) . '/vendor/autoload.php')) {
if (file_exists(plugin_dir_path(__FILE__) . '/vendor/scoper-autoload.php')) {
require_once plugin_dir_path(__FILE__) . '/vendor/autoload.php';
} elseif (file_exists(plugin_dir_path(__FILE__) . '/vendor/autoload.php')) {
require_once plugin_dir_path(__FILE__) . '/vendor/autoload.php';
}

Expand Down

0 comments on commit 5d5d0c1

Please sign in to comment.