Repository navigation
Expand file tree
/
Copy pathcreate_release.sh
More file actions
46 lines (43 loc) · 2.11 KB
/
Copy pathcreate_release.sh
File metadata and controls
46 lines (43 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
# Read the version from the plugin header, so the SVN tag always matches the code.
version=$(sed -n -E 's/^[[:space:]]*\*[[:space:]]*Version:[[:space:]]*([0-9][0-9A-Za-z.+-]*)[[:space:]]*$/\1/p' reactpress.php | head -n 1)
stable_tag=$(sed -n -E 's/^Stable tag:[[:space:]]*([^[:space:]]+)[[:space:]]*$/\1/p' README.txt | head -n 1)
constant_version=$(sed -n -E 's/^define\("REPR_VERSION", "([^"]+)"\);/\1/p' reactpress.php | head -n 1)
if [ -z "$version" ]; then
echo "Could not read Version from reactpress.php" >&2
exit 1
fi
if [ "$version" != "$stable_tag" ] || [ "$version" != "$constant_version" ]; then
echo "Version mismatch: header=$version, README Stable tag=$stable_tag, REPR_VERSION=$constant_version" >&2
exit 1
fi
echo "Creating release $version"
# We don't want a ton of dev dependencies in our release.
composer install --no-dev --optimize-autoloader
build=/tmp/reactpress-svn
tag_dir=$build/tags/$version
rm -rf "$build"
mkdir -p "$tag_dir"
cp -r ./ "$tag_dir/"
rm -rf "$tag_dir/assets"
# Dev-only files that are not allowed / not needed in the WordPress.org release.
rm -rf "$tag_dir/tests" "$tag_dir/vendor/bin"
rm -f "$tag_dir/phpstan.neon" "$tag_dir/create_release.sh" "$tag_dir/composer.lock" "$tag_dir/README.md"
# All hidden files and folders (.git, .gitignore, .vscode, .cursor, .claude, .phpactor.json, .DS_Store, caches, ...).
find "$tag_dir" -mindepth 1 -name '.*' -prune -exec rm -rf {} +
# Admin React app: only the build output is shipped.
find "$tag_dir/admin/js/reactpress-admin" -mindepth 1 -maxdepth 1 ! -name build -exec rm -rf {} +
# Fail if anything that Plugin Check rejects slipped through.
leftovers=$(find "$tag_dir" \( -name '.*' -o -name '*.sh' -o -name node_modules -o -name tests \) -print)
if [ -n "$leftovers" ]; then
echo "Release contains files that must not be shipped:" >&2
echo "$leftovers" >&2
composer install
exit 1
fi
rm -rf "$build/trunk"
cp -r "$tag_dir" "$build/trunk"
# Reinstall dev dependencies to be able to work on ReactPress again
composer install
echo "Release $version built in $build (tags/$version and trunk)"