Skip to content

Commit

Permalink
Merge pull request #238 from yangyao/master
Browse files Browse the repository at this point in the history
Add an build & deploy script
  • Loading branch information
yangyao authored Sep 10, 2024
2 parents f114e78 + 55fc3e6 commit 20e50a4
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

svn_url="http://plugins.svn.wordpress.org/aftership-woocommerce-tracking"
git_url="[email protected]:AfterShip/aftership-apps-woocommerce.git"

git_tmp_dir=$(mktemp -d)
git clone $git_url $git_tmp_dir

# get version number from readme.txt
version=$(sed -n '7p' "$git_tmp_dir/readme.txt" | cut -c 13-)

echo "Version number is $version"

build_dir="../build/$version"

# if build directory exists, remove it
if [ -d "$build_dir" ]; then
rm -rf "$build_dir"
fi

mkdir -p "$build_dir"

# move all files from git to build directory
cp "$git_tmp_dir"/aftership-woocommerce-tracking.php "$build_dir"
mkdir -p "$build_dir/assets/frontend"
mkdir -p "$build_dir/assets/frontendv2"
cp -r "$git_tmp_dir"/assets/frontend/dist "$build_dir/assets/frontend"
cp -r "$git_tmp_dir"/assets/frontendv2/dist "$build_dir/assets/frontendv2"
cp -r "$git_tmp_dir"/assets/css "$build_dir/assets"
cp -r "$git_tmp_dir"/assets/js "$build_dir/assets"
cp -r "$git_tmp_dir"/assets/images "$build_dir/assets"
cp -r "$git_tmp_dir"/assets/plugin "$build_dir/assets"
cp -r "$git_tmp_dir"/assets/*.png "$build_dir/assets"
cp -r "$git_tmp_dir"/includes "$build_dir"
cp -r "$git_tmp_dir"/templates "$build_dir"
cp -r "$git_tmp_dir"/views "$build_dir"
cp -r "$git_tmp_dir"/woo-includes "$build_dir"
cp -r "$git_tmp_dir"/aftership.php "$build_dir"
cp -r "$git_tmp_dir"/aftership-woocommerce-tracking.php "$build_dir"
cp -r "$git_tmp_dir"/readme.txt "$build_dir"

# remove git temporary directory
rm -rf "$git_tmp_dir"

# check script parameters if it want to deploy to SVN
if [ "$1" != "deploy" ]; then
echo "Build completed. Run 'sh scripts/build.sh deploy' to deploy to SVN."
exit 0
fi

# deploy to SVN
svn_tmp_dir=$(mktemp -d)
svn checkout $svn_url $svn_tmp_dir

# check if already deployed to svn
if [ -d "$svn_tmp_dir/tags/$version" ]; then
echo "Version $version already exists in SVN. Please update version number in readme.txt."
exit 1
fi

rm -rf "$svn_tmp_dir/trunk/*"
mkdir -p "$svn_tmp_dir/tags/$version"

cp -r "$build_dir/*" "$svn_tmp_dir/trunk"
cp -r "$build_dir/*" "$svn_tmp_dir/tags/$version"

cd "$svn_tmp_dir" && svn add . --force && svn ci -m "Version $version" --username aftership --force-interactive

echo "Process completed."

0 comments on commit 20e50a4

Please sign in to comment.