Skip to content

Commit

Permalink
0.5.0 Add release info, several fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTom committed Jul 13, 2017
1 parent 323c54e commit 61e261e
Show file tree
Hide file tree
Showing 33 changed files with 522 additions and 196 deletions.
7 changes: 6 additions & 1 deletion .mux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ windows:
lein trampoline cljsbuild auto electron-main-dev
7:
name: css
command: lein sass watch
command: |
lein sass watch
9:
name: watch-releases
command: |
bundle exec ./bin/update-releases -w
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ source 'https://rubygems.org'
gem 'activesupport'
gem 'addressable'
gem 'capybara'
gem 'chromedriver-helper'
gem 'faker'
gem 'faraday'
gem 'faraday_middleware'
gem 'filewatcher'
gem 'git'
gem 'json_roa-client', '>= 1.0.0', '< 2.0.0'
gem 'poltergeist'
gem 'pry'
gem 'rest-client'
gem 'rspec'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ GEM
faraday_middleware (0.11.0.1)
faraday (>= 0.7.4, < 1.0)
ffi (1.9.18)
filewatcher (0.5.4)
trollop (~> 2.0)
git (1.3.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
Expand Down Expand Up @@ -90,6 +92,7 @@ GEM
websocket (~> 1.0)
slop (3.6.0)
thread_safe (0.3.6)
trollop (2.1.2)
tzinfo (1.2.3)
thread_safe (~> 0.1)
unf (0.1.4)
Expand All @@ -112,6 +115,8 @@ DEPENDENCIES
chromedriver-helper
faker
faraday
faraday_middleware
filewatcher
git
json_roa-client (>= 1.0.0, < 2.0.0)
poltergeist
Expand All @@ -121,4 +126,4 @@ DEPENDENCIES
selenium-webdriver

BUNDLED WITH
1.14.5
1.14.6
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The Madek App
# The Madek Exporter


## Building the App for Production
Expand All @@ -7,12 +7,7 @@ We do this via our CI system, see the file [cider-ci.yml](cider-ci.yml).

## Development

The setup of the project is based on
[descjop](https://github.com/karad/lein_template_descjop). It has been adjusted
and cleaned up in many ways. Descjop consists essentially of conventions
and a number of of `lein` aliases. See the file [project.clj](project.clj).

See also the file [.mux.yml](.mux.yml).
See the files [project.clj](project.clj) and [.mux.yml](.mux.yml).

### First time preparation

Expand Down
1 change: 1 addition & 0 deletions app/dev/releases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}]
1 change: 1 addition & 0 deletions app/dev/releases.yml
2 changes: 1 addition & 1 deletion app/prod/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/site.css">
<title>Madek APP</title>
<title>Madek Exporter</title>
</head>
<body>
<div id="app">
Expand Down
1 change: 1 addition & 0 deletions app/prod/releases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}]
84 changes: 84 additions & 0 deletions bin/draft-gh-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env ruby

require 'active_support/all'
require 'addressable/template'
require 'addressable/uri'
require 'faraday'
require 'faraday_middleware'
require 'json'
require 'pry'
require 'yaml'

user = ENV['GH_USER'].presence || raise('gh username missing')
token = ENV['GH_TOKEN'].presence || raise('gh token missing')

conn = Faraday.new() do |conn|
conn.token_auth(token)
conn.basic_auth(user, token)
conn.headers['Content-Type'] = 'application/json'
conn.request :json
conn.response :json, :content_type => /\bjson$/
conn.adapter Faraday.default_adapter
end

def _version
release= YAML.load_file('releases.yml').first.with_indifferent_access
"#{release[:version_major]}.#{release[:version_minor]}.#{release[:version_patch]}" \
+ ( (pre = release[:version_pre]) ? "-#{pre}" : "") \
+ ( (build = release[:version_build]) ? "+#{build}" : "")
end

def version
@version ||= _version
end

def commitish
JSON.parse(ENV['CIDER_CI_CURRENT_BRANCH_HEADS']).first.presence.try(:strip) \
|| `git log -n 1 --pretty='%H'`.strip
end

def create_data
{ "tag_name": version,
"target_commitish": commitish,
"name": version,
"body": "Version #{version} of the Madek Exporter",
"draft": true }
end

existing_release = conn.get do |req|
req.url "https://api.github.com/repos/madek/madek-exporter/releases/tags/#{version}"
end

if existing_release.status == 200
raise "tag #{version} already exists"
end

unless existing_release.status == 404
raise 'expected response for existing_release is 404'
end

created_release = conn.post do |req|
req.url "https://api.github.com/repos/madek/madek-exporter/releases"
req.body = create_data.to_json
end

unless created_release.status == 201
raise "create release #{version} failed"
end

upload_url_template = Addressable::Template.new(created_release.body["upload_url"])

%w(Madek-App_Linux.zip Madek-App_Mac-OS.zip Madek-App_Windows.zip).each do |filename|
url = upload_url_template.expand(name: filename).to_s
file_content = IO.binread(filename)
uploaded = conn.post do |req|
req.url url
conn.headers['Content-Type'] = 'application/json'
req.body = file_content
end
unless uploaded.status == 201
raise "upload #{filename} failed"
end
end

exit 0
48 changes: 48 additions & 0 deletions bin/update-releases
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env ruby

require 'active_support/all'
require 'json'
require 'optparse'
require 'pry'
require 'yaml'
require 'filewatcher'


options = {watch: false, help: false}

def update
begin
releases_json = YAML.load_file("releases.yml").to_json
IO.write("app/prod/releases.json", releases_json)
IO.write("app/dev/releases.json", releases_json)
puts "Updated app/(prod|dev)/releases.json"
rescue Exception => e
puts e
end
end

parser = OptionParser.new do|opts|
opts.banner = "Usage: update-releases [options]"
opts.on('-w', '--watch', 'Wach and update continously') do
options[:watch] = true
end

opts.on('-h', '--help', 'Displays Help') do
options[:help] = true
puts opts
exit
end
end

parser.parse!

if not options[:help]
update
end

if options[:watch]
puts "Watching releases.yml ..."
FileWatcher.new(['releases.yml']).watch do |filename|
update
end
end
Loading

0 comments on commit 61e261e

Please sign in to comment.