Skip to content

Commit 5d5d0c1

Browse files
committed
Update release processes
1 parent 712c192 commit 5d5d0c1

File tree

8 files changed

+79
-28
lines changed

8 files changed

+79
-28
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ composer.local.json
1616
.php-cs-fixer.cache
1717
composer.local.old
1818
pest.log
19+
private-signing-key.pem
20+
build.zip
21+
build.zip.sig

build-dev.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

build.sh

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,61 @@
11
#!/bin/bash
22

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

6+
function trim() {
7+
local str="$*"
8+
str="${str#"${str%%[![:space:]]*}"}"
9+
str="${str%"${str##*[![:space:]]}"}"
10+
echo "${str}"
11+
}
12+
13+
function semver {
14+
local SEMVER_REGEX='^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$'
15+
local version=$(trim $1)
16+
17+
if [[ "$version" =~ $SEMVER_REGEX ]]; then
18+
if [ "$#" -eq 2 ]; then
19+
local major=${BASH_REMATCH[0]}
20+
local minor=${BASH_REMATCH[1]}
21+
local patch=${BASH_REMATCH[2]}
22+
local suffix=${BASH_REMATCH[3]}
23+
eval "$2=(\"$major\" \"$minor\" \"$patch\" \"$suffix\")"
24+
fi
25+
else
26+
echo "Error: version '$version' does not match the semver 'X.Y.Z' format."
27+
exit 1
28+
fi
29+
}
30+
31+
printf 'What version are you building? '
32+
read version
33+
echo "Version: $version"
34+
semver "$version" version
35+
filename="Auth0_WordPress_${version}.zip"
36+
37+
echo "# Cleaning up environment..."
38+
rm -f build.zip
39+
rm -f build.zip.sig
40+
rm -rf build
41+
rm -rf vendor
42+
rm composer.lock
43+
44+
echo "# Executing Composer..."
45+
composer update --no-plugins
46+
47+
echo "# Prefixing Dependencies..."
48+
vendor/bin/php-scoper add-prefix --force
49+
50+
echo "# Finalizing Build..."
51+
cd build
552
composer update --no-dev --optimize-autoloader --no-plugins
53+
rm composer.json
54+
rm composer.lock
55+
cd ..
56+
57+
echo "# Archiving Build..."
58+
zip -vr ${filename} build/ -x "*.DS_Store"
59+
60+
echo "# Signing Build..."
61+
openssl dgst -sign private-signing-key.pem -sha256 -out ${filename}.sig -binary ${filename}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
}
9696
},
9797
"scripts": {
98-
"package": "./build.sh",
98+
"build": "./build.sh",
9999
"pest": "@php vendor/bin/pest --order-by random --fail-on-risky --parallel --no-progress",
100100
"pest:coverage": "@php vendor/bin/pest --order-by random --fail-on-risky --coverage --parallel --no-progress",
101101
"pest:debug": "@php vendor/bin/pest --log-events-verbose-text pest.log --display-errors --fail-on-risky --no-progress",

scoper.inc.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Finder::create()
1212
->files()
1313
->ignoreVCS(true)
14-
->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.(json|lock)/')
14+
->notName('/.*\\.dist|Makefile|scoper.inc.php|rector.php|opslevel.yml|build.sh|public-signing-key.pub|composer.json|composer.lock/')
1515
->exclude([
1616
'doc',
1717
'test',
@@ -28,7 +28,8 @@
2828
],
2929

3030
'exclude-namespaces' => [
31-
'/^Auth0\\\\WordPress\\\/',
31+
'/^Auth0\\\\WordPress\\\\/',
32+
'/^Auth0\\\\WordPress/',
3233
'/^Psr\\\/',
3334
],
3435

src/Actions/Updates.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class Updates extends Base
1616

1717
public function doUpdateCheck($plugins)
1818
{
19-
trap($plugins);
19+
// trap($plugins);
2020

2121
if (! is_object($plugins)) {
2222
return $plugins;
@@ -26,12 +26,12 @@ public function doUpdateCheck($plugins)
2626
$plugins->response = [];
2727
}
2828

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

3636
return $plugins;
3737
}

updates.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"5.3.0": {
3+
"download": "Auth0_WordPress_5.3.0.zip"
4+
}
5+
}

wpAuth0.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
}
3232

3333
// Load dependencies
34-
if (file_exists(plugin_dir_path(__FILE__) . '/vendor/autoload.php')) {
34+
if (file_exists(plugin_dir_path(__FILE__) . '/vendor/scoper-autoload.php')) {
35+
require_once plugin_dir_path(__FILE__) . '/vendor/autoload.php';
36+
} elseif (file_exists(plugin_dir_path(__FILE__) . '/vendor/autoload.php')) {
3537
require_once plugin_dir_path(__FILE__) . '/vendor/autoload.php';
3638
}
3739

0 commit comments

Comments
 (0)