-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·73 lines (56 loc) · 1.9 KB
/
release.sh
File metadata and controls
executable file
·73 lines (56 loc) · 1.9 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
#!/bin/bash
# Remove the svn-push directory
rm -rf ./svn-push/
# Check if zip file argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <zip_file>"
exit 1
fi
# Extract zip file name from command-line argument
ZIP_FILE=$1
# Check if zip file exists
if [ ! -f "$ZIP_FILE" ]; then
echo "Error: $ZIP_FILE not found."
exit 1
fi
# Extract the directory name from the zip file
DIRECTORY_NAME=$(basename -s .zip "$ZIP_FILE" | sed 's/-[0-9.]*$//')
# Extract version from the filename
VERSION=$(echo "$ZIP_FILE" | sed 's/.*-\([0-9.]*\)\.zip/\1/')
# 1. Create a directory named 'svn-push' in the working directory
mkdir -p ./svn-push/
# Get the SVN link from package.json
SVN_LINK=$(grep '"svn"' package.json | awk -F '"' '{print $4}')
# Check if the tag already exists
if svn ls $SVN_LINK/tags/$VERSION > /dev/null 2>&1; then
# If the tag exists, terminate
echo "$VERSION exists already"
exit 1
fi
# 2. Pull the SVN link using svn
cd ./svn-push
svn checkout $SVN_LINK
cd ../
# 3. Unzip the zip file and extract only the children of the root directory
unzip $ZIP_FILE -d ./svn-push/tmp
# 4. Clear existing trunk directory
cd ./svn-push/$DIRECTORY_NAME
svn delete --force ./trunk/*
cd ../../
# and Move updated codebase to trunk
cp -r ./svn-push/tmp/$DIRECTORY_NAME/* ./svn-push/$DIRECTORY_NAME/trunk/
rm -rf ./svn-push/tmp/
# and add new tag
mkdir -p ./svn-push/$DIRECTORY_NAME/tags/$VERSION/
cp -r ./svn-push/$DIRECTORY_NAME/trunk/* ./svn-push/$DIRECTORY_NAME/tags/$VERSION/
# 5. Add, delete files from svn as per status
cd ./svn-push/$DIRECTORY_NAME/
svn add --force trunk/*
svn add --force tags/*
svn status | awk '/^\?/ {print $2}' | xargs svn add
svn status | awk '$1 == "!" {print $2}' | xargs -r svn delete
# 6. Commit finally
svn commit -m "Adding $DIRECTORY_NAME plugin version $VERSION" --username $SVN_USERNAME --password $SVN_PASSWORD
cd ../../
# 7. Remove the svn-push directory
rm -rf ./svn-push/