-
Notifications
You must be signed in to change notification settings - Fork 4
/
github.rake
44 lines (39 loc) · 1.32 KB
/
github.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true
require_relative 'release_utils'
namespace :github do
desc 'Check for a Github aaccess token'
task :require_access_token do
puts 'TASK START: github:require_access_token'
unless ENV['AWS_SDK_FOR_RUBY_GH_TOKEN']
warn('Github credentials for the automation account are required.: ' \
"export ENV['AWS_SDK_FOR_RUBY_GH_TOKEN']")
exit(1)
end
puts 'TASK END: github:require_access_token'
end
desc 'Push a new github release'
idempotent_task :release do
puts 'TASK START: github:release'
require 'octokit'
gh = Octokit::Client.new(access_token: ENV['AWS_SDK_FOR_RUBY_GH_TOKEN'])
repo = `git remote get-url origin`
.sub('ssh://', '')
.sub('[email protected]:', '')
.sub(".git\n", '').chomp
tag_ref_sha = `git show-ref v#{ENV['VERSION']}`.split.first
tag = gh.tag(repo, tag_ref_sha)
date = tag.tagger.date.strftime('%Y-%m-%d')
release = gh.create_release(
repo, "v#{ENV['VERSION']}",
name: "Release v#{ENV['VERSION']} - #{date}",
body: tag.message,
prerelease: ENV['VERSION'].match('rc') ? true : false
)
gh.upload_asset(
release.url,
"#{gem_name}-#{ENV['VERSION']}.gem",
content_type: 'application/octet-stream'
)
puts 'TASK END: github:release'
end
end