Permalink
Browse files

First working version of the release flow.

  • Loading branch information...
1 parent c0cbf42 commit 2809ceee9c9b5acedad4d4b340990365c59d0339 @vktr vktr committed Mar 14, 2013
Showing with 58 additions and 8 deletions.
  1. +4 −1 .gitignore
  2. +2 −1 Gemfile
  3. +4 −0 Gemfile.lock
  4. +7 −0 config/config-sample.yml
  5. +41 −6 tools/buildscripts/release.rb
View
@@ -20,4 +20,7 @@ src/Shared/CommonAssemblyInfo.cs
#Wix
*.wxobj
*.wixobj
-*.wixpdb
+*.wixpdb
+
+#Config
+config/config.yml
View
@@ -2,4 +2,5 @@ source "http://rubygems.org"
gem "rake"
gem "albacore"
gem "semver2"
-gem "httparty"
+gem "httparty"
+gem "net-sftp"
View
@@ -8,6 +8,9 @@ GEM
multi_xml (>= 0.5.2)
multi_json (1.6.1)
multi_xml (0.5.3)
+ net-sftp (2.1.1)
+ net-ssh (>= 2.6.5)
+ net-ssh (2.6.6)
rake (0.9.2.2)
rubyzip (0.9.8)
semver2 (3.0.1)
@@ -18,5 +21,6 @@ PLATFORMS
DEPENDENCIES
albacore
httparty
+ net-sftp
rake
semver2
@@ -0,0 +1,7 @@
+---
+sftp:
+ host: <server where files are hosted>
+ user: <user to access host>
+ keys: <array of paths to private keys>
+ path: <path on server where to base file uploads>
+
@@ -1,5 +1,9 @@
require 'semver'
+require 'psych'
require 'httparty'
+require 'net/sftp'
+
+CFG = YAML.load_file("config/config.yml") unless defined? CFG
namespace :release do
task :common do
@@ -45,8 +49,11 @@
ensure_msi_packages(version.format("%M.%m.%p"))
ensure_version_available(version.to_s)
+ copy_to_server("build/msi/hdkn-#{version.format("%M.%m.%p")}.4000-x86.msi", version.format("%M.%m"))
+ copy_to_server("build/msi/hdkn-#{version.format("%M.%m.%p")}.4000-x64.msi", version.format("%M.%m"))
+
tag_repo(version.to_s)
- push_repo(:origin, version.to_s)
+ push_repo(CFG["git"]["remote"], version.to_s)
end
def ensure_msi_packages(v)
@@ -65,11 +72,13 @@ def ensure_msi_packages(v)
end
def ensure_correct_branch()
- puts "checking current branch (must be master)"
+ release_branch = CFG["git"]["release_branch"]
+
+ puts "checking current branch (must be #{release_branch})"
branch = `git rev-parse --abbrev-ref HEAD`.strip
- if branch != "releaseflow" then
- fail "can only release from master branch (current branch is #{branch})"
+ if branch != release_branch then
+ fail "can only release from branch #{release_branch} (current branch is #{branch})"
end
end
@@ -86,7 +95,7 @@ def ensure_clean_repo()
def ensure_version_available(v)
puts "checking with github if we have released #{v} already"
- response = HTTParty.get("https://api.github.com/repos/hadouken/hdkn/tags")
+ response = HTTParty.get(CFG["github"]["api"]["tags"])
response.each do |tag|
tv = version(tag["name"])
@@ -108,13 +117,39 @@ def ensure_version_available(v)
puts "version OK"
end
+ def copy_to_server(localFile, v)
+ puts "copying file #{localFile} to remote server"
+
+ s = CFG["sftp"]
+
+ Net::SFTP.start(s["host"], s["user"], :keys => s["keys"]) do |sftp|
+ hasDir = false
+
+ sftp.dir.foreach(s["path"]) do |p|
+ if(p.name == v)
+ puts "directory #{File.join(s["path"], v)} already exists"
+ hasDir = true
+ end
+ end
+
+ unless hasDir
+ puts "creating remote directory #{File.join(s["path"], v)}"
+ sftp.mkdir!(File.join(s["path"], v))
+ end
+
+ puts "uploading file"
+ sftp.upload!(localFile, File.join(s["path"], v, File.basename(localFile)))
+ end
+ end
+
def tag_repo(v)
puts "tagging repo with version #{v}"
`git tag #{v}`
end
def push_repo(remote, tag)
puts "pushing tag #{tag} to remote repository #{remote}"
- `git push test #{tag}`
+ `git push #{remote}`
+ `git push #{remote} #{tag}`
end
end

0 comments on commit 2809cee

Please sign in to comment.