Skip to content

Commit

Permalink
Verify s3_website.jar checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
laurilehmijoki committed Jun 6, 2014
1 parent 396c9da commit 204072e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion bin/s3_website
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion lib/s3_website/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module S3Website
VERSION = '2.1.0'
VERSION = '2.1.1'
end
7 changes: 6 additions & 1 deletion release
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
7 changes: 6 additions & 1 deletion s3_website.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 204072e

Please sign in to comment.