Skip to content

Commit

Permalink
First working version of the release flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
vktr committed Mar 14, 2013
1 parent c0cbf42 commit 2809cee
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -20,4 +20,7 @@ src/Shared/CommonAssemblyInfo.cs
#Wix
*.wxobj
*.wixobj
*.wixpdb
*.wixpdb

#Config
config/config.yml
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -2,4 +2,5 @@ source "http://rubygems.org"
gem "rake"
gem "albacore"
gem "semver2"
gem "httparty"
gem "httparty"
gem "net-sftp"
4 changes: 4 additions & 0 deletions Gemfile.lock
Expand Up @@ -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)
Expand All @@ -18,5 +21,6 @@ PLATFORMS
DEPENDENCIES
albacore
httparty
net-sftp
rake
semver2
7 changes: 7 additions & 0 deletions config/config-sample.yml
@@ -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>

47 changes: 41 additions & 6 deletions tools/buildscripts/release.rb
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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"])
Expand All @@ -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.