Skip to content

Commit

Permalink
refactor: Fetch and digest for release binaries using pure ruby
Browse files Browse the repository at this point in the history
with thread, remove dependency on system curl and sha256sum commands
  • Loading branch information
ashchan committed Nov 6, 2019
1 parent 559fc3f commit e887f84
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/release-checksums.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#!/usr/bin/env ruby

# curl and sha256sum are required to run this.
require "open-uri"
require "digest"

tag = ARGV[0]
puts "Generate release checksums for #{tag}, this could take a while..."
puts "Generating release checksums for #{tag}, this could take a while..."

windows_exe = "https://github.com/nervosnetwork/neuron/releases/download/#{tag}/Neuron-#{tag}-win-installer.exe"
macos_zip = "https://github.com/nervosnetwork/neuron/releases/download/#{tag}/Neuron-#{tag}-mac.zip"
macos_dmg = "https://github.com/nervosnetwork/neuron/releases/download/#{tag}/Neuron-#{tag}-mac.dmg"
linux_appimage = "https://github.com/nervosnetwork/neuron/releases/download/#{tag}/Neuron-#{tag}-linux-x86_64.AppImage"

def get_sha256_checksum(url)
%x(curl -L #{url} | sha256sum).split(" ").first
content = open(url).read
Digest::SHA256.hexdigest(content)
end

windows_exe_sha256 = get_sha256_checksum(windows_exe)
macos_zip_sha256 = get_sha256_checksum(macos_zip)
macos_dmg_sha256 = get_sha256_checksum(macos_dmg)
linux_appimage_sha256 = get_sha256_checksum(linux_appimage)
windows_exe_sha256, macos_zip_sha256, macos_dmg_sha256, linux_appimage_sha256 = [windows_exe, macos_zip, macos_dmg, linux_appimage].map do |url|
Thread.new { get_sha256_checksum(url) }
end.map(&:value)

checksums = %(
### Downloads
Expand Down

0 comments on commit e887f84

Please sign in to comment.