File: Rakefile

package info (click to toggle)
schleuder-gitlab-ticketing 1.0.0-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 264 kB
  • sloc: ruby: 775; makefile: 5
file content (122 lines) | stat: -rw-r--r-- 3,029 bytes parent folder | download | duplicates (3)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
project = 'schleuder-gitlab-ticketing'
require_relative "lib/#{project}.rb"

@version = SchleuderGitlabTicketing::VERSION
@tagname = "schleuder-gitlab-ticketing-#{@version}"
@gpguid = 'team@schleuder.org'
@filename_gem = "#{@tagname}.gem"
@filename_tarball = "#{@tagname}.tar.gz"

@gpg=File.exist?('/usr/bin/gpg2') ? '/usr/bin/gpg2' : '/usr/bin/gpg'

def edit_and_add_file(filename)
  puts "Please edit #{filename} to refer to version #{@version}"
  if system("gvim -f #{filename}.md")
    `git add #{filename}.md`
  else
    exit 1
  end
end

task :console do
  exec "irb -r #{File.dirname(__FILE__)}/lib/#{project}.rb"
end

task :publish_gem => :website
task :git_tag => :check_version

desc "Build new version: git-tag and gem-file"
task :new_version => [
    :check_version,
    :edit_readme, :edit_changelog,
    :git_add_version,
    :git_commit,
    :build_gem,
    :sign_gem,
    :build_tarball,
    :sign_tarball,
    :git_tag
  ] do
end

desc "Edit CHANGELOG.md"
task :edit_changelog do
  edit_and_add_file('CHANGELOG')
end

desc "Edit README"
task :edit_readme do
  edit_and_add_file('README')
end

desc 'git-tag HEAD as new version'
task :git_tag do
  `git tag -u #{@gpguid} -s -m "Version #{@version}" #{@tagname}`
end

desc "Add changed version to git-index"
task :git_add_version do
  `git add lib/#{project}/version.rb`
end

desc "Commit changes as new version"
task :git_commit do
  `git commit -m "Version #{@version}"`
end

desc 'Build, sign and commit a gem-file.'
task :build_gem do
  `gem build schleuder-gitlab-ticketing.gemspec`
end

desc 'OpenPGP-sign gem and tarball'
task :sign_tarball do
  `#{@gpg} -u #{@gpguid} -b #{@filename_tarball}`
end

desc 'OpenPGP-sign gem'
task :sign_gem do
  `#{@gpg} -u #{@gpguid} -b #{@filename_gem}`
end

desc 'Upload download-files (gem, tarball, signatures) to schleuder.org.'
task :upload_files do
  # Use rsync to ensure correct file permissions on the server (scp overwrites umask, ACL, etc.).
  puts `rsync -v -t --chmod=ugo=rwX #{@tagname}* schleuder.org:/var/www/download/ 2>&1`
end

desc 'Publish gem-file to rubygems.org'
task :publish_gem do
  puts "Really push #{@filename_gem} to rubygems.org? [yN]"
  if gets.match(/^y/i)
    puts "Pushing..."
    `gem push #{@filename_gem}`
  else
    puts "Not pushed."
  end
end

desc 'Build and sign a tarball'
task :build_tarball do
  `git archive --format tar.gz --prefix "#{@tagname}/" -o #{@filename_tarball} master`
end

desc 'Describe manual release-tasks'
task :website do
  puts "Please remember to publish the release-notes on the website and on schleuder-announce."
end

desc 'Check if version-tag already exists'
task :check_version do
  # Check if Schleuder::VERSION has been updated since last release
  if `git tag`.match?(/^#{@tagname}$/)
    $stderr.puts "Warning: Tag '#{@tagname}' already exists. Did you forget to update #{project}/version.rb?"
    $stderr.print "Delete tag to continue? [yN] "
    if $stdin.gets.match(/^y/i)
      `git tag -d #{@tagname}`
    else
      exit 1
    end
  end
end