github-release-party 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36e90a03908ef079b264f0e8159049566e4f94acf164dfbcdd5c360936856729
4
- data.tar.gz: 2d3d346a630f2afe897f30b9aba7e6623a9fec2fc3b8794962c9fed8c2ff3e77
3
+ metadata.gz: d5daa687ea156f731f143bce3dc98a1fcc4a07464a793eb475f1b8d7ba55acc6
4
+ data.tar.gz: c75ed78a66ceff740603553d0ef81a2d6874d17ffefa63faf60ea7351f223b9c
5
5
  SHA512:
6
- metadata.gz: c2339bf5e9a31063e2292488431cda41aab6b342dc272c19821152cac54f1544848492d5cb5089ca09a5ae78b18597b4fff34bee24e510831dbc0017990ef8e3
7
- data.tar.gz: '08ccc13edd9326240bcda6fa0a2d9735bba3cd65a8436a3af73c5a9d8711d84d57a25399493a57ef010697b3c138062acdebb232b7cbfe6d1f716adf80767b96'
6
+ metadata.gz: 641bd4382b4c0e3974e12b218dd75099afc3bb2b8bfb651d750c4ce6f486060f9c6c8aae8570435209431766340f8d282660e8d7c9a0e46429f7202528bc1c65
7
+ data.tar.gz: edcd80c9993c93c0f0f95ae6fedfb2b33cfefa67e4fbe8a5233dfcab12e5473066a54312414624ec7bb7b3b9e705819fd016a78d7f9d2a2bd21d32007e628e85
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,129 @@
1
+ require "open3"
2
+ require "shellwords"
3
+ require "github-release-party"
4
+
5
+ def fly_deploy(args=[])
6
+ # grab the new version number from the "fly deploy" output
7
+ cmd = %w[fly deploy] + args
8
+ ver = Open3.popen2e(*cmd) do |stdin, output, thread|
9
+ v = nil
10
+ output.each do |line|
11
+ puts line
12
+ if /--> release (v\d+) created/ =~ line
13
+ v = $~[1]
14
+ end
15
+ end
16
+ v
17
+ end
18
+ return ver
19
+ end
20
+
21
+ def github_tag(hash, ver)
22
+ # build tag message
23
+ repo = GithubReleaseParty.repo
24
+ tag_name = "fly/#{ver}"
25
+ last_tag = `git describe --tags --abbrev=0 --match 'fly/v*' 2> /dev/null`.strip
26
+ if last_tag.empty?
27
+ # first deploy, use root hash
28
+ last_tag = `git rev-list --max-parents=0 HEAD`.strip[0..6]
29
+ first_deploy = true
30
+ end
31
+ commits = `git log #{last_tag}..#{hash} --reverse --first-parent --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
32
+ message = "Deploy #{hash[0..6]}\n\nDiff: https://github.com/#{repo}/compare/#{last_tag}...#{tag_name}\n#{commits}"
33
+
34
+ if first_deploy
35
+ message = "#{message.strip}\n"+`git show #{last_tag} -s --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
36
+ end
37
+
38
+ # tag and push new tag
39
+ puts
40
+ puts "Tagging #{tag_name}."
41
+ success = system "git tag -a -m #{Shellwords.shellescape(message)} #{tag_name} #{hash}"
42
+ abort if not success
43
+ puts
44
+ success = system "git push origin #{tag_name}"
45
+ abort if not success
46
+
47
+ # create GitHub release
48
+ puts
49
+ puts "Waiting 3 seconds to let GitHub process the new tag."
50
+ sleep(3)
51
+ GithubReleaseParty.create(tag_name, message)
52
+ end
53
+
54
+
55
+ desc "Deploy a new version to Fly"
56
+ task :deploy do
57
+ GithubReleaseParty.check_env!
58
+ ver = fly_deploy() or abort("Deploy failed.")
59
+ hash = `git rev-parse HEAD`.strip
60
+ github_tag(hash, ver)
61
+ end
62
+
63
+ namespace :deploy do
64
+ desc "Tag last release"
65
+ task :tag do
66
+ GithubReleaseParty.check_env!
67
+
68
+ # get fly version number
69
+ begin
70
+ fly_releases = JSON.parse(`fly releases --json`)
71
+ ver = fly_releases[0]["Version"]
72
+ hash = `git rev-parse HEAD`.strip
73
+ rescue
74
+ abort "There was a problem getting the release number. Have you logged in with flyctl? Try again with 'rake deploy:tag'."
75
+ end
76
+
77
+ github_tag(hash, ver)
78
+ end
79
+
80
+ desc "Rebuild all the release tags"
81
+ task :retag do
82
+ GithubReleaseParty.check_env!
83
+ releases = GithubReleaseParty.releases
84
+ repo = GithubReleaseParty.repo
85
+
86
+ tags = `git tag -l fly/v* --sort=version:refname`.split("\n")
87
+ puts "Found #{tags.length} tags."
88
+ tags.each_with_index do |tag_name, i|
89
+ puts
90
+ last_tag = if i == 0
91
+ `git rev-list --max-parents=0 HEAD`.strip
92
+ else
93
+ tags[i-1]
94
+ end
95
+
96
+ hash = `git rev-list --max-count=1 #{tag_name}`.strip
97
+ date = `git show --pretty="format:%ai" -s --no-color #{tag_name} | tail -1`.strip
98
+ commits = `git log #{last_tag}..#{tag_name} --reverse --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
99
+ message = "Deploy #{hash[0..6]}\n\nDiff: https://github.com/#{repo}/compare/#{last_tag}...#{tag_name}\n#{commits}"
100
+
101
+ if i == 0
102
+ message += "\n"+`git show #{last_tag} -s --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
103
+ end
104
+
105
+ success = system "GIT_COMMITTER_DATE='#{date}' git tag -f -a -m #{Shellwords.shellescape(message)} #{tag_name} #{tag_name}^{}"
106
+ abort if not success
107
+ success = system "git push -f origin #{tag_name}"
108
+ abort if not success
109
+
110
+ # update or create GitHub release
111
+ release = releases.find { |rel| rel["tag_name"] == tag_name }
112
+ if release
113
+ GithubReleaseParty.update(release["id"], tag_name, message)
114
+ else
115
+ GithubReleaseParty.create(tag_name, message)
116
+ end
117
+ end
118
+
119
+ puts
120
+ puts "Done"
121
+ end
122
+
123
+ desc "List the new commits since last deploy (you might want to pull first to ensure you have the latest tag)"
124
+ task :changes do
125
+ last_tag = `git describe --tags --abbrev=0 --match 'fly/v*' 2> /dev/null`.strip
126
+ last_tag = `git rev-list --max-parents=0 HEAD`.strip[0..6] if last_tag.empty?
127
+ system "git log --oneline --no-decorate --reverse #{last_tag}..HEAD"
128
+ end
129
+ end
@@ -28,7 +28,7 @@ def github_tag(hash, ver)
28
28
  last_tag = `git rev-list --max-parents=0 HEAD`.strip[0..6]
29
29
  first_deploy = true
30
30
  end
31
- commits = `git log #{last_tag}..#{hash} --first-parent --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
31
+ commits = `git log #{last_tag}..#{hash} --reverse --first-parent --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
32
32
  message = "Deploy #{hash[0..6]}\n\nDiff: https://github.com/#{repo}/compare/#{last_tag}...#{tag_name}\n#{commits}"
33
33
 
34
34
  if first_deploy
@@ -48,7 +48,7 @@ def github_tag(hash, ver)
48
48
  puts
49
49
  puts "Waiting 3 seconds to let GitHub process the new tag."
50
50
  sleep(3)
51
- GithubReleaseParty.create(tag_name, ver, message)
51
+ GithubReleaseParty.create(tag_name, message)
52
52
  end
53
53
 
54
54
 
@@ -95,7 +95,6 @@ namespace :deploy do
95
95
  puts "Found #{tags.length} tags."
96
96
  tags.each_with_index do |tag_name, i|
97
97
  puts
98
- ver = tag_name[/v(\d+)/]
99
98
  last_tag = if i == 0
100
99
  `git rev-list --max-parents=0 HEAD`.strip
101
100
  else
@@ -104,7 +103,7 @@ namespace :deploy do
104
103
 
105
104
  hash = `git rev-list --max-count=1 #{tag_name}`.strip
106
105
  date = `git show --pretty="format:%ai" -s --no-color #{tag_name} | tail -1`.strip
107
- commits = `git log #{last_tag}..#{tag_name} --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
106
+ commits = `git log #{last_tag}..#{tag_name} --reverse --pretty=format:"- [%s](https://github.com/#{repo}/commit/%H)"`
108
107
  message = "Deploy #{hash[0..6]}\n\nDiff: https://github.com/#{repo}/compare/#{last_tag}...#{tag_name}\n#{commits}"
109
108
 
110
109
  if i == 0
@@ -119,9 +118,9 @@ namespace :deploy do
119
118
  # update or create GitHub release
120
119
  release = releases.find { |rel| rel["tag_name"] == tag_name }
121
120
  if release
122
- GithubReleaseParty.update(release["id"], ver, message)
121
+ GithubReleaseParty.update(release["id"], tag_name, message)
123
122
  else
124
- GithubReleaseParty.create(tag_name, ver, message)
123
+ GithubReleaseParty.create(tag_name, message)
125
124
  end
126
125
  end
127
126
 
@@ -1,3 +1,3 @@
1
1
  class GithubReleaseParty
2
- VERSION = "0.3.5"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -20,10 +20,10 @@ class GithubReleaseParty
20
20
  return releases
21
21
  end
22
22
 
23
- def self.update(id, name, message)
24
- r = GitHub.patch("/repos/#{repo}/releases/#{id}", {
23
+ def self.update(release_id, name, message)
24
+ r = GitHub.patch("/repos/#{repo}/releases/#{release_id}", {
25
25
  name: name,
26
- body: message
26
+ body: message,
27
27
  }.to_json)
28
28
  if r.success?
29
29
  puts "GitHub release #{name} updated!"
@@ -33,11 +33,11 @@ class GithubReleaseParty
33
33
  end
34
34
  end
35
35
 
36
- def self.create(tag_name, name, message)
36
+ def self.create(tag_name, message)
37
37
  body = {
38
38
  tag_name: tag_name,
39
- name: name,
40
- body: message
39
+ name: tag_name,
40
+ body: message,
41
41
  }
42
42
 
43
43
  r = GitHub.post("/repos/#{repo}/releases", body.to_json)
@@ -48,7 +48,7 @@ class GithubReleaseParty
48
48
  puts
49
49
  puts "Body sent: #{body.to_json}"
50
50
  puts
51
- puts "Failed to create GitHub release!"
51
+ puts "Failed to create a GitHub release!"
52
52
  puts "Create it manually here: https://github.com/#{repo}/releases/new?tag=#{tag_name}"
53
53
  puts "Tag version: #{tag_name}"
54
54
  puts "Release title: #{tag_name}"
@@ -62,7 +62,7 @@ class GithubReleaseParty
62
62
  abort "Configure GITHUB_RELEASE_TOKEN to create GitHub releases. See https://github.com/stefansundin/github-release-party#setup"
63
63
  end
64
64
  if !repo
65
- abort "Can't find the GitHub repo. Please use the remote 'origin'."
65
+ abort "Can't find the GitHub repository. Please use the remote 'origin'."
66
66
  end
67
67
  end
68
68
 
@@ -103,7 +103,6 @@ class GithubReleaseParty
103
103
  "User-Agent" => "github-release-party/#{GithubReleaseParty::VERSION}",
104
104
  }
105
105
  if method == :request_post or method == :patch
106
- # response = http.send(:request_get, "/", headers)
107
106
  response = http.send(method, request_uri, body, headers)
108
107
  else
109
108
  response = http.send(method, request_uri, headers)
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-release-party
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Sundin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -31,7 +31,7 @@ cert_chain:
31
31
  E04BZKo2WzOTzSDymo97Yu4YFgyc98umMyeaCvPk4YmdNzqSanAXpY2bnsyu0CF5
32
32
  Td0=
33
33
  -----END CERTIFICATE-----
34
- date: 2019-12-23 00:00:00.000000000 Z
34
+ date: 2022-11-26 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
@@ -47,8 +47,8 @@ dependencies:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '12'
50
- description: I use this gem to automatically create GitHub releases when I deploy
51
- to Heroku. See the GitHub page for usage.
50
+ description: I use this gem to automatically create GitHub releases when I deploy.
51
+ See the GitHub page for usage.
52
52
  email:
53
53
  - rubygems@stefansundin.com
54
54
  executables: []
@@ -56,13 +56,14 @@ extensions: []
56
56
  extra_rdoc_files: []
57
57
  files:
58
58
  - lib/github-release-party.rb
59
+ - lib/github-release-party/tasks/fly.rb
59
60
  - lib/github-release-party/tasks/heroku.rb
60
61
  - lib/github-release-party/version.rb
61
62
  homepage: https://github.com/stefansundin/github-release-party
62
63
  licenses:
63
64
  - GPL-3.0
64
65
  metadata: {}
65
- post_install_message:
66
+ post_install_message:
66
67
  rdoc_options: []
67
68
  require_paths:
68
69
  - lib
@@ -77,8 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
78
  - !ruby/object:Gem::Version
78
79
  version: 1.3.6
79
80
  requirements: []
80
- rubygems_version: 3.0.3
81
- signing_key:
81
+ rubygems_version: 3.3.11
82
+ signing_key:
82
83
  specification_version: 4
83
84
  summary: Easily create GitHub releases.
84
85
  test_files: []
metadata.gz.sig CHANGED
Binary file