-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patharchive.sh
More file actions
executable file
·62 lines (42 loc) · 1.56 KB
/
archive.sh
File metadata and controls
executable file
·62 lines (42 loc) · 1.56 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
#!/usr/bin/env bash
# Get current directory of the script
ROOT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
# Extract version from the plugin.xml file
VERSION_RAW="$(sed -n 's|<version>\(.*\)</version>|\1|p' ./FinSearchUnified/plugin.xml)"
# Trim the whitespaces from the version otherwise it would cause problems
# in creating the archive zip file
VERSION="$(echo -e "${VERSION_RAW}" | tr -d '[:space:]')"
echo "Version: ${VERSION}"
STASH=$(git stash)
echo ${STASH}
git fetch --all --tags --prune
TAG=$(git tag -l "v${VERSION}")
# Get current working branch
BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
# If tag is available we proceed with the checkout and zip commands
# else exit with code 1
if [[ -z "${TAG}" ]]; then
echo "[ERROR]: Tag ${TAG} not found"
exit 1
fi
git checkout tags/${TAG}
# Copying plugins files
echo "Copying files ... "
cp -rf ./FinSearchUnified/ /tmp/FinSearchUnified
# Get into the created directory for running the archive command
cd /tmp/FinSearchUnified
# Install dependencies
composer install --no-dev
cd /tmp
# Run archive command to create the zip in the root directory
zip -r9 ${ROOT_DIR}/FinSearchUnified-${VERSION}.zip FinSearchUnified -x FinSearchUnified/phpunit.xml.dist \
FinSearchUnified/shopware-phpcs.xml FinSearchUnified/Tests/\*
# Delete the directory after script execution
rm -rf "/tmp/FinSearchUnified"
cd ${ROOT_DIR}
echo "Restoring work in progress ... "
git checkout ${BRANCH}
# Only apply stash if there are some local changes
if [[ ${STASH} != "No local changes to save" ]]; then
git stash pop
fi