Repository navigation
Expand file tree
/
Copy pathbuild-release.sh
More file actions
executable file
·103 lines (86 loc) · 2.47 KB
/
Copy pathbuild-release.sh
File metadata and controls
executable file
·103 lines (86 loc) · 2.47 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env sh
set -eu
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
REPOSITORY_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
PLUGIN_DIR=${1:-"$REPOSITORY_ROOT/plugins/basicrum"}
RELEASE_DIR=${2:-"$REPOSITORY_ROOT/release"}
PLUGIN_SLUG=basicrum-real-user-monitoring
ARCHIVE_NAME="${PLUGIN_SLUG}.zip"
ARCHIVE_PATH="$RELEASE_DIR/$ARCHIVE_NAME"
CHECKSUM_PATH="$ARCHIVE_PATH.sha256"
if [ ! -f "$PLUGIN_DIR/basicrum.php" ] || [ ! -f "$PLUGIN_DIR/.distignore" ]; then
printf '%s\n' "Plugin source is incomplete: $PLUGIN_DIR" >&2
exit 1
fi
for required_command in composer rsync zip; do
if ! command -v "$required_command" >/dev/null 2>&1; then
printf '%s\n' "Required command is not installed: $required_command" >&2
exit 1
fi
done
mkdir -p "$RELEASE_DIR"
STAGING_DIR=$(mktemp -d "${TMPDIR:-/tmp}/basicrum-release.XXXXXX")
cleanup() {
rm -rf "$STAGING_DIR"
}
trap cleanup EXIT HUP INT TERM
BUILD_DIR="$STAGING_DIR/build"
PACKAGE_DIR="$STAGING_DIR/package"
mkdir -p "$BUILD_DIR" "$PACKAGE_DIR/$PLUGIN_SLUG"
rsync -rc \
--delete \
--exclude='/vendor/' \
"$PLUGIN_DIR/" \
"$BUILD_DIR/"
(
cd "$BUILD_DIR"
composer install \
--no-dev \
--no-interaction \
--no-progress \
--prefer-dist \
--classmap-authoritative
)
# composer/installers only places this package when a Composer project installs
# it as a dependency. It has no role inside an installed plugin, so remove it
# from the staged tree so that the shipped vendor directory, class map, and
# Composer metadata all agree, then restore the manifest the repository ships.
(
cd "$BUILD_DIR"
composer remove composer/installers \
--no-interaction \
--no-progress \
--no-plugins \
--no-scripts \
--update-no-dev \
--classmap-authoritative
)
cp "$PLUGIN_DIR/composer.json" "$BUILD_DIR/composer.json"
rsync -rc \
--delete \
--delete-excluded \
--exclude-from="$PLUGIN_DIR/.distignore" \
"$BUILD_DIR/" \
"$PACKAGE_DIR/$PLUGIN_SLUG/"
rm -f "$ARCHIVE_PATH" "$CHECKSUM_PATH"
(
cd "$PACKAGE_DIR"
zip -qr "$ARCHIVE_PATH" "$PLUGIN_SLUG"
)
if command -v sha256sum >/dev/null 2>&1; then
(
cd "$RELEASE_DIR"
sha256sum "$ARCHIVE_NAME" > "$ARCHIVE_NAME.sha256"
)
elif command -v shasum >/dev/null 2>&1; then
(
cd "$RELEASE_DIR"
shasum -a 256 "$ARCHIVE_NAME" > "$ARCHIVE_NAME.sha256"
)
else
printf '%s\n' 'Neither sha256sum nor shasum is installed.' >&2
exit 1
fi
sh "$SCRIPT_DIR/verify-release.sh" "$ARCHIVE_PATH"
printf '%s\n' "Release archive: $ARCHIVE_PATH"
printf '%s\n' "SHA-256 checksum: $CHECKSUM_PATH"