Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby script to download a release binaries and calculate SHA256 checksums #1049

Merged
merged 4 commits into from
Nov 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions scripts/release-checksums.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env ruby

require "open-uri"
require "digest"

tag = ARGV[0]
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)
content = open(url).read
Digest::SHA256.hexdigest(content)
end

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

OS | Arch | Package | SHA256 Checksum
-- | -- | -- | --
Windows | x64 | [exe](#{windows_exe}) | <code>#{windows_exe_sha256}</code>
macOS | x64 | [zip](#{macos_zip}) | <code>#{macos_zip_sha256}</code>
macOS | x64 | [DMG](#{macos_dmg}) | <code>#{macos_dmg_sha256}</code>
Linux | x64 | [AppImage](#{linux_appimage}) | <code>#{linux_appimage_sha256}</code>
)

puts checksums