def version
  git_describe_tags = `git describe --tags`
  tag = git_describe_tags.split('-').first || git_describe_tags
  tag.strip!
  commit = `git rev-list --full-history #{tag}.. -- src/ | wc -l`.strip
  tag.slice! 0
  "#{tag}.#{commit}"
end

task :upload do
  require 'net/github-upload'
  gh = Net::GitHub::Upload.new(
    :login => `git config github.user`.chomp,
    :token => `git config github.token`.chomp
  )
  puts gh.upload(
    :repos => 'CSSOM',
    :file  => 'build/CSSOM.js',
    :name => "CSSOM.v#{version}.js",
    :content_type => 'text/javascript',
    :description => "CSS Object Model implemented in pure JavaScript"
  )
end
