├── deploy.sh └── README.md /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [[ "false" != "$TRAVIS_PULL_REQUEST" ]]; then 6 | echo "Not deploying pull requests." 7 | exit 8 | fi 9 | 10 | if [[ ! $WP_PULUGIN_DEPLOY ]]; then 11 | echo "Not deploying." 12 | exit 13 | fi 14 | 15 | if [[ ! $SVN_REPO ]]; then 16 | echo "SVN repo is not specified." 17 | exit 18 | fi 19 | 20 | # Untrailing slash of SVN_REPO path 21 | SVN_REPO=`echo $SVN_REPO | sed -e "s/\/$//"` 22 | # Git repository 23 | GH_REF=https://github.com/${TRAVIS_REPO_SLUG}.git 24 | 25 | echo "Starting deploy..." 26 | 27 | mkdir build 28 | 29 | cd build 30 | BASE_DIR=$(pwd) 31 | 32 | echo "Checking out trunk from $SVN_REPO ..." 33 | svn co -q $SVN_REPO/trunk 34 | 35 | echo "Getting clone from $GH_REF to $SVN_REPO ..." 36 | git clone -q $GH_REF ./git 37 | 38 | cd ./git 39 | 40 | if [ -e "bin/build.sh" ]; then 41 | echo "Starting bin/build.sh." 42 | bash bin/build.sh 43 | fi 44 | 45 | cd $BASE_DIR 46 | 47 | echo "Syncing git repository to svn" 48 | rsync -a --exclude=".svn" --checksum --delete ./git/ ./trunk/ 49 | rm -fr ./git 50 | 51 | cd ./trunk 52 | 53 | if [ -e ".distignore" ]; then 54 | echo "svn propset form .distignore" 55 | svn propset -q -R svn:ignore -F .distignore . 56 | 57 | else 58 | if [ -e ".svnignore" ]; then 59 | echo "svn propset" 60 | svn propset -q -R svn:ignore -F .svnignore . 61 | fi 62 | fi 63 | 64 | echo "Run svn del for modified and missing directories." 65 | svn st | grep '^!M' | sed -e 's/\!M[ ]*/svn del -q /g' | sh 66 | echo "Run svn del for missing files and directories." 67 | svn st | grep '^!' | sed -e 's/\![ ]*/svn del -q /g' | sh 68 | echo "Run svn add" 69 | svn st | grep '^?' | sed -e 's/\?[ ]*/svn add -q /g' | sh 70 | 71 | # If tag number and credentials are provided, commit to trunk. 72 | if [[ $TRAVIS_TAG && $SVN_USER && $SVN_PASS ]]; then 73 | if [[ ! -d tags/$TRAVIS_TAG ]]; then 74 | echo "Commit to $SVN_REPO." 75 | svn commit -m "commit version $TRAVIS_TAG" --username $SVN_USER --password $SVN_PASS --non-interactive 2>/dev/null 76 | echo "Take snapshot of $TRAVIS_TAG" 77 | svn copy $SVN_REPO/trunk $SVN_REPO/tags/$TRAVIS_TAG -m "Take snapshot of $TRAVIS_TAG" --username $SVN_USER --password $SVN_PASS --non-interactive 2>/dev/null 78 | else 79 | echo "tags/$TRAVIS_TAG already exists." 80 | fi 81 | else 82 | echo "Nothing to commit and check \`svn st\`." 83 | svn st 84 | fi 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Automated deploy to wordpress.org plugin repository from Travis CI 2 | 3 | ## How to setup 4 | 5 | ### Please add following lines into `.travis.yml`. 6 | 7 | Deployment should be executed only `after_success`. 8 | 9 | ``` 10 | after_success: curl -L https://raw.githubusercontent.com/miya0001/travis2wpplugin/master/deploy.sh | bash 11 | ``` 12 | 13 | This script will run when `WP_PULUGIN_DEPLOY` is `true`. 14 | 15 | ``` 16 | matrix: 17 | include: 18 | - php: 5.3 19 | env: WP_VERSION=latest WP_MULTISITE=0 WP_PULUGIN_DEPLOY=1 20 | ``` 21 | 22 | Finally, please add environments variables like following in global section. 23 | 24 | ``` 25 | env: 26 | global: 27 | - SVN_REPO: https://plugins.svn.wordpress.org// 28 | - secure: "xxxxxxxx" 29 | ``` 30 | 31 | You can get `secure` value like following. 32 | 33 | ``` 34 | travis encrypt SVN_USER= SVN_PASS= 35 | ``` 36 | 37 | http://docs.travis-ci.com/user/encryption-keys/ 38 | 39 | ### `.svnignore` 40 | 41 | Example of .svnignore is following. 42 | 43 | https://github.com/miya0001/wp-svnignore 44 | 45 | Add your `.svnignore` like following projects 46 | 47 | https://github.com/miya0001/simple-map 48 | 49 | This script runs `svn propset -R` automatically when there is a `.svnignore`. 50 | 51 | ### `bin/build.sh` 52 | 53 | If you are using `gulp`, `composer` or so, please place the `bin/build.sh`. 54 | 55 | `bin/build.sh` will be executed automatically. 56 | 57 | ## How to commit 58 | 59 | When you tag like following, then it will run commit to plugin's repository on wordpress.org. 60 | 61 | ``` 62 | $ git tag 1.0.0 63 | $ git push origin 1.0.0 64 | ``` 65 | 66 | Tag and plugin's version need to be same. 67 | 68 | ## Integration Checklist 69 | 70 | You can use following checklist to integrate this project in your plugin. 71 | 72 | * [ ] Add `after_success: curl -L https://raw.githubusercontent.com/miya0001/travis2wpplugin/master/deploy.sh | bash` into `.travis.yml` like [this](https://github.com/tarosky/logbook/blob/master/.travis.yml#L57). 73 | * [ ] Define the `WP_PULUGIN_DEPLOY=1` in the `.travis.yml` like [this](https://github.com/tarosky/logbook/blob/master/.travis.yml#L14). 74 | * [ ] Run `travis encrypt SVN_USER= SVN_PASS=` and paste the output into `.travis.yml` like [this](https://github.com/tarosky/logbook/blob/master/.travis.yml#L43-L46). 75 | * [ ] Place the `.distignore` that are list of files to exclude to commit SVN. It is an [example](https://github.com/tarosky/logbook/blob/master/.distignore). 76 | * [ ] If you need to run `npm install` or `composer install` or so, place the `build.sh` that will be executed automatically. This is an [example](https://github.com/tarosky/logbook/blob/master/bin/build.sh). 77 | 78 | Finnaly, you can release your plugin like following. 79 | 80 | ``` 81 | $ git tag 1.0.0 82 | $ git push origin 1.0.0 83 | ``` 84 | 85 | ## Example project 86 | 87 | We are using this project in following plugins. 88 | 89 | Please check logs of Travis CI. 90 | 91 | * https://github.com/miya0001/simple-map 92 | * https://github.com/miya0001/oembed-gist 93 | * https://github.com/miya0001/content-template-engine 94 | * https://github.com/miya0001/wp-total-hacks 95 | * https://github.com/torounit/hello-kushimoto/ 96 | --------------------------------------------------------------------------------