Compare commits

...

5 Commits

Author SHA1 Message Date
Matyáš Kříž 5853ee8135 Upgrade Fastfile and podspec. `run` downloads the latest generator if it's deleted. 2018-03-23 16:03:34 +01:00
Matyáš Kříž 0ea1e57510 Make the script a bit more resilient. 2018-03-23 09:01:35 +01:00
Matyáš Kříž 34db5e6f9b Fix changelog creating and make commit message ignoring broader. 2018-03-09 16:56:02 +01:00
Matyáš Kříž 0c9d095ce5 Update Gemfile. 2018-03-09 15:06:29 +01:00
Matyáš Kříž 76c01a02e4 Add initial deployer script for deploying release drafts to github. 2018-03-09 14:58:21 +01:00
6 changed files with 255 additions and 10 deletions

94
.fastlane/Fastfile Normal file
View File

@ -0,0 +1,94 @@
fastlane_version '2.54.1'
default_platform :mac
fastlane_require 'json'
platform :mac do
before_all do
ensure_git_status_clean
ensure_git_branch
pod_lib_lint
end
desc 'Releases build specified by user.'
lane :release do |options|
release_type = UI.select('Select release type: ', %w[major minor patch])
upload_release release_type
end
desc 'Releases major build. (+1).0.0'
lane :major do |options| # fastlane major
upload_release 'major'
end
desc 'Releases minor build. X.(+1).0'
lane :minor do |options| # fastlane minor
upload_release 'minor'
end
desc 'Releases patch build. X.X.(+1)'
lane :patch do |options| # fastlane patch
upload_release 'patch'
end
def upload_release release_type
# Settings
cuckoo_gen_path = '../../Generator/.build/debug/cuckoo_generator'
binary_name = 'CuckooGenerator'
# GitHub username
username_var_name = 'GITHUB_USERNAME'
username = ENV[username_var_name]
# Personal Access Token
token_var_name = 'RELEASE_ACCESS_TOKEN'
access_token = ENV[token_var_name]
# Error Raisins
UI.input "Please type in your GitHub username or cancel the release and define enviroment variable \"#{token_var_name}\" with the personal access token to use." unless access_token
UI.input "Please type in your GitHub access token or cancel the release and define enviroment variable \"#{username_var_name}\" with your GitHub username." unless username
version = version_bump_podspec(path: 'Cuckoo.podspec', bump_type: release_type)
# URL variables
repo_path = 'Brightify/Cuckoo'
base_url = "github.com/repos/#{repo_path}/releases"
api_url = "https://api.#{base_url}"
auth_string = "#{username}:#{access_token}"
changelog = create_changelog(tag_name).gsub(/`/, '``').gsub(/'/, ''').gsub(/"/, '"').gsub(/\n/, '\\n')
add_git_tag(tag: new_tag, force: true)
# https://developer.github.com/v3/repos/releases/#create-a-release
creation_body = "'{\"tag_name\":\"#{tag_name}\",\"target_commitish\":\"master\", \"name\":\"New Release #{tag_name}\", \"body\":\"#{changelog}\", \"draft\":true, \"prerelease\":false}'"
creation_response = JSON.parse(`curl -X POST -d #{creation_body} -u #{auth_string} #{api_url} -v`)
raise 'Release draft creation failed!' unless creation_response
upload_url = (creation_response['upload_url']).sub(/{.*name.*}/, '')
# https://developer.github.com/v3/repos/releases/#upload-a-release-asset
upload_response = JSON.parse(`curl -X POST --data-binary "@#{cuckoo_gen_path}" -u "#{auth_string}" "#{upload_url}?name=#{binary_name}" -H "Content-Type:application/octet-stream"`)
raise 'Release draft upload failed!' unless upload_response
browser_dl_url = upload_response['browser_download_url']
# do with these as you please
$RELEASE_URL = creation_response['url']
end
def create_changelog new_tag
changelog = changelog_from_git_commits(pretty: "- %s", merge_commit_filtering: "exclude_merges")
if changelog
changelog.gsub(/.(?<=[^|\n]).*[B|b]ump.*\n?/, '')
else
'No new changes, sorry!'
end
end
after_all do |lane|
UI.success "All done!\nYou can now visit #{$RELEASE_URL} (command+click) and release the thing."
end
error do |lane, exception|
puts "Release failed. This might help: #{exception}"
end
end

1
.gitignore vendored
View File

@ -41,3 +41,4 @@ Generator/*.app
.idea/
cuckoo_generator
Generator/CuckooGenerator.xcodeproj
.fastlane

View File

@ -21,9 +21,9 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = '9.0'
s.source_files = ['Source/**/*.swift']
s.preserve_paths = ['Generator/**/*', 'run', 'build_generator']
generator_name = 'cuckoo_generator'
s.prepare_command = <<-CMD
git submodule update --init --recursive
./build_generator
curl -Lo #{generator_name} `curl "https://api.github.com/repos/Brightify/Cuckoo/releases/tags/#{s.version}" | grep -oe '"browser_download_url":\s*"[^" ]*"' | grep -oe 'http[^" ]*' | grep #{generator_name} | head -1`
CMD
s.frameworks = 'XCTest', 'Foundation'
s.requires_arc = true

5
Gemfile Normal file
View File

@ -0,0 +1,5 @@
# frozen_string_literal: true
source "https://rubygems.org"
gem 'json'
gem 'fastlane'

144
Gemfile.lock Normal file
View File

@ -0,0 +1,144 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.5)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
babosa (1.0.2)
claide (1.0.2)
colored (1.2)
colored2 (3.1.2)
commander-fastlane (4.4.6)
highline (~> 1.7.2)
declarative (0.0.9)
declarative-option (0.1.0)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.2.1)
excon (0.58.0)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
faraday (>= 0.7.4)
http-cookie (~> 1.0.0)
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fastimage (2.1.0)
fastlane (2.84.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
bundler (>= 1.12.0, < 2.0.0)
colored
commander-fastlane (>= 4.4.6, < 5.0.0)
dotenv (>= 2.1.1, < 3.0.0)
excon (>= 0.45.0, < 1.0.0)
faraday (~> 0.9)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 0.9)
fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-api-client (>= 0.13.1, < 0.14.0)
highline (>= 1.7.2, < 2.0.0)
json (< 3.0.0)
mini_magick (~> 4.5.1)
multi_json
multi_xml (~> 0.5)
multipart-post (~> 2.0.0)
plist (>= 3.1.0, < 4.0.0)
public_suffix (~> 2.0.0)
rubyzip (>= 1.1.0, < 2.0.0)
security (= 0.1.3)
slack-notifier (>= 2.0.0, < 3.0.0)
terminal-notifier (>= 1.6.2, < 2.0.0)
terminal-table (>= 1.4.5, < 2.0.0)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.5.2, < 2.0.0)
xcpretty (>= 0.2.4, < 1.0.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.1.3)
google-api-client (0.13.1)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.5)
httpclient (>= 2.8.1, < 3.0)
mime-types (~> 3.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
googleauth (0.5.3)
faraday (~> 0.12)
jwt (~> 1.4)
logging (~> 2.0)
memoist (~> 0.12)
multi_json (~> 1.11)
os (~> 0.9)
signet (~> 0.7)
highline (1.7.8)
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
json (2.1.0)
jwt (1.5.6)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
memoist (0.16.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.5.1)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nanaimo (0.2.3)
os (0.9.6)
plist (3.3.0)
public_suffix (2.0.5)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.1)
rouge (2.0.7)
rubyzip (1.2.1)
security (0.1.3)
signet (0.7.3)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (~> 1.5)
multi_json (~> 1.10)
slack-notifier (2.3.2)
terminal-notifier (1.8.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
tty-cursor (0.5.0)
tty-screen (0.6.4)
tty-spinner (0.8.0)
tty-cursor (>= 0.5.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)
unicode-display_width (1.3.0)
word_wrap (1.0.0)
xcodeproj (1.5.4)
CFPropertyList (~> 2.3.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.3)
xcpretty (0.2.8)
rouge (~> 2.0.7)
xcpretty-travis-formatter (0.0.4)
xcpretty (~> 0.2, >= 0.0.7)
PLATFORMS
ruby
DEPENDENCIES
fastlane
json
BUNDLED WITH
1.16.1

17
run
View File

@ -2,22 +2,23 @@
SCRIPT_PATH="$(dirname "$0")"
FILE_NAME="cuckoo_generator"
FILE_PATH="$SCRIPT_PATH/Generator/.build/debug/$FILE_NAME"
if [[ "$1" = "--clean" || ! -e "$FILE_PATH" ]]; then
pushd "$SCRIPT_PATH"
./build_generator
FILE_PATH="$SCRIPT_PATH/$FILE_NAME"
if [[ ! -e "$FILE_PATH" ]]; then
echo "No Cuckoo Generator found, downloading latest version..."
pushd "$SCRIPT_PATH"
curl -Lo ${FILE_NAME} `curl "https://api.github.com/repos/Brightify/Cuckoo/releases/latest" | grep -oe '"browser_download_url":\s*"[^" ]*"' | grep -oe 'http[^" ]*' | grep ${FILE_NAME} | head -1`
popd
fi
if [[ "$1" = "--clean" ]]; then
shift
fi
INPUT_FILES=""
if [[ "$#" > 0 ]]; then
INPUT_FILES=$(printf '%q ' "$@")
fi
if [[ -z $SCRIPT_INPUT_FILE_COUNT ]]; then
SCRIPT_INPUT_FILE_COUNT=0
fi
for (( i=0; i<$SCRIPT_INPUT_FILE_COUNT; i++ ))
do
INPUT_FILE="SCRIPT_INPUT_FILE_$i"