diff --git a/.gitignore b/.gitignore index 1d3956ea..4a291cec 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,7 @@ Gemfile.lock target .idea_modules .vagrant + +# The checksum is unique to each build, and we don't store builds in git. +# Consequently, ignore the checksum file. +resources/s3_website.jar.md5 diff --git a/bin/s3_website b/bin/s3_website index 596e3bcc..d67098d3 100755 --- a/bin/s3_website +++ b/bin/s3_website @@ -2,6 +2,7 @@ require File.expand_path(File.dirname(__FILE__)+ '/../lib/s3_website') require 'colored' +require 'digest/md5' class Cfg < Thor desc 'create', 'Create a config file with placeholder values' @@ -157,8 +158,18 @@ def resolve_jar(project_root, logger) File.exists? jar_path }. first + def jar_has_valid_checksum(jar_path, logger) + expected_checksum = File.read(File.dirname(__FILE__) + '/../resources/s3_website.jar.md5') + found_checksum = Digest::MD5.file(jar_path).hexdigest + if expected_checksum == found_checksum + true + else + logger.info_msg "The jar file has invalid checksum. Expected #{expected_checksum} but got #{found_checksum}" + false + end + end jar_file = - if found_jar + if found_jar and jar_has_valid_checksum(found_jar, logger) found_jar else is_development = File.exists?(project_root + '/.git') diff --git a/changelog.md b/changelog.md index aa03f2fa..95930309 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,10 @@ This project uses [Semantic Versioning](http://semver.org). +## 2.1.1 + +* Verify that the s3_website.jar is not corrupted. Download it again, if it is. + ## 2.1.0 * Show the upload reason when calling `push --verbose` diff --git a/lib/s3_website/version.rb b/lib/s3_website/version.rb index 39eb9893..e6a2f5b5 100644 --- a/lib/s3_website/version.rb +++ b/lib/s3_website/version.rb @@ -1,3 +1,3 @@ module S3Website - VERSION = '2.1.0' + VERSION = '2.1.1' end diff --git a/release b/release index 81b52678..7070ffbd 100755 --- a/release +++ b/release @@ -16,9 +16,14 @@ def run(cmd) end puts "Building s3_website.jar..." +jar_location = 'target/scala-2.11/s3_website.jar' run "./sbt clean" run "./sbt assembly" +# The bin s3_website uses the MD5 checksum to verify that the jar is not corrupted +jar_md5 = Digest::MD5.file(jar_location).hexdigest +File.write('resources/s3_website.jar.md5', jar_md5) + tag_name = "v#{version}" run "git tag #{tag_name} && git push origin #{tag_name}" run "git push" @@ -32,5 +37,5 @@ release = client.create_release( :body => "See https://github.com/laurilehmijoki/s3_website/blob/master/changelog.md##{version.gsub('.', '')}" ) puts "Uploading s3_website.jar..." -client.upload_asset(release[:url], 'target/scala-2.11/s3_website.jar') +client.upload_asset(release[:url], jar_location) run "gem push pkg/s3_website-#{version}.gem" diff --git a/s3_website.gemspec b/s3_website.gemspec index eb4b56f6..9df7c83c 100644 --- a/s3_website.gemspec +++ b/s3_website.gemspec @@ -25,7 +25,12 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '10.1.1' s.add_development_dependency 'octokit', '3.1.0' - s.files = `git ls-files`.split("\n").reject { |f| f.match('sbt-launch.jar') } + s.files = `git ls-files` + .split("\n") + # Reject the SBT jar, as it is a big file. + .reject { |f| f.match('sbt-launch.jar') } + # Include the checksum file in the gem: + .push('resources/s3_website.jar.md5') s.test_files = `git ls-files -- src/test/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"]