File: git.rake

package info (click to toggle)
ruby-autoparse 0.3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 364 kB
  • sloc: ruby: 2,250; makefile: 5
file content (45 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download
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
namespace :git do
  namespace :tag do
    desc 'List tags from the Git repository'
    task :list do
      tags = `git tag -l`
      tags.gsub!("\r", '')
      tags = tags.split("\n").sort {|a, b| b <=> a }
      puts tags.join("\n")
    end

    desc 'Create a new tag in the Git repository'
    task :create do
      changelog = File.open('CHANGELOG.md', 'r') { |file| file.read }
      puts '-' * 80
      puts changelog
      puts '-' * 80
      puts

      v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
      abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION

      git_status = `git status`
      if git_status !~ /nothing to commit \(working directory clean\)/
        abort "Working directory isn't clean."
      end

      tag = "#{PKG_NAME}-#{PKG_VERSION}"
      msg = "Release #{PKG_NAME}-#{PKG_VERSION}"

      existing_tags = `git tag -l #{PKG_NAME}-*`.split('\n')
      if existing_tags.include?(tag)
        warn('Tag already exists, deleting...')
        unless system "git tag -d #{tag}"
          abort 'Tag deletion failed.'
        end
      end
      puts "Creating git tag '#{tag}'..."
      unless system "git tag -a -m \"#{msg}\" #{tag}"
        abort 'Tag creation failed.'
      end
    end
  end
end

task 'gem:release' => 'git:tag:create'