Compare commits

...

171 commits

Author SHA1 Message Date
Karl Freeman 243ab38b08 tidy up changelog [ci skip] 2015-08-16 19:27:24 +01:00
Karl Freeman 32d7897b66 2.0.0-alpha
closes #93
2015-08-16 19:09:26 +01:00
Karl Freeman 9cd8988a66 not needed 2015-08-16 19:08:07 +01:00
Karl Freeman 86f76b2a53 tidy up 2015-08-16 19:06:10 +01:00
Karl Freeman 751c11f6eb Merge pull request #87 from emilioforrer/development
Fixing compatibility issues with middleman v4.0.0.beta.1
2015-08-16 18:56:58 +01:00
Emilio Forrer c590d005cf Fixing cucumber failed test 2015-02-22 22:09:54 -06:00
Emilio Forrer 1806c9263b Fixing dependency error while activating asset_hash and validated middleman version 2015-02-22 21:56:53 -06:00
Emilio Forrer a8c6fdafef Fixing dependency error while activating asset_hash 2015-02-22 21:18:59 -06:00
Emilio Forrer 9eece01aef Fixing compatibility issues with middleman v4.0.0.beta.1 2015-02-22 15:52:52 -06:00
Karl Freeman 000cabda96 Merge pull request #84 from Aupajo/fix/git-email-in-force-push
Fix Git user.email change in force push strategy
2015-01-18 10:22:37 +00:00
Pete Nicholls 4b79845d53 Fix Git user.email change in force push strategy 2015-01-18 14:51:25 +13:00
Karl Freeman 21d04f253a latest travis 2014-11-21 18:25:10 +00:00
Karl Freeman 7360fcadc4 1.0 2014-11-21 17:26:59 +00:00
Karl Freeman bd5e214614 Merge pull request #70 from Gee-Bee/git-user-details
Respect user details of git repo.
2014-11-21 17:08:03 +00:00
Karl Freeman 217af0d33c Merge pull request #77 from mconnell/master
Prevent bad commits deploying. (git)
2014-11-21 17:07:11 +00:00
Karl Freeman 8a0bfaec2b RuboCop 2014-11-21 17:00:23 +00:00
Mark Connell 79d86af7be Prevent bad commits deploying.
In the event of a fatal error occuring when trying to add content to
git for commit, you end up pushing a blank commit to the git respository.
This is a change which halts the push to a git repository so you don't
accidentally take down your website.
2014-09-04 11:25:57 +01:00
Karl Freeman b84f69f54a Merge pull request #74 from philippbosch/patch-1
Fix version number in installation instructions
2014-08-19 15:50:33 +01:00
Philipp Bosch c466746266 Fix version number in installation instructions 2014-08-19 16:12:24 +02:00
Karl Freeman 546542032f changelog 2014-08-14 11:38:48 +01:00
Karl Freeman 5486033a11 Merge branch 'master' of github.com:karlfreeman/middleman-deploy 2014-08-14 11:36:13 +01:00
Karl Freeman 70863dc312 bump 2014-08-14 11:34:48 +01:00
Karl Freeman 6e7ce4d72d Merge branch 'cleanup/major'
Conflicts:
	README.md
2014-08-14 11:32:14 +01:00
Karl Freeman e14f90fe1d cleanup 2014-08-14 11:18:58 +01:00
Karl Freeman 359f7d7431 Merge pull request #71 from statonjr/patch-1
Fix ArgumentError in SFTP
2014-08-08 09:09:05 +01:00
Larry Staton Jr. 2aba441a30 Update sftp.rb
Fix ArgumentError on exception. Line 55 had 2 arguments, but the `handle_exception` method in line 30 only required 1 argument.
2014-07-20 18:11:30 -04:00
Gee-Bee bfe6473000 Fix comment. 2014-07-18 09:35:27 +02:00
Gee-Bee 4f9d4879d7 Respect user details of git repo.
Branch with compiled pages respects repo's user details settings.
2014-07-16 10:56:58 +02:00
Karl Freeman 84b3cb0121 no longer needed 👍 2014-05-28 11:11:59 +01:00
Tom Vaughan 71c4e6339b Bump. 2014-05-25 02:07:26 -04:00
Tom Vaughan b8069d3144 Help! I still need somebody! 2014-05-24 15:22:05 -04:00
Tom Vaughan fa339eba4f Help! I need somebody! 2014-05-24 15:19:25 -04:00
Tom Vaughan 84e86e2530 Merge pull request #65 from NARKOZ/custom-commit-message
add ability to set custom commit message for git deploys
2014-05-24 14:55:38 -04:00
Nihad Abbasov efd66e7fca add ability to set custom commit message for git deploys
issue #64
2014-05-24 23:35:14 +05:00
Tom Vaughan 08e392fc6b Merge pull request #60 from jackcasey/master
Tiny change to README to suggest using 'system' over 'exec'
2014-03-20 10:23:58 -05:00
Jack Casey 4fe4526807 Tiny change to README to suggest using 'system' over 'exec'
Reason being, 'exec' will run the shell command and then exit the ruby
process. While 'system will run the shell command and then continue
execution.

I feel this is a better example as the first thing I did was write a
rake task that chains multiple tasks together and the way 'exec' was
ending the process cost me a bit of time trouble shooting why.
2014-03-20 23:10:03 +08:00
Tom Vaughan 6c426c0ef3 bump 2014-02-26 08:39:50 -03:00
Tom Vaughan c381b6448f Merge pull request #59 from andlum/replacing-run-with-exec-in-rsync
No method 'run' in rsync.rb
2014-02-26 08:38:34 -03:00
Andrew Lum da58498102 Update rsync.rb 2014-02-26 19:04:08 +08:00
Tom Vaughan d494a4faf7 bump 2014-02-23 19:00:00 -03:00
Tom Vaughan dca25529a3 Merge pull request #57 from crtvhd/master
Use binary transfer mode for all files to prevent corrupt images when deploying via FTP
2014-02-23 18:58:34 -03:00
Martin Wessely 774e656cfa Upload all files as binary to prevent corrupt images 2014-02-23 22:07:30 +01:00
Tom Vaughan 8226bba8b3 bump 2014-02-23 13:52:02 -03:00
Tom Vaughan e729af6b02 Merge pull request #56 from xinminlabs/master
add port reader for ftp method
2014-02-23 13:51:07 -03:00
Richard Huang 0bd94419ea add port reader for ftp method 2014-02-24 00:44:11 +08:00
Tom Vaughan e89b403ad8 bump 2014-02-23 11:36:02 -03:00
Tom Vaughan 865b98f1c0 Ensure -e ssh ... is always passed to rsync. Fixes #54 2014-02-23 11:27:50 -03:00
Tom Vaughan c22ff4bc15 Merge pull request #52 from whitetrefoil/master
Why not let the port of SFTP configurable?
2014-02-23 11:09:15 -03:00
Tom Vaughan 1d120c0112 Merge pull request #55 from derek-watson/features/environments_readme
Multiple Environments readme
2014-02-23 11:07:04 -03:00
Derek Watson ae68d40616 whitespace 2014-02-22 23:24:54 -05:00
Derek Watson dbaef1ead7 refined language 2014-02-22 23:23:27 -05:00
Derek Watson 669763b878 rmeoved conflicts 2014-02-22 23:22:24 -05:00
Derek Watson 4e46a4e3e7 Merge branch 'features/environments_readme' of github.com:derek-watson/middleman-deploy into features/environments_readme
Conflicts:
	README.md
2014-02-22 23:19:34 -05:00
Derek Watson a7e90214f2 documented multiple environment config 2014-02-22 23:18:38 -05:00
Derek Watson 260665eef9 documented multiple environment config 2014-02-22 23:13:13 -05:00
WhiteTrefoil 08875eebec Supporting port config of SFTP 2014-01-18 21:55:50 +08:00
Tom Vaughan 83c24d7443 Merge pull request #53 from cveneziani/refactoring
Refactoring
2014-01-18 05:15:23 -08:00
Cecile Veneziani 11860dd930 Refactoring
- Create a class per method
- Create a class per git strategy
- Extract USAGE into a file
- Refactor git and ftp/sftp methods
2014-01-16 16:52:52 +01:00
Tom Vaughan 064b17add2 Merge pull request #49 from cveneziani/git_submodule_strategy
Add strategy option to git method
2013-12-23 10:55:11 -08:00
Cecile Veneziani 23c6b8c1f6 Add strategy option to git method
- Set force push as default strategy (avoid breaking change)
- Add submodule strategy
2013-11-30 21:28:35 +01:00
Tom Vaughan b0f7cde56a bump 2013-11-23 17:17:25 -03:00
Tom Vaughan 26f2e43a52 Add new rsync flags option to error message. 2013-11-19 20:36:02 -03:00
Tom Vaughan 64ffb98d14 Merge pull request #48 from jasonsemko/jason
Adding "flags" option for rsync
2013-11-19 15:26:03 -08:00
Jason Semko eaedc962b8 updating readme 2013-11-18 17:59:58 -08:00
Jason Semko 5b1723ab34 adding a flags option to override default rsync flags 2013-11-18 17:42:55 -08:00
Tom Vaughan 63a9e82bd2 Add a prominent link to the wiki. 2013-11-18 10:37:42 -03:00
Tom Vaughan 23cace3319 Merge pull request #41 from sDaniel/master
Quotes-Fix - deploying/comitting to github on a windows machine is not woking
2013-10-03 06:20:14 -07:00
Sebastian Daniel 36785eb98f fix for quotes not woking when comitting on a windows machine. + comment since change didn't show up on github 2013-10-01 20:14:23 +02:00
Sebastian Daniel 273174f427 fix for quotes not woking when comitting on a windows machine. 2013-10-01 19:43:02 +02:00
Tom Vaughan 0b0f447117 This is misleading. There are no tests. 2013-09-21 13:37:36 -03:00
Tom Vaughan 4f03a0eaa1 Prefer README.md over the GitHub pages site. 2013-09-21 13:21:15 -03:00
Tom Vaughan 0f1a55a82b Because why not. 2013-09-21 12:13:07 -04:00
Tom Vaughan d845e9f42d Bump. 2013-09-21 12:33:45 -03:00
Tom Vaughan c981ca3aa0 Pull-in new middleman extension defaults. 2013-09-21 12:32:19 -03:00
Tom Vaughan fd5fa8c04d Oddly this is no longer required. 2013-09-21 12:29:10 -03:00
Tom Vaughan 268ddb1a14 Add username and password are optional to sftp docs. 2013-09-21 12:06:25 -03:00
Tom Vaughan 2f8d236ee4 Make username optional for sftp deployment. Like rsync. 2013-09-21 12:05:56 -03:00
Tom Vaughan cbead1ee4b Merge pull request #39 from MSch/patch-1
Make password optional for sftp deployment
2013-09-12 12:18:59 -07:00
Martin Schürrer 6eed387731 Make password optional for sftp deployment
Some people use public key authentication
2013-09-12 20:33:06 +02:00
Tom Vaughan 336fcd3c0e Catch specific exception. Fixes #38 (I think). 2013-08-24 11:16:22 -04:00
Tom Vaughan a738143f3e bump 2013-08-08 19:46:10 -04:00
Tom Vaughan c9d44ba5e7 Comment and separate default options. 2013-08-08 19:44:03 -04:00
Tom Vaughan 6cb77153d4 Add port to list of possible options. 2013-08-08 19:41:46 -04:00
Tom Vaughan d749a99fbe Let user be optional in the rsync method. 2013-08-08 19:39:10 -04:00
Tom Vaughan 87b71cc7c9 Merge pull request #35 from rmm5t/kill-global-constants
Removed use of global constants (VERSION and PACKAGE)
2013-08-04 06:58:57 -07:00
Ryan McGeary 81fd3ad4c5 Removed use of global constants (VERSION and PACKAGE)
Fixes #33
2013-08-03 18:06:38 -04:00
Tom Vaughan a5d8d9c4f3 bump 2013-07-29 19:58:39 -04:00
Tom Vaughan 02eb3a9095 Switch to github's .io domain for static sites.
Because of this:
https://github.com/blog/1452-new-github-pages-domain-github-io
2013-07-29 19:48:13 -04:00
Tom Vaughan 966d90f7ba Merge branch 'master' of github.com:tvaughan/middleman-deploy
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2013-07-24 00:03:00 -04:00
Tom Vaughan e1c44aa9d3 Call middleman build to work-around a problem in middleman. 2013-07-23 21:43:15 -04:00
Tom Vaughan 4c64a8a046 Merge pull request #30 from rmm5t/require-compass
Compass warning during test suite
2013-07-21 19:05:26 -07:00
Tom Vaughan 0ac2b4ad82 Merge pull request #32 from rmm5t/readme-improvements
Reorganized the readme for better readability
2013-07-21 19:05:11 -07:00
Ryan McGeary 0ea49a47ce Reorganized the readme for better readability
This should make it easier for people to quickly grok the possible
extension behaviors and get started.
2013-07-21 13:23:06 -04:00
Ryan McGeary caced07f0f Added compass to avoid warning during test suite 2013-07-21 12:54:04 -04:00
Tom Vaughan 60dc1fee0e sorry but i can't keep up with the number of contributors 2013-07-16 22:54:58 -04:00
Tom Vaughan 9c925ff0e5 some ftp/sftp related clean-ups 2013-07-16 22:25:06 -04:00
Tom Vaughan c0a974d6a0 bump 2013-07-16 22:08:33 -04:00
Tom Vaughan 4aa98a0035 add that we removed deploy from the after_build hook 2013-07-16 22:02:26 -04:00
Tom Vaughan 8cb0500c0d remove the --clean command-line option 2013-07-16 21:53:11 -04:00
Tom Vaughan 62248cb099 update tagline and ensure required settings are provided for sftp 2013-07-16 21:43:00 -04:00
Tom Vaughan 757272d6af whitespace clean-up 2013-07-16 21:40:33 -04:00
Tom Vaughan f0a60edf29 work-around a problem with running build in an extension 2013-07-16 21:24:45 -04:00
Tom Vaughan 3b9b8093d3 Rename to build_before and add corresponding command-line option. 2013-06-11 00:42:12 -04:00
Tom Vaughan 8c9b79688a Remove the after_build option. This never made much sense. 2013-06-11 00:14:34 -04:00
Tom Vaughan ef47e6321a Merge branch 'master' of github.com:tvaughan/middleman-deploy
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2013-06-11 00:07:36 -04:00
Tom Vaughan f175024f5f The default skeleton provided by middleman now omits versions. 2013-06-11 00:06:36 -04:00
Tom Vaughan 264f1082b2 Merge pull request #24 from jm3/force-build
(optionally) force a build before any deploy
2013-06-10 21:03:06 -07:00
Tom Vaughan 04fccda46b Merge pull request #28 from tobiaswerner/master
Add SFTP deployment
2013-06-08 16:15:31 -07:00
tobiaswerner a1ae241553 Added SFTP deployment 2013-06-08 22:46:43 +02:00
Tom Vaughan e393283264 Merge pull request #27 from rmm5t/gemspec-license
Add license declaration to gemspec
2013-05-30 16:31:28 -07:00
Ryan McGeary f474cbd298 Added license declaration to gemspec 2013-05-30 19:19:42 -04:00
Tom Vaughan 36ba3b9086 Merge pull request #26 from rmm5t/fix-branch-check
Fix branch selection logic for git deploys
2013-05-30 08:10:00 -07:00
Ryan McGeary e854adb5a6 Fixed branch selection logic for git deploys
* Before, because the logic was revered (see
  c0e46393c6), a brand new deploy would
  result in assuming that the deploy branch existed when it actually
  did not. This would cause initial deploys to fail.
* This new logic is more concise, more readable, and still backwards
  compatible with ruby 1.8.
2013-05-30 10:25:03 -04:00
John Manoogian III 92e7724a1a (optionally) force a build before any deploy 2013-05-06 16:39:19 -07:00
Tom Vaughan 00e00ee96d Clean-up README.md (remove step 1 as it is redundant). 2013-05-05 20:51:13 -04:00
Tom Vaughan 5931dfc748 bump 2013-05-05 20:14:12 -04:00
Tom Vaughan 41f33b69d2 Fix #23. use build_dir as specified in config.rb 2013-05-05 20:13:14 -04:00
Tom Vaughan 73fad02a78 give ftp some props 2013-05-05 20:04:55 -04:00
Tom Vaughan 50283f2d0a use a secure transport to fetch gems (or else they can be compromised?) 2013-05-05 20:04:43 -04:00
Tom Vaughan 46286a2729 bump 2013-03-15 22:57:41 -03:00
Tom Vaughan bc38de72dd Merge pull request #16 from bzalasky/master
Nothing major, just a typo in the readme
2013-03-14 05:51:24 -07:00
Benjamin Zalasky 6ff92c0607 Update README.md
Fixed a typo on the first line, delpoy to deploy.
2013-03-13 21:58:33 -07:00
Tom Vaughan 2ba1b86d06 Merge pull request #15 from reefab/master
Very small bugfix to make middleman deploy work on ruby 1.8
2013-03-01 10:05:30 -08:00
Fabien Piuzzi c0e46393c6 Fixing deploy for ruby 1.8
.keep_if is not present in Ruby 1.8, using delete_if and reversing the test should be equivalent and more universal.
2013-03-01 18:07:33 +01:00
Tom Vaughan 0c84e7ec6e also bump 2013-01-20 10:58:43 -03:00
Tom Vaughan 7f2b18b2de bump 2013-01-20 10:56:03 -03:00
Tom Vaughan 8c6bbae53a Display help on config.rb when ftp method is not setup correctly. Update printf's. 2013-01-20 10:51:22 -03:00
Tom Vaughan 4f41240306 Merge pull request #11 from danielbayerlein/ftp-hidden-files
[deploy_ftp] Add support for hidden files.
2013-01-13 18:35:50 -08:00
Tom Vaughan 32a3dfbac2 Merge pull request #12 from danielbayerlein/readme-improvements
Some README improvements.
2013-01-13 18:34:33 -08:00
Daniel Bayerlein 586f70c571 Some README improvements. 2013-01-13 20:04:21 +01:00
Daniel Bayerlein fd926b183d [deploy_ftp] Add support for hidden files. 2013-01-13 19:41:58 +01:00
Tom Vaughan 73258f3c5c bump 2013-01-05 13:43:18 -03:00
Tom Vaughan dbc310ec11 Merge pull request #10 from benben/9_git_deploy_fix
git: remove origin fetching, fixes #9
2013-01-03 04:31:16 -08:00
Benjamin Knofe 6b6f928e75 git: remove origin fetching, fixes #9 2013-01-02 22:38:24 +01:00
Tom Vaughan 1877938c8a bump 2012-12-01 20:52:53 -03:00
Tom Vaughan 3876a2f986 Clean-up documentation. 2012-12-01 20:52:26 -03:00
Tom Vaughan 95a796ab41 Merge pull request #8 from benben/git-deploy
Better git deployment.

 * Remove outdated git gem.
 * Support git remotes other than "origin".
 * Use "build" directory as tmp git repo.
2012-11-28 04:27:32 -08:00
Benjamin Knofe 95f3a8429f updated README.md 2012-11-28 11:31:04 +01:00
Benjamin Knofe 327a41fd05 refactored the whole git deploy process, fixes #7 2012-11-28 11:17:24 +01:00
Tom Vaughan d4ae8de561 bump 2012-11-13 20:33:45 -03:00
Tom Vaughan 2137e353f3 whoa! three deploy methods! sweet! exclamation points!!! 2012-11-13 20:33:13 -03:00
Tom Vaughan 358ed821f3 thanks everybody! for reals! 2012-11-13 20:29:47 -03:00
Tom Vaughan ca049388fc document that we support the after_build hook 2012-11-13 20:29:20 -03:00
Tom Vaughan b71dc4d8df Merge pull request #6 from benben/master
FTP deployment
2012-11-08 08:18:36 -08:00
Benjamin Knofe 963971bb15 added ftp to error message 2012-11-08 16:53:45 +01:00
Benjamin Knofe 817ac132c0 added FTP deployment 2012-11-08 16:45:57 +01:00
Tom Vaughan 2b33d3d409 call deploy via middleman's built-in after_build hook
TODO: pass "--clean" or "--no-clean" to deploy as passed to build
2012-10-31 17:49:30 -03:00
Tom Vaughan aa59736914 bump 2012-10-05 00:44:18 -03:00
Tom Vaughan 2f0914595b per recent updates 2012-10-05 00:44:12 -03:00
Tom Vaughan 01eb463045 allow remotes other than "origin" in the git deploy method 2012-10-05 00:44:02 -03:00
Tom Vaughan 54ebdd153e per recent updates 2012-10-04 15:22:16 -03:00
Tom Vaughan 82a4915250 Update lib/middleman-deploy/extension.rb
clean-up whitespace
2012-09-26 15:46:21 -07:00
Tom Vaughan 96725beb12 Merge pull request #4 from grossws/master
Option to push branch other than gh-pages when deploying to git
2012-09-26 15:45:11 -07:00
Konstantin Gribov 62e6d4429f Added support for non-default (gh-pages) branch on github 2012-09-27 02:27:15 +04:00
Tom Vaughan 72fcf8c717 periods, periods, periods 2012-09-04 11:04:09 -07:00
Tom Vaughan 749ea963d4 add a simple coverage report 2012-09-04 10:47:53 -07:00
Tom Vaughan be45c22d0d bump 2012-09-04 10:31:25 -07:00
Tom Vaughan a832143c87 misc clean-ups 2012-09-04 10:30:52 -07:00
Tom Vaughan 8694bb8fb2 rework how we get our extension options 2012-09-04 10:25:21 -07:00
Tom Vaughan fa123c1c70 as reported at: http://forum.middlemanapp.com/discussion/comment/177 2012-09-03 11:31:15 -07:00
Tom Vaughan 0f7f2b8b0c per recent pull request 2012-08-30 09:43:12 -07:00
Tom Vaughan f5dccd5c7d Merge pull request #1 from bencates/master
Added github pages support
2012-08-30 09:23:12 -07:00
Ben Cates 134420026b Updated documentation 2012-08-30 09:34:16 -04:00
Ben Cates bf8ce71a49 Update lib/middleman-deploy/commands.rb
Dumb fix
2012-08-30 00:58:44 -03:00
Ben Cates ca961309bc Update lib/middleman-deploy/pkg-info.rb
Bumped the version number
2012-08-30 00:56:26 -03:00
Ben Cates 4de34e8948 Added github pages support 2012-08-29 23:50:23 -04:00
Tom Vaughan c074f8d907 bump 2012-08-22 17:06:28 -07:00
Tom Vaughan dc628d3fb3 oops 2012-08-22 17:06:14 -07:00
Tom Vaughan bf914bb27a be explicit about what deploy means 2012-08-22 16:56:07 -07:00
Tom Vaughan 3463d54589 oh, use middleman-deploy's homepage... red face 2012-08-22 16:46:07 -07:00
Tom Vaughan 157675c381 oops 2012-08-22 16:30:54 -07:00
31 changed files with 922 additions and 186 deletions

3
.document Normal file
View file

@ -0,0 +1,3 @@
LICENSE.md
README.md
lib/**/*.rb

17
.gitignore vendored
View file

@ -1 +1,18 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
bin

11
.rubocop.yml Normal file
View file

@ -0,0 +1,11 @@
AllCops:
Include:
- 'Gemfile'
Exclude:
- 'script/**/*'
- 'vendor/**/*'
- 'bin/**/*'
Documentation:
Enabled: false
ClassAndModuleChildren:
Enabled: false

26
.travis.yml Normal file
View file

@ -0,0 +1,26 @@
language: ruby
sudo: false
cache: bundler
bundler_args: --without development
rvm:
- ruby-head
- ruby
- jruby-head
- jruby
- 2.1.0
- 2.0.0
- 1.9.3
- rbx-2
before_script: bundle update
matrix:
fast_finish: true
allow_failures:
- rvm: ruby-head
- rvm: ruby
- rvm: jruby-head
- rvm: jruby
- rvm: rbx-2
notifications:
email: false
env:
- CODECLIMATE_REPO_TOKEN=5eee8e8624962f963a52a1d2313dc7407e3b8006291e3704346c786642cc073b

6
.yardopts Normal file
View file

@ -0,0 +1,6 @@
--markup markdown
-
CHANGELOG.md
CONTRIBUTING.md
LICENSE.md
README.md

12
CHANGELOG.md Normal file
View file

@ -0,0 +1,12 @@
Next Release
============
* Your contribution here.
2.0.0-alpha (02/08/2015)
==================
* [Fixing compatibility issues with middleman v4.0.0.beta.1](https://github.com/middleman-contrib/middleman-deploy/pull/87) - [@emilioforrer](https://github.com/emilioforrer).
1.0.0 (16/07/2014)
==================
* [Respect user details of git repo](https://github.com/middleman-contrib/middleman-deploy/pull/70) - [@Gee-Bee](https://github.com/gee-bee).
* [Prevent bad commits deploying](https://github.com/middleman-contrib/middleman-deploy/pull/77) - [@karlfreeman](https://github.com/mconnell).

44
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,44 @@
## Contributing
In the spirit of [free software][free-sw], **everyone** is encouraged to help
improve this project.
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
Here are some ways *you* can contribute:
* by using alpha, beta, and prerelease versions
* by reporting bugs
* by suggesting new features
* by writing or editing documentation
* by writing specifications
* by writing code (**no patch is too small**: fix typos, add comments, clean up
inconsistent whitespace)
* by refactoring code
* by closing [issues][]
* by reviewing patches
[issues]: https://github.com/karlfreeman/middleman-deploy/issues
## Submitting an Issue
We use the [GitHub issue tracker][issues] to track bugs and features. Before
submitting a bug report or feature request, check to make sure it hasn't
already been submitted. When submitting a bug report, please include a [Gist][]
that includes a stack trace and any details that may be necessary to reproduce
the bug, including your gem version, Ruby version, and operating system.
Ideally, a bug report should include a pull request with failing specs.
[gist]: https://gist.github.com/
## Submitting a Pull Request
1. [Fork the repository.][fork]
2. [Create a topic branch.][branch]
3. Add specs for your unimplemented feature or bug fix.
4. Run `bundle exec rake cucumber`. If your specs pass, return to step 3.
5. Implement your feature or bug fix.
6. Run `bundle exec rake cucumber`. If your specs fail, return to step 5.
7. Add, commit, and push your changes.
9. [Submit a pull request.][pr]
[fork]: http://help.github.com/fork-a-repo/
[branch]: http://learn.github.com/p/branching.html
[pr]: http://help.github.com/send-pull-requests/

20
Gemfile
View file

@ -1,19 +1,11 @@
source :rubygems
# Specify your gem's dependencies in middleman-deploy.gemspec
gemspec
source 'https://rubygems.org'
gemspec
group :development do
gem "rake", "~> 0.9.2"
gem "rdoc", "~> 3.9"
gem "yard", "~> 0.8.0"
end
group :test do
gem "cucumber", "~> 1.2.0"
gem "fivemat"
gem "aruba", "~> 0.4.11"
gem "rspec", "~> 2.7"
gem 'rake', '~> 10.0'
gem 'cucumber', '~> 1.3'
gem 'aruba', '~> 0.5'
gem 'fivemat'
gem 'codeclimate-test-reporter'
end

View file

@ -1,4 +1,6 @@
Copyright (c) 2012 Tom Vaughan <thomas.david.vaughan@gmail.com>
Copyright (c) 2012-2014 Tom Vaughan, Karl Freeman
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@ -8,13 +10,13 @@ distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

193
README.md
View file

@ -1,67 +1,186 @@
Middleman Delpoy -- Deploy a [middleman](http://middlemanapp.com/) built site over rsync.
# Middleman Deploy
[![Build Status](https://secure.travis-ci.org/tvaughan/middleman-deploy.png)](http://travis-ci.org/tvaughan/middleman-deploy)
Deploy your [Middleman](http://middlemanapp.com/) build via **rsync**, **ftp**, **sftp**, or **git** (e.g. [gh-pages on github](https://help.github.com/articles/creating-project-pages-manually)).
===
## Installation
## QUICK START
```ruby
gem 'middleman-deploy', '~> 1.0'
```
Be sure that `rsync` is installed.
## Usage
### Step 1
```
$ middleman build [--clean]
$ middleman deploy [--build-before]
```
gem install middleman-deploy
## Possible Configurations
### Step 2
Middleman-deploy can deploy a site via rsync, ftp, sftp, or git. Checkout [the wiki](https://github.com/tvaughan/middleman-deploy/wiki/_pages) for advanced set-up options.
middleman init example-site
cd example-site
### Rsync
### Step 3
Make sure that `rsync` is installed, and activate the extension by adding the
following to `config.rb`:
Edit `Gemfile`, and add:
```ruby
activate :deploy do |deploy|
deploy.deploy_method = :rsync
deploy.host = 'www.example.com'
deploy.path = '/srv/www/site'
# Optional Settings
# deploy.user = 'tvaughan' # no default
# deploy.port = 5309 # ssh port, default: 22
# deploy.clean = true # remove orphaned files on remote host, default: false
# deploy.flags = '-rltgoDvzO --no-p --del' # add custom flags, default: -avz
end
```
gem "middleman-deploy"
### Git (e.g. GitHub Pages)
Then run:
Make sure that `git` is installed, and activate the extension by adding the
following to `config.rb`:
bundle install
```ruby
activate :deploy do |deploy|
deploy.deploy_method = :git
# Optional Settings
# deploy.remote = 'custom-remote' # remote name or git url, default: origin
# deploy.branch = 'custom-branch' # default: gh-pages
# deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push
# deploy.commit_message = 'custom-message' # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version`
end
```
### Step 4
If you use a remote name, you must first add it using `git remote add`. Run
`git remote -v` to see a list of possible remote names. If you use a git url,
it must end with '.git'.
#### These settings are required.
Afterwards, the `build` directory will become a git repo.
Edit `config.ru`, and add:
If you use the force push strategy, this branch will be created on the remote if
it doesn't already exist.
But if you use the submodule strategy, you must first initialize build folder as
a submodule. See `git submodule add` documentation.
activate :deploy do |deploy|
deploy.user = "tvaughan"
deploy.host = "www.example.com"
deploy.path = "/srv/www/site"
end
### FTP
Adjust these values accordingly.
Activate the extension by adding the following to `config.rb`:
### Step 4.1
```ruby
activate :deploy do |deploy|
deploy.deploy_method = :ftp
deploy.host = 'ftp.example.com'
deploy.path = '/srv/www/site'
deploy.user = 'tvaughan'
deploy.password = 'secret'
end
```
#### These settings are optional.
### SFTP
To use a particular SSH port, add:
Activate the extension by adding the following to `config.rb`:
deploy.port = 5309
```ruby
activate :deploy do |deploy|
deploy.deploy_method = :sftp
deploy.host = 'sftp.example.com'
deploy.port = 22
deploy.path = '/srv/www/site'
# Optional Settings
# deploy.user = 'tvaughan' # no default
# deploy.password = 'secret' # no default
end
```
Default is `22`.
### Run Automatically
To remove orphaned files or directories on the remote host, add:
To automatically run `middleman build` during `middleman deploy`, turn on the
`build_before` option while activating the deploy extension:
deploy.clean = true
```ruby
activate :deploy do |deploy|
# ...
deploy.build_before = true # default: false
end
```
Default is `false`.
### Multiple Environments
### Step 5
Deploy your site to more than one configuration using environment variables.
middleman build
middleman deploy
```ruby
# config.rb
case ENV['TARGET'].to_s.downcase
when 'production'
activate :deploy do |deploy|
deploy.deploy_method = :rsync
deploy.host = 'www.example.com'
deploy.path = '/srv/www/production-site'
end
else
activate :deploy do |deploy|
deploy.deploy_method = :rsync
deploy.host = 'staging.example.com'
deploy.path = '/srv/www/staging-site'
end
end
```
### NOTES
```ruby
# Rakefile
namespace :deploy do
def deploy(env)
puts "Deploying to #{env}"
system "TARGET=#{env} bundle exec middleman deploy"
end
Inspired by the rsync task in [Octopress](https://github.com/imathis/octopress).
task :staging do
deploy :staging
end
task :production do
deploy :production
end
end
```
```
$ rake deploy:staging
$ rake deploy:production
```
## Badges
[![Gem Version](http://img.shields.io/gem/v/middleman-deploy.svg)][gem]
[![Build Status](http://img.shields.io/travis/karlfreeman/middleman-deploy.svg)][travis]
[![Code Quality](http://img.shields.io/codeclimate/github/karlfreeman/middleman-deploy.svg)][codeclimate]
[![Code Coverage](http://img.shields.io/codeclimate/coverage/github/karlfreeman/middleman-deploy.svg)][codeclimate]
[![Gittip](http://img.shields.io/gittip/karlfreeman.svg)][gittip]
## Supported Ruby Versions
This library aims to support and is [tested against][travis] the following Ruby
implementations:
- Ruby 2.1.0
- Ruby 2.0.0
- Ruby 1.9.3
- [JRuby][jruby]
- [Rubinius][rubinius]
# Credits
A **BIG** thanks to [everyone who has contributed](https://github.com/karlfreeman/middleman-deploy/graphs/contributors)! Almost all pull requests are accepted.
Inspiration:
- The rsync task in [Octopress](https://github.com/imathis/octopress)
[gem]: https://rubygems.org/gems/middleman-deploy
[travis]: http://travis-ci.org/karlfreeman/middleman-deploy
[codeclimate]: https://codeclimate.com/github/karlfreeman/middleman-deploy
[gittip]: https://www.gittip.com/karlfreeman
[jruby]: http://www.jruby.org
[rubinius]: http://rubini.us

View file

@ -1,35 +1,25 @@
require 'bundler'
Bundler.setup
Bundler::GemHelper.install_tasks
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
exempt_tags = ['--tags ~@wip']
t.cucumber_opts = "--color #{exempt_tags.join(' ')} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
end
require 'rake/clean'
task :test => ["cucumber"]
require "middleman-deploy/pkg-info"
PACKAGE = "#{Middleman::Deploy::PACKAGE}"
VERSION = "#{Middleman::Deploy::VERSION}"
task :package do
system "gem build #{PACKAGE}.gemspec"
begin
require 'yard'
YARD::Rake::YardocTask.new
rescue LoadError
end
task :install => :package do
Dir.chdir("pkg") do
system "gem install #{PACKAGE}-#{VERSION}"
end
begin
require 'rubocop/rake_task'
desc 'Run rubocop'
RuboCop::RakeTask.new(:rubocop)
rescue LoadError
end
task :release => :package do
Dir.chdir("pkg") do
system "gem push #{PACKAGE}-#{VERSION}"
end
end
task :default => :test
task default: :cucumber
task test: :cucumber

View file

@ -1,4 +1,8 @@
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
require "middleman-core"
require "middleman-core/step_definitions"
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-deploy')
require 'middleman-core'
require 'middleman-core/step_definitions'
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-deploy')

6
features/test.feature Normal file
View file

@ -0,0 +1,6 @@
Feature: test
Scenario: whilst testing
Given the Server is running at "test-app"
When I go to "/index.html"
Then I should see "<h1>Test</h1>"

View file

View file

@ -0,0 +1 @@
<h1>Test</h1>

View file

@ -1,8 +1,8 @@
require "middleman-core"
require 'middleman-core'
require "middleman-deploy/commands"
require 'middleman-deploy/commands'
::Middleman::Extensions.register(:deploy) do
require "middleman-deploy/extension"
::Middleman::Deploy
require 'middleman-deploy/extension'
::Middleman::Deploy::Extension
end

View file

@ -1,60 +1,119 @@
require "middleman-core/cli"
require "middleman-deploy/extension"
require 'middleman-core/cli'
require 'middleman-core/rack' if Middleman::VERSION.to_i > 3
require 'middleman-deploy/pkg-info'
require 'middleman-deploy/extension'
require 'middleman-deploy/methods'
require 'middleman-deploy/strategies'
module Middleman
module Cli
# This class provides a "deploy" command for the middleman CLI.
class Deploy < Thor
class Deploy < Thor::Group
include Thor::Actions
check_unknown_options!
namespace :deploy
class_option :environment,
aliases: '-e',
default: ENV['MM_ENV'] || ENV['RACK_ENV'] || 'production',
desc: 'The environment Middleman will run under'
class_option :verbose,
type: :boolean,
default: false,
desc: 'Print debug messages'
class_option :instrument,
type: :string,
default: false,
desc: 'Print instrument messages'
class_option :build_before,
type: :boolean,
aliases: '-b',
desc: 'Run `middleman build` before the deploy step'
def self.subcommand_help(_options)
# TODO
end
# Tell Thor to exit with a nonzero exit code on failure
def self.exit_on_failure?
true
end
desc "deploy", "Deploy to a remote host over rsync"
method_option "clean",
:type => :boolean,
:aliases => "-c",
:desc => "Remove orphaned files or directories on the remote host"
def deploy
shared_inst = ::Middleman::Application.server.inst
env = options['environment'] ? :production : options['environment'].to_s.to_sym
verbose = options['verbose'] ? 0 : 1
instrument = options['instrument']
host = shared_inst.options.host
port = shared_inst.options.port
user = shared_inst.options.user
path = shared_inst.options.path
# These only exists when the config.rb sets them!
if (!host || !user || !path)
raise Thor::Error.new "You need to activate the deploy extension in config.rb"
@app = ::Middleman::Application.new do
config[:mode] = :build
config[:environment] = env
::Middleman::Logger.singleton(verbose, instrument)
end
command = "rsync -avze '" + "ssh -p #{port}" + "' build/ #{user}@#{host}:#{path}"
if options.has_key? "clean"
clean = options.clean
else
clean = shared_inst.options.clean
end
if clean
command += " --delete"
end
run command
build_before(options)
process
end
protected
def build_before(options = {})
build_enabled = options.fetch('build_before', deploy_options.build_before)
if build_enabled
# http://forum.middlemanapp.com/t/problem-with-the-build-task-in-an-extension
run("middleman build -e #{options['environment']}") || exit(1)
end
end
def print_usage_and_die(message)
fail StandardError, "ERROR: #{message}\n#{Middleman::Deploy::README}"
end
def process
server_instance = @app
camelized_method = deploy_options.deploy_method.to_s.split('_').map(&:capitalize).join
method_class_name = "Middleman::Deploy::Methods::#{camelized_method}"
method_instance = method_class_name.constantize.new(server_instance, deploy_options)
method_instance.process
end
def deploy_options
options = nil
begin
options = ::Middleman::Deploy.options
rescue NoMethodError
print_usage_and_die 'You need to activate the deploy extension in config.rb.'
end
unless options.deploy_method
print_usage_and_die 'The deploy extension requires you to set a method.'
end
case options.deploy_method
when :rsync, :sftp
unless options.host && options.path
print_usage_and_die "The #{options.deploy_method} method requires host and path to be set."
end
when :ftp
unless options.host && options.user && options.password && options.path
print_usage_and_die 'The ftp deploy method requires host, path, user, and password to be set.'
end
end
options
end
end
# Alias "d" to "deploy"
Base.map({ "d" => "deploy" })
# Add to CLI
Base.register(Middleman::Cli::Deploy, 'deploy', 'deploy [options]', Middleman::Deploy::TAGLINE)
# Alias "d" to "deploy"
Base.map('d' => 'deploy')
end
end

View file

@ -1,57 +1,53 @@
# Require core library
require "middleman-core"
require 'middleman-core'
# Extension namespace
module Middleman
module Deploy
class Options < Struct.new(:host, :port, :user, :path, :clean); end
@options
class << self
attr_reader :options
def options
@@options
end
attr_writer :options
end
class Extension < Extension
option :deploy_method, nil
option :host, nil
option :port, nil
option :user, nil
option :password, nil
option :path, nil
option :clean, nil
option :remote, nil
option :branch, nil
option :strategy, nil
option :build_before, nil
option :flags, nil
option :commit_message, nil
def initialize(app, options_hash = {}, &block)
super
def registered(app, options_hash={}, &block)
options = Options.new(options_hash)
yield options if block_given?
# Default options for the rsync method.
options.port ||= 22
options.clean ||= false
@@options = options
# Default options for the git method.
options.remote ||= 'origin'
options.branch ||= 'gh-pages'
options.strategy ||= :force_push
options.commit_message ||= nil
app.send :include, Helpers
app.after_configuration do
if (!options.host || !options.user || !options.path)
raise <<EOF
ERROR: middleman-deploy is not setup correctly. host, user, and path
*must* be set in config.rb. For example:
activate :deploy do |deploy|
deploy.user = "tvaughan"
deploy.host = "www.example.com"
deploy.path = "/srv/www/site"
end
EOF
end
end
options.build_before ||= false
end
alias :included :registered
end
module Helpers
def options
::Middleman::Deploy.options
def after_configuration
::Middleman::Deploy.options = options
end
end
end
end

View file

@ -0,0 +1,5 @@
require 'middleman-deploy/methods/base'
require 'middleman-deploy/methods/ftp'
require 'middleman-deploy/methods/git'
require 'middleman-deploy/methods/rsync'
require 'middleman-deploy/methods/sftp'

View file

@ -0,0 +1,22 @@
module Middleman
module Deploy
module Methods
class Base
attr_reader :options, :server_instance
def initialize(server_instance, options = {})
@options = options
@server_instance = server_instance
end
def build_dir
server_instance.config.setting(:build_dir).value
end
def process
fail NotImplementedError
end
end
end
end
end

View file

@ -0,0 +1,86 @@
require 'net/ftp'
require 'ptools'
module Middleman
module Deploy
module Methods
class Ftp < Base
attr_reader :host, :port, :pass, :path, :user
def initialize(server_instance, options = {})
super(server_instance, options)
@host = self.options.host
@user = self.options.user
@pass = self.options.password
@path = self.options.path
@port = self.options.port
end
def process
puts "## Deploying via ftp to #{user}@#{host}:#{path}"
ftp = open_connection
Dir.chdir(build_dir) do
filtered_files.each do |filename|
if File.directory?(filename)
upload_directory(ftp, filename)
else
upload_binary(ftp, filename)
end
end
end
ftp.close
end
protected
def filtered_files
files = Dir.glob('**/*', File::FNM_DOTMATCH)
files.reject { |filename| filename =~ Regexp.new('\.$') }
end
def handle_exception(exception, ftp, filename)
reply = exception.message
err_code = reply[0, 3].to_i
if err_code == 550
if File.binary?(filename)
ftp.putbinaryfile(filename, filename)
else
ftp.puttextfile(filename, filename)
end
end
end
def open_connection
ftp = Net::FTP.new(host)
ftp.login(user, pass)
ftp.chdir(path)
ftp.passive = true
ftp
end
def upload_binary(ftp, filename)
begin
ftp.putbinaryfile(filename, filename)
rescue Exception => exception
handle_exception(exception, ftp, filename)
end
puts "Copied #{filename}"
end
def upload_directory(ftp, filename)
ftp.mkdir(filename)
puts "Created directory #{filename}"
rescue
end
end
end
end
end

View file

@ -0,0 +1,17 @@
module Middleman
module Deploy
module Methods
class Git < Base
def process
puts "## Deploying via git to remote=\"#{options.remote}\" and branch=\"#{options.branch}\""
camelized_strategy = options.strategy.to_s.split('_').map(&:capitalize).join
strategy_class_name = "Middleman::Deploy::Strategies::Git::#{camelized_strategy}"
strategy_instance = strategy_class_name.constantize.new(build_dir, options.remote, options.branch, options.commit_message)
strategy_instance.process
end
end
end
end
end

View file

@ -0,0 +1,34 @@
module Middleman
module Deploy
module Methods
class Rsync < Base
attr_reader :clean, :flags, :host, :path, :port, :user
def initialize(server_instance, options = {})
super(server_instance, options)
@clean = self.options.clean
@flags = self.options.flags
@host = self.options.host
@path = self.options.path
@port = self.options.port
@user = self.options.user
end
def process
# Append "@" to user if provided.
user = "#{self.user}@" if user && !user.empty?
dest_url = "#{user}#{host}:#{path}"
flags = self.flags || '-avz'
command = "rsync #{flags} '-e ssh -p #{port}' #{build_dir}/ #{dest_url}"
command += ' --delete' if clean
puts "## Deploying via rsync to #{dest_url} port=#{port}"
exec command
end
end
end
end
end

View file

@ -0,0 +1,60 @@
require 'net/sftp'
require 'ptools'
module Middleman
module Deploy
module Methods
class Sftp < Ftp
def process
puts "## Deploying via sftp to #{user}@#{host}:#{path}"
# `nil` is a valid value for user and/or pass.
Net::SFTP.start(host, user, password: pass, port: port) do |sftp|
sftp.mkdir(path)
Dir.chdir(build_dir) do
filtered_files.each do |filename|
if File.directory?(filename)
upload_directory(sftp, filename)
else
upload_file(sftp, filename)
end
end
end
end
end
protected
def handle_exception(exception, filename, file_path)
reply = exception.message
err_code = reply[0, 3].to_i
sftp.upload(filename, file_path) if err_code == 550
end
def upload_directory(sftp, filename)
file_path = "#{path}/#{filename}"
begin
sftp.mkdir(file_path)
puts "Created directory #{filename}"
rescue
end
end
def upload_file(sftp, filename)
file_path = "#{path}/#{filename}"
begin
sftp.upload(filename, file_path)
rescue Exception => exception
handle_exception(exception, filename, file_path)
end
puts "Copied #{filename}"
end
end
end
end
end

View file

@ -1,6 +1,64 @@
module Middleman
module Deploy
PACKAGE = "middleman-deploy"
VERSION = "0.0.2"
PACKAGE = 'middleman-deploy'
VERSION = '2.0.0-alpha'
TAGLINE = 'Deploy a middleman built site over rsync, ftp, sftp, or git (e.g. gh-pages on github).'
README = %{
You should follow one of the four examples below to setup the deploy
extension in config.rb.
# To deploy the build directory to a remote host via rsync:
activate :deploy do |deploy|
deploy.method = :rsync
# host and path *must* be set
deploy.host = "www.example.com"
deploy.path = "/srv/www/site"
# user is optional (no default)
deploy.user = "tvaughan"
# port is optional (default is 22)
deploy.port = 5309
# clean is optional (default is false)
deploy.clean = true
# flags is optional (default is -avze)
deploy.flags = "-rltgoDvzO --no-p --del -e"
end
# To deploy to a remote branch via git (e.g. gh-pages on github):
activate :deploy do |deploy|
deploy.method = :git
# remote is optional (default is "origin")
# run `git remote -v` to see a list of possible remotes
deploy.remote = "some-other-remote-name"
# branch is optional (default is "gh-pages")
# run `git branch -a` to see a list of possible branches
deploy.branch = "some-other-branch-name"
# strategy is optional (default is :force_push)
deploy.strategy = :submodule
end
# To deploy the build directory to a remote host via ftp:
activate :deploy do |deploy|
deploy.method = :ftp
# host, user, passwword and path *must* be set
deploy.host = "ftp.example.com"
deploy.path = "/srv/www/site"
deploy.user = "tvaughan"
deploy.password = "secret"
end
# To deploy the build directory to a remote host via sftp:
activate :deploy do |deploy|
deploy.method = :sftp
# host, user, passwword and path *must* be set
deploy.host = "sftp.example.com"
deploy.port = 22
deploy.path = "/srv/www/site"
# user is optional (no default)
deploy.user = "tvaughan"
# password is optional (no default)
deploy.password = "secret"
end}
end
end

View file

@ -0,0 +1,3 @@
require 'middleman-deploy/strategies/git/base'
require 'middleman-deploy/strategies/git/force_push'
require 'middleman-deploy/strategies/git/submodule'

View file

@ -0,0 +1,56 @@
module Middleman
module Deploy
module Strategies
module Git
class Base
attr_accessor :branch, :build_dir, :remote, :commit_message, :user_name, :user_email
def initialize(build_dir, remote, branch, commit_message)
self.branch = branch
self.build_dir = build_dir
self.remote = remote
self.commit_message = commit_message
self.user_name = `git config --get user.name`
self.user_email = `git config --get user.email`
end
def process
fail NotImplementedError
end
protected
def add_signature_to_commit_message(base_message)
signature = "#{Middleman::Deploy::PACKAGE} #{Middleman::Deploy::VERSION}"
time = "#{Time.now.utc}"
"#{base_message} at #{time} by #{signature}"
end
def checkout_branch
# if there is a branch with that name, switch to it, otherwise create a new one and switch to it
if `git branch`.split("\n").any? { |b| b =~ /#{branch}/i }
`git checkout #{branch}`
else
`git checkout -b #{branch}`
end
end
def commit_branch(options = '')
message = commit_message ? commit_message : add_signature_to_commit_message('Automated commit')
run_or_fail('git add -A')
run_or_fail("git commit --allow-empty -am \"#{message}\"")
run_or_fail("git push #{options} origin #{branch}")
end
private
def run_or_fail(command)
system(command) || fail("ERROR running: #{command}")
end
end
end
end
end
end

View file

@ -0,0 +1,58 @@
module Middleman
module Deploy
module Strategies
module Git
class ForcePush < Base
def process
Dir.chdir(build_dir) do
add_remote_url
checkout_branch
commit_branch('-f')
end
end
private
def add_remote_url
url = get_remote_url
unless File.exist?('.git')
`git init`
`git remote add origin #{url}`
`git config user.name "#{user_name}"`
`git config user.email "#{user_email}"`
else
# check if the remote repo has changed
unless url == `git config --get remote.origin.url`.chop
`git remote rm origin`
`git remote add origin #{url}`
end
# check if the user name has changed
`git config user.name "#{user_name}"` unless user_name == `git config --get user.name`
# check if the user email has changed
`git config user.email "#{user_email}"` unless user_email == `git config --get user.email`
end
end
def get_remote_url
remote = self.remote
url = remote
# check if remote is not a git url
unless remote =~ /\.git$/
url = `git config --get remote.#{url}.url`.chop
end
# if the remote name doesn't exist in the main repo
if url == ''
puts "Can't deploy! Please add a remote with the name '#{remote}' to your repo."
exit
end
url
end
end
end
end
end
end

View file

@ -0,0 +1,42 @@
module Middleman
module Deploy
module Strategies
module Git
class Submodule < Base
def process
Dir.chdir(build_dir) do
checkout_branch
pull_submodule
commit_branch
end
commit_submodule
end
private
def commit_submodule
current_branch = `git rev-parse --abbrev-ref HEAD`
message = add_signature_to_commit_message('Deployed')
`git add #{build_dir}`
`git commit --allow-empty -m "#{message}"`
`git push origin #{current_branch}`
end
def pull_submodule
`git fetch`
`git stash`
`git rebase #{remote}/#{branch}`
`git stash pop`
if $CHILD_STATUS.exitstatus == 1
puts "Can't deploy! Please resolve conflicts. Then process to manual commit and push on #{branch} branch."
exit
end
end
end
end
end
end
end

View file

@ -1 +1 @@
require "middleman-deploy"
require 'middleman-deploy'

View file

@ -1,25 +1,32 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "middleman-deploy/pkg-info"
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'middleman-deploy/pkg-info'
Gem::Specification.new do |s|
s.name = Middleman::Deploy::PACKAGE
s.version = Middleman::Deploy::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Tom Vaughan"]
s.email = ["thomas.david.vaughan@gmail.com"]
s.homepage = "http://flavors.me/tvaughan"
s.summary = %q{Deploy a middleman built site over rsync.}
s.description = %q{Deploy a middleman built site over rsync.}
Gem::Specification.new do |spec|
spec.name = Middleman::Deploy::PACKAGE
spec.version = Middleman::Deploy::VERSION
spec.authors = ['Tom Vaughan', 'Karl Freeman']
spec.email = ['thomas.david.vaughan@gmail.com', 'karlfreeman@gmail.com']
spec.summary = Middleman::Deploy::TAGLINE
spec.description = Middleman::Deploy::TAGLINE
spec.homepage = 'https://github.com/karlfreeman/middleman-deploy'
spec.license = 'MIT'
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
# The version of middleman-core your extension depends on
s.add_runtime_dependency("middleman-core", [">= 3.0.0"])
# Additional dependencies
# s.add_runtime_dependency("gem-name", "gem-version")
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 1.9.3'
spec.add_dependency 'middleman-core', '>= 3.2'
spec.add_dependency 'ptools'
spec.add_dependency 'net-sftp'
spec.add_development_dependency 'bundler', '~> 1.5'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'kramdown', '>= 0.14'
spec.add_development_dependency 'rubocop', '~> 0.19'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'yard'
end