Skip to content

Commit c583d58

Browse files
committed
Initial release
1 parent 97e3960 commit c583d58

File tree

2 files changed

+226
-0
lines changed

2 files changed

+226
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Github to WordPress.org Deployment Script
2+
Releasing plugins can be quite a chore for me so after some research I found release scripts that other developers were using to deploy their plugin releases without the fuss. I tried a few and the best one was done by [@MikeJolley](https://github.com/mikejolley/github-to-wordpress-deploy-script), however it did not seem to work 100% for me so I experimented and wrote a version that does it a little bit different.
3+
4+
This script is dummy proof. No need to configure anything. Just run the script and follow the instructions as you go along.
5+
6+
## What does the script do?
7+
This script will pull down your remote GIT and SVN repositories, tag a release using the branch you specify, and commit everything to WordPress.org.
8+
9+
Before or that it asks a few questions to setup the process of the script such as the ROOT Path of the plugin your GitHub username, repository slug and so on.
10+
11+
When it comes to ask for which version you want to release it checks if it has already been tagged before continuing the rest of the script.
12+
13+
To use it you must:
14+
15+
1. Host your code on GitHub
16+
2. Already have a WordPress.org SVN repository setup for your plugin.
17+
3. Have both GIT and SVN setup on your machine and available from the command line.
18+
19+
## Getting started
20+
21+
All you have to do is download the script release.sh from this repository and place it in a location of your choosing.
22+
23+
## Usage
24+
25+
1. Open up terminal and cd to the directory containing the script.
26+
2. Run: ```sh release.sh```
27+
3. Follow the prompts.
28+
29+
## Final notes
30+
31+
- This will checkout the remote version of your Github Repo.
32+
- Committing to WordPress.org can take a while so be patient.
33+
- I have tested this on Mac only.
34+
- Use at your own risk of course :)

release.sh

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
#!/bin/sh
2+
3+
set -e
4+
clear
5+
6+
# ASK INFO
7+
echo "---------------------------------------------------------------------"
8+
echo " GitHub to WordPress.org RELEASER "
9+
echo "---------------------------------------------------------------------"
10+
read -p "Enter the ROOT PATH of the plugin you want to release: " ROOT_PATH
11+
echo "---------------------------------------------------------------------"
12+
read -p "Tag and Release Version: " VERSION
13+
echo "---------------------------------------------------------------------"
14+
echo ""
15+
echo "Before continuing, confirm that you have done the following :"
16+
echo ""
17+
read -p " - Added a changelog for v"${VERSION}"?"
18+
read -p " - Set version in the readme.txt and main file to v"${VERSION}"?"
19+
read -p " - Set stable tag in the readme.txt file to v"${VERSION}"?"
20+
read -p " - Updated the POT file?"
21+
read -p " - Committed all changes up to GitHub?"
22+
echo ""
23+
read -p "Press [ENTER] to begin releasing v"${VERSION}
24+
clear
25+
26+
# Check if version is already released.
27+
if $ROOT_PATH git show-ref --tags | egrep -q "refs/tags/v${VERSION}"
28+
then
29+
echo "Version already tagged and released.";
30+
echo ""
31+
echo "Run sh release.sh again and enter another version.";
32+
exit 1;
33+
else
34+
echo ""
35+
echo "v${VERSION} has not been found released.";
36+
fi
37+
38+
read -p "Enter the WordPress plugin slug: " SVN_REPO_SLUG
39+
clear
40+
41+
echo "Now processing..."
42+
43+
SVN_REPO_URL="https://plugins.svn.wordpress.org"
44+
45+
# Set WordPress.org Plugin URL
46+
SVN_REPO=$SVN_REPO_URL"/"$SVN_REPO_SLUG"/"
47+
48+
# Set temporary SVN folder for WordPress release.
49+
TEMP_SVN_REPO=${SVN_REPO_SLUG}"-svn"
50+
51+
# Delete old SVN cache just incase it was not cleaned before after the last release.
52+
rm -Rf $ROOT_PATH$TEMP_SVN_REPO
53+
54+
# CHECKOUT SVN DIR IF NOT EXISTS
55+
if [[ ! -d $TEMP_SVN_REPO ]];
56+
then
57+
echo "Checking out WordPress.org plugin repository."
58+
svn checkout $SVN_REPO $TEMP_SVN_REPO || { echo "Unable to checkout repo."; exit 1; }
59+
fi
60+
61+
read -p "Enter your GitHub username: " GITHUB_USER
62+
clear
63+
64+
read -p "Now enter the repository slug: " GITHUB_REPO_NAME
65+
clear
66+
67+
# Set temporary folder for GitHub release.
68+
TEMP_GITHUB_REPO=${GITHUB_REPO_NAME}"-git"
69+
70+
# Delete old GitHub cache just incase it was not cleaned before after the last release.
71+
rm -Rf $ROOT_PATH$TEMP_GITHUB_REPO
72+
73+
# Set GitHub Repository URL
74+
GIT_REPO="https://github.com/"${GITHUB_USER}"/"${GITHUB_REPO_NAME}".git"
75+
76+
# CLONE GIT DIR
77+
echo "Cloning GIT repository from GitHub"
78+
git clone --progress $GIT_REPO $TEMP_GITHUB_REPO || { echo "Unable to clone repo."; exit 1; }
79+
80+
# MOVE INTO GIT DIR
81+
cd $ROOT_PATH$TEMP_GITHUB_REPO
82+
83+
# LIST BRANCHES
84+
clear
85+
git fetch origin
86+
echo "Which branch do you wish to release?"
87+
git branch -r || { echo "Unable to list branches."; exit 1; }
88+
echo ""
89+
read -p "origin/" BRANCH
90+
91+
# Switch Branch
92+
echo "Switching to branch"
93+
git checkout ${BRANCH} || { echo "Unable to checkout branch."; exit 1; }
94+
95+
echo ""
96+
read -p "Press [ENTER] to deploy branch "${BRANCH}
97+
98+
# REMOVE UNWANTED FILES & FOLDERS
99+
echo "Removing unwanted files"
100+
rm -Rf .git
101+
rm -Rf .github
102+
rm -Rf tests
103+
rm -Rf apigen
104+
rm -f .gitattributes
105+
rm -f .gitignore
106+
rm -f .gitmodules
107+
rm -f .travis.yml
108+
rm -f Gruntfile.js
109+
rm -f package.json
110+
rm -f .jscrsrc
111+
rm -f .jshintrc
112+
rm -f composer.json
113+
rm -f phpunit.xml
114+
rm -f phpunit.xml.dist
115+
rm -f README.md
116+
rm -f .coveralls.yml
117+
rm -f .editorconfig
118+
rm -f .scrutinizer.yml
119+
rm -f apigen.neon
120+
rm -f CHANGELOG.md
121+
rm -f CONTRIBUTING.md
122+
rm -f Theme-Presets.md
123+
rm -f screenshot-*.png
124+
rm -f release.sh
125+
126+
# MOVE INTO SVN DIR
127+
cd "../"$TEMP_SVN_REPO
128+
129+
# UPDATE SVN
130+
echo "Updating SVN"
131+
svn update || { echo "Unable to update SVN."; exit 1; }
132+
133+
# DELETE TRUNK
134+
echo "Replacing trunk"
135+
rm -Rf trunk/
136+
137+
# COPY GIT DIR TO TRUNK
138+
cp -R "../"$TEMP_GITHUB_REPO trunk/
139+
140+
# DO THE ADD ALL NOT KNOWN FILES UNIX COMMAND
141+
svn add --force * --auto-props --parents --depth infinity -q
142+
143+
# DO THE REMOVE ALL DELETED FILES UNIX COMMAND
144+
MISSING_PATHS=$( svn status | sed -e '/^!/!d' -e 's/^!//' )
145+
146+
# iterate over filepaths
147+
for MISSING_PATH in $MISSING_PATHS; do
148+
svn rm --force "$MISSING_PATH"
149+
done
150+
151+
# COPY TRUNK TO TAGS/$VERSION
152+
echo "Copying trunk to new tag"
153+
svn copy trunk tags/${VERSION} || { echo "Unable to create tag."; exit 1; }
154+
155+
# DO SVN COMMIT
156+
clear
157+
echo "Showing SVN status"
158+
svn status
159+
160+
# PROMPT USER
161+
echo ""
162+
read -p "Press [ENTER] to commit release "${VERSION}" to WordPress.org AND GitHub"
163+
echo ""
164+
165+
# CREATE THE GITHUB RELEASE
166+
echo "Creating release on GitHub repository."
167+
cd "$GITPATH"
168+
169+
echo "Tagging new version in git"
170+
git tag -a "v${VERSION}" -m "Tagging version v${VERSION}"
171+
172+
echo "Pushing latest commit to origin, with tags"
173+
git push origin master
174+
git push origin master --tags
175+
176+
# DEPLOY
177+
echo ""
178+
echo "Committing to WordPress.org... this may take a while..."
179+
svn commit -m "Releasing "${VERSION}"" || { echo "Unable to commit."; exit 1; }
180+
181+
# REMOVE THE TEMP DIRS
182+
echo "Cleaning Up..."
183+
cd "../"
184+
rm -Rf $ROOT_PATH$TEMP_GITHUB_REPO
185+
rm -Rf $ROOT_PATH$TEMP_SVN_REPO
186+
187+
# DONE
188+
echo "Release Done."
189+
echo ""
190+
read -p "Press [ENTER] to close program."
191+
192+
clear

0 commit comments

Comments
 (0)