File: publish-gem

package info (click to toggle)
ruby-spamcheck 1.10.1-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 668 kB
  • sloc: python: 1,261; ruby: 484; makefile: 54; sh: 13
file content (41 lines) | stat: -rwxr-xr-x 1,022 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env ruby

#Borrowed from Gitaly 

require_relative 'run.rb'

def main(tag)
  version = tag.sub(/^v/, '')

  unless version.match?(/\d+\.\d+\.\d+(-rc\d+)?/)
    abort "Version string #{version.inspect} does not look like a Spamcheck Release tag (e.g. \"v1.0.2\"). Aborting."
  end

  ref = capture!(%w[git describe --tag]).chomp
  if ref != "v#{version}"
    abort "Checkout tag v#{version} to publish.\n\t git checkout v#{version}"
  end

  puts 'Testing for changed files'
  run!(%w[git diff --quiet --exit-code])

  puts 'Testing for staged changes'
  run!(%w[git diff --quiet --cached --exit-code])

  gem = "spamcheck-#{version}.gem"
  run!(['gem', 'build', 'spamcheck.gemspec', '--output', gem])
  abort "gem not found: #{gem}" unless File.exist?(gem)

  puts "Proceed to publish version #{tag}? Enter 'Yes' to continue; Ctrl-C to abort"
  $stdout.flush
  abort unless $stdin.gets.chomp == 'Yes'

  run!(%W[gem push #{gem}])
end

unless ARGV.count == 1
  warn "Usage: #{$0} TAG"
  abort
end

main(ARGV[0])