forked from mrauhu/web-typography-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
109 lines (90 loc) · 2.22 KB
/
deploy.sh
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
104
105
106
107
108
109
#!/usr/bin/env bash
#
# release.sh
#
# Takes a tag to release, and syncs it to WordPress.org
#
# Based on https://github.com/toolstack/git-to-wp-plugin-dir-release-script
# Added comparability with Windows Git Bash based on MinGW
#
# Usage:
# ./release.sh tag svn-username svn-password
#
TAG=$1
USERNAME=$2
PASSWORD=$3
PLUGIN="ram108-typo"
TMPDIR=./tmp
PLUGINDIR="$PWD"
PLUGINSVN="https://plugins.svn.wordpress.org/$PLUGIN"
TMPTAR="tmp.tar"
# Fail on any error
set -e
# Is the tag valid?
if [ -z "$TAG" ] || ! git rev-parse "$TAG" > /dev/null; then
echo "Invalid tag. Make sure you tag before trying to release."
exit 1
fi
# Username
if [ -z "$USERNAME" ]; then
echo "Empty Wordpress SVN username"
exit 1
fi
# Password
if [ -z "$PASSWORD" ]; then
echo "Empty Wordpress SVN password"
exit 1
fi
if [[ ${TAG} == "v*" ]]; then
# Starts with an extra "v", strip for the version
VERSION=${TAG:1}
else
VERSION="$TAG"
fi
if [ -d "$TMPDIR" ]; then
# Wipe it clean
rm -r "$TMPDIR"
fi
# Ensure the directory exists first
mkdir "$TMPDIR"
# Grab an unadulterated copy of SVN
svn co "$PLUGINSVN/trunk" "$TMPDIR" > /dev/null
# Extract files from the Git tag to temporary tar file
git archive --format="tar" "$TAG" > "$TMPTAR"
# Move temporary tar file to build dir
mv "$TMPTAR" "$TMPDIR/$TMPTAR"
# Switch to build dir
cd "$TMPDIR"
# Extract files
tar -xf "$TMPTAR"
# Remove temporary tar
rm "$TMPTAR"
# Run build tasks
#sed -e "s/{{TAG}}/$VERSION/g" < "$PLUGINDIR/bin/readme.txt" > readme.txt
# Remove special files
#rm ".gitignore"
#rm ".scrutinizer.yml"
#rm ".travis.yml"
#rm "composer.json"
#rm "Gruntfile.js"
#rm "package.json"
#rm "phpcs.ruleset.xml"
#rm "phpunit.xml.dist"
#rm "multisite.xml"
#rm "codecoverage.xml"
#rm -r "assets"
#rm -r "bin"
#rm -r "tests"
# Add any new files
#svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
svn add --force .
# Pause to allow checking
echo "About to commit $VERSION. Double-check $TMPDIR to make sure everything looks fine."
read -p "Hit Enter to continue."
# Commit the changes
svn commit -m "Trunk $VERSION" --username ${USERNAME} --password ${PASSWORD}
# tag_ur_it
svn copy "$PLUGINSVN/trunk" "$PLUGINSVN/tags/$VERSION" -m "Tag $VERSION"
# Clean tmp dir
cd ..
rm -r "$TMPDIR"