Skip to content

Commit

Permalink
fixing the release scripts for new code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Anema committed Oct 11, 2016
1 parent 0ae2adc commit 9c50d27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ linux: ## Build binaries for Linux (32 and 64 bit)
@echo "building linux-32" && export GOOS=linux; $(MAKE) build32 && echo "linux-32 build complete";

zip: ## Create zip file with distributable binaries
echo "compressing releases" && ./scripts/compress && echo "finished compressing";
@echo "compressing releases" && ./scripts/compress && echo "finished compressing";

upload_to_s3: ## Upload zip file with binaries to S3
@echo "uploading to S3" && ./scripts/release && echo "upload complete";
@echo "uploading to S3" && bundle exec ruby ./scripts/release && echo "upload complete";

help:
@grep -E '^[a-zA-Z_0-9-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
23 changes: 12 additions & 11 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
require 'fog'
require 'fog/aws'
require 'dotenv'
require 'json'
require 'digest'
Expand All @@ -8,8 +8,8 @@ require 'git'
Dotenv.load

class FileManager
ALL_RELEASES = "releases/all.json"
LATEST_RELEASE = "releases/latest.json"
ALL_RELEASES = 'releases/all.json'.freeze
LATEST_RELEASE = 'releases/latest.json'.freeze

attr_reader :bucket

Expand All @@ -30,24 +30,25 @@ class FileManager
get_file(filename).public_url
end

def fetch(filename, default: "")
def fetch(filename, default: '')
exists?(filename) ? get_file(filename).body : default
end

private

def get_file(name)
bucket.files.get(name)
end

def exists?(name)
bucket.files.head(name)
rescue => e
rescue
false
end
end

class Repository
GIT_DIR = File.expand_path(__FILE__ + "/..")
GIT_DIR = File.expand_path(__FILE__ + '/../..')

def initialize
@git = Git.open(GIT_DIR)
Expand Down Expand Up @@ -160,7 +161,7 @@ class FeedGenerator
end

def upload!(logger: nil)
logger.puts "Updating feeds" if logger
logger.puts 'Updating feeds' if logger
storage_manager.upload!(FileManager::LATEST_RELEASE, latest_feed)
storage_manager.upload!(FileManager::ALL_RELEASES, entire_feed)
end
Expand All @@ -179,13 +180,13 @@ class FeedGenerator

def as_hash
{
"version" => version,
"platforms" => releases.map(&:as_hash)
version: version,
platforms: releases.map(&:as_hash)
}
end
end

puts "Establishing Connection to Amazon S3"
puts 'Establishing Connection to Amazon S3'
connection = Fog::Storage.new(
provider: 'AWS',
aws_access_key_id: ENV['AWS_KEY_ID'],
Expand All @@ -194,7 +195,7 @@ connection = Fog::Storage.new(

bucket = Fog::Storage::AWS::Directory.new(key: ENV['AWS_BUCKET_NAME'], service: connection)
manager = FileManager.new(bucket)
puts "Determining latest release"
puts 'Determining latest release'
repo = Repository.new
version = repo.latest_version

Expand Down

0 comments on commit 9c50d27

Please sign in to comment.