Skip to content

Commit

Permalink
Add the github:upload_assets task to attach files to realeses
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Oct 21, 2013
1 parent 53064ef commit 1f504b8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@
Gemfile.lock
/mspec
/build
/.github_access_token
19 changes: 19 additions & 0 deletions Rakefile
Expand Up @@ -2,6 +2,25 @@ require 'bundler'
Bundler.require
Bundler::GemHelper.install_tasks

namespace :github do
task :upload_assets do
require 'octokit'
# https://github.com/octokit/octokit.rb#oauth-access-tokens
token_path = '.github_access_token'
File.exist?(token_path) or raise ArgumentError, "Please create a personal access token (https://github.com/settings/tokens/new) and paste it inside #{token_path.inspect}"
token = File.read(token_path).strip
client = Octokit::Client.new access_token: token
tag_name = ENV['TAG'] || raise(ArgumentError, 'missing the TAG env variable (e.g. TAG=v0.4.4)')
release = client.releases('opal/opal').find{|r| p(r.id); p(r).tag_name == tag_name}
release_url = "https://api.github.com/repos/opal/opal/releases/#{release.id}"
%w[opal opal-parser].each do |name|
client.upload_asset release_url, "build/#{name}.js", content_type: 'application/x-javascript'
client.upload_asset release_url, "build/#{name}.min.js", content_type: 'application/x-javascript'
client.upload_asset release_url, "build/#{name}.min.js.gz", content_type: 'application/octet-stream'
end
end
end

require 'rack'
require 'webrick'
require 'opal-sprockets'
Expand Down
1 change: 1 addition & 0 deletions opal.gemspec
Expand Up @@ -25,4 +25,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'racc'
s.add_development_dependency 'opal-sprockets', '~> 0.1.1'
s.add_development_dependency 'rspec', '~> 2.14'
s.add_development_dependency 'octokit', '~> 2.4.0'
end

0 comments on commit 1f504b8

Please sign in to comment.