diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..d5e2485494 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: ruby +cache: bundler +rvm: + - 2.3.0 +install: + - bundle install --path vendor/bundle + - eval "$(ssh-agent -s)" +script: bundle exec rake travis:deploy +branches: + only: + - master diff --git a/Rakefile b/Rakefile index 4a3d594b4f..0da56f7925 100644 --- a/Rakefile +++ b/Rakefile @@ -1,98 +1,10 @@ -directory "vendor" -directory "vendor/bundler" => ["vendor"] do - system "git clone https://github.com/bundler/bundler.git vendor/bundler" -end - -task :update_vendor => ["vendor/bundler"] do - Dir.chdir("vendor/bundler") { sh "git fetch" } -end - -VERSIONS = Dir.chdir("source") { Dir.glob("v*").sort_by{|x| [x.size, x] } }.freeze -desc "Print the Bundler versions the site documents" -task :versions do - puts VERSIONS.join(' ') -end - -desc "Pull in the man pages for the specified gem versions." -task :man => [:update_vendor] do - VERSIONS.each do |version| - next if version == "v0.9" - branch = (version[1..-1].split('.') + %w(stable)).join('-') - - rm_rf "source/#{version}/man" - mkdir_p "source/#{version}/man" - - Dir.chdir "vendor/bundler" do - sh "git reset --hard HEAD" - sh "git checkout origin/#{branch}" - sh "ronn -5 man/*.ronn" - cp(FileList["man/*.html"], "../../source/#{version}/man") - sh "git clean -fd" - end - end - - # Make man pages for the latest version available at the top level, too. - rm_rf "source/man" - cp_r "source/#{VERSIONS.last}/man", "source" -end - -desc "Pulls in pages maintained in the bundler repo." -task :repo_pages => [:update_vendor] do - Dir.chdir "vendor/bundler" do - sh "git reset --hard HEAD" - sh "git checkout origin/master" - cp "ISSUES.md", "../../source/issues.md" - cp "CODE_OF_CONDUCT.md", "../../source/conduct.md" - end -end - -directory "vendor/bundler.github.io" => ["vendor"] do - system "git clone https://github.com/bundler/bundler.github.io.git vendor/bundler.github.io" -end - -task :update_site => ["vendor/bundler.github.io"] do - Dir.chdir "vendor/bundler.github.io" do - sh "git checkout master" - sh "git reset --hard HEAD" - sh "git pull origin master" - end -end +Dir.glob("lib/tasks/**/*.rake").each { |r| load r } desc "Build the static site" task :build => [:repo_pages, :man] do sh "middleman build --clean" end -desc "Release the current commit to bundler/bundler.github.io" -task :release => [:build, :update_site] do - commit = `git rev-parse HEAD`.chomp - - Dir.chdir "vendor/bundler.github.io" do - rm_rf FileList["*"] - cp_r FileList["../../build/*"], "./" - File.write("CNAME", "bundler.io") - - sh "git add -A ." - sh "git commit -m 'bundler/bundler-site@#{commit}'" - - Bundler.with_clean_env do - puts <<-TWO_FACTOR_WARNING -==================================================================== -Please note that if you have two-factor auth enabled for your Github -account, you will need to use a github access token instead of your -account password. -==================================================================== - TWO_FACTOR_WARNING - sh "git push origin master" - end - end - - Bundler.with_clean_env do - sh "git push origin master" - end -end - -# Heroku deploys need to build the non-Middleman pages namespace :assets do task :precompile => [:repo_pages, :man] end diff --git a/deploy_key.enc b/deploy_key.enc new file mode 100644 index 0000000000..62f6aec5cc Binary files /dev/null and b/deploy_key.enc differ diff --git a/lib/tasks/man.rake b/lib/tasks/man.rake new file mode 100644 index 0000000000..6f6abe7a87 --- /dev/null +++ b/lib/tasks/man.rake @@ -0,0 +1,22 @@ +desc "Pull in the man pages for the specified gem versions." +task :man => [:update_vendor] do + VERSIONS.each do |version| + next if version == "v0.9" + branch = (version[1..-1].split('.') + %w(stable)).join('-') + + rm_rf "source/#{version}/man" + mkdir_p "source/#{version}/man" + + Dir.chdir "vendor/bundler" do + sh "git reset --hard HEAD" + sh "git checkout origin/#{branch}" + sh "ronn -5 man/*.ronn" + cp(FileList["man/*.html"], "../../source/#{version}/man") + sh "git clean -fd" + end + end + + # Make man pages for the latest version available at the top level, too. + rm_rf "source/man" + cp_r "source/#{VERSIONS.last}/man", "source" +end diff --git a/lib/tasks/release.rake b/lib/tasks/release.rake new file mode 100644 index 0000000000..2e7ff2da99 --- /dev/null +++ b/lib/tasks/release.rake @@ -0,0 +1,28 @@ +desc "Release the current commit to bundler/bundler.github.io" +task :release => [:build, :update_site] do + commit = `git rev-parse HEAD`.chomp + + Dir.chdir "vendor/bundler.github.io" do + rm_rf FileList["*"] + cp_r FileList["../../build/*"], "./" + File.write("CNAME", "bundler.io") + + sh "git add -A ." + sh "git commit -m 'bundler/bundler-site@#{commit}'" + + Bundler.with_clean_env do + puts <<-TWO_FACTOR_WARNING +==================================================================== +Please note that if you have two-factor auth enabled for your Github +account, you will need to use a github access token instead of your +account password. +==================================================================== + TWO_FACTOR_WARNING + sh "git push origin master" + end + end + + Bundler.with_clean_env do + sh "git push origin master" + end +end diff --git a/lib/tasks/travis/deploy.rake b/lib/tasks/travis/deploy.rake new file mode 100644 index 0000000000..534379defc --- /dev/null +++ b/lib/tasks/travis/deploy.rake @@ -0,0 +1,42 @@ +namespace :travis do + def encrypted_key + ENV["encrypted_#{ENV["ENCRYPTION_LABEL"]}_key"] + end + + def encrypted_iv + ENV["encrypted_#{ENV["ENCRYPTION_LABEL"]}_iv"] + end + + def commit_author_email + ENV["COMMIT_AUTHOR_EMAIL"] + end + + def configure_ssh_deploy_key + sh "openssl aes-256-cbc -K #{encrypted_key} -iv #{encrypted_iv} -in deploy_key.enc -out deploy_key -d" + sh "chmod 600 deploy_key" + sh "ssh-add deploy_key" + sh "rm deploy_key" + end + + task :deploy => [:build] do + configure_ssh_deploy_key + + Rake::Task["travis:update_ssh_site"].invoke + + commit = `git rev-parse HEAD`.chomp + + Dir.chdir "vendor/ssh_bundler.github.io" do + rm_rf FileList["*"] + cp_r FileList["../../build/*"], "./" + File.write("CNAME", "bundler.io") + + sh "git add -A ." + + sh "git config user.name 'Travis CI'" + sh "git config user.email '#{commit_author_email}'" + + sh "git commit -m 'bundler/bundler-site@#{commit}'" + sh "git push origin master" + end + end +end diff --git a/lib/tasks/travis/ssh_repo.rake b/lib/tasks/travis/ssh_repo.rake new file mode 100644 index 0000000000..c8b4bfd73f --- /dev/null +++ b/lib/tasks/travis/ssh_repo.rake @@ -0,0 +1,13 @@ +directory "vendor/ssh_bundler.github.io" => ["vendor"] do + system "git clone git@github.com:bundler/bundler.github.io vendor/ssh_bundler.github.io" +end + +namespace :travis do + task :update_ssh_site => ["vendor/ssh_bundler.github.io"] do + Dir.chdir "vendor/ssh_bundler.github.io" do + sh "git checkout master" + sh "git reset --hard HEAD" + sh "git pull origin master" + end + end +end diff --git a/lib/tasks/vendor_files.rake b/lib/tasks/vendor_files.rake new file mode 100644 index 0000000000..3b16a56707 --- /dev/null +++ b/lib/tasks/vendor_files.rake @@ -0,0 +1,30 @@ +directory "vendor" +directory "vendor/bundler" => ["vendor"] do + system "git clone https://github.com/bundler/bundler.git vendor/bundler" +end + +task :update_vendor => ["vendor/bundler"] do + Dir.chdir("vendor/bundler") { sh "git fetch" } +end + +desc "Pulls in pages maintained in the bundler repo." +task :repo_pages => [:update_vendor] do + Dir.chdir "vendor/bundler" do + sh "git reset --hard HEAD" + sh "git checkout origin/master" + cp "ISSUES.md", "../../source/issues.md" + cp "CODE_OF_CONDUCT.md", "../../source/conduct.md" + end +end + +directory "vendor/bundler.github.io" => ["vendor"] do + system "git clone https://github.com/bundler/bundler.github.io vendor/bundler.github.io" +end + +task :update_site => ["vendor/bundler.github.io"] do + Dir.chdir "vendor/bundler.github.io" do + sh "git checkout master" + sh "git reset --hard HEAD" + sh "git pull origin master" + end +end diff --git a/lib/tasks/versions.rake b/lib/tasks/versions.rake new file mode 100644 index 0000000000..a41d28d2c6 --- /dev/null +++ b/lib/tasks/versions.rake @@ -0,0 +1,6 @@ +VERSIONS = Dir.chdir("source") { Dir.glob("v*").sort_by{|x| [x.size, x] } }.freeze + +desc "Print the Bundler versions the site documents" +task :versions do + puts VERSIONS.join(' ') +end