forked from bclymer/R.swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecffb7e
commit e6f86cc
Showing
29 changed files
with
519 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule R.swift.Library
updated
3 files
+4 −0 | .gitignore | |
+104 −0 | fastlane/Fastfile | |
+157 −0 | fastlane/actions/af_create_github_release.rb |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
fastlane_version "1.86.0" | ||
|
||
lane :release do | ||
ensure_git_branch(branch: "master") | ||
|
||
if options[:allow_dirty_branch] != true | ||
ensure_git_status_clean | ||
else | ||
Helper.log.info "Skipping the 'git status clean' check!".yellow | ||
end | ||
|
||
git_pull | ||
|
||
libraryVersion = read_podspec['dependencies']['R.swift.Library'].first | ||
unless prompt(text: "R.swift.Library #{libraryVersion} is used. Adjust podspec now if this is incorrect, ready?".green, boolean: true, ci_input: "") | ||
raise "Aborted by user".red | ||
end | ||
|
||
runalltests | ||
|
||
archivePath = '/tmp/rswift/rswift.xcarchive' | ||
|
||
xcodebuild( | ||
workspace: 'R.swift.xcworkspace', | ||
scheme: 'rswift', | ||
archivePath: archivePath, | ||
archive: true | ||
) | ||
|
||
zipPath = junk_zip( | ||
paths: ['#{archivePath}/Products/usr/local/bin/rswift', 'License'], | ||
output_path: '/tmp/rswiftrelease.zip' | ||
) | ||
|
||
unless is_ci | ||
notification( | ||
title: "R.swift release", | ||
message: "💡 Needs your attention." | ||
) | ||
end | ||
|
||
currentVersion = version_get_podspec() | ||
Helper.log.info "Current R.swift podspec version is #{currentVersion}" | ||
|
||
bumpType = prompt(text: "What kind of release is this? (major/minor/patch/custom)".green, boolean: false, ci_input: "") | ||
isPrerelease = false | ||
case bumpType | ||
when "major", "minor", "patch" | ||
version_bump_podspec(bump_type: bumpType) | ||
when "custom" | ||
newVersion = prompt(text: "What is the new custom version number?".green, boolean: false, ci_input: "") | ||
version_bump_podspec(version_number: newVersion) | ||
|
||
isPrerelease = prompt(text: "Is this a prerelease version?".green, boolean: true, ci_input: "") | ||
else | ||
raise "Invalid release type: #{bumpType}".red | ||
end | ||
|
||
changelog = prompt(text: "Please provide release notes:".green, boolean: false, ci_input: "", multi_line_end_keyword: "FIN") | ||
|
||
newVersion = version_get_podspec() | ||
unless prompt(text: "#{newVersion} has been prepped for release. If you have any additional changes you would like to make, please do those before continuing. Would you like to commit, tag, push and release #{newVersion} including all uncommitted changes?".green, boolean: true, ci_input:"y") | ||
raise "Aborted by user".red | ||
end | ||
|
||
git_commit( | ||
path: ".", | ||
message: "Preparing for the #{newVersion} release" | ||
) | ||
|
||
push_to_git_remote | ||
|
||
af_create_github_release( | ||
owner: 'mac-cain13', | ||
repository: 'r.swift', | ||
tag_name: 'v#{newVersion}', | ||
target_commitish: 'master', | ||
name: '#{newVersion}', | ||
body: '#{changelog}', | ||
prerelease: isPrerelease | ||
) | ||
|
||
af_upload_asset_for_github_release( | ||
file_path: zipPath | ||
) | ||
|
||
pod_push | ||
|
||
unless is_ci | ||
notification( | ||
title: "R.swift.Library release", | ||
message: "🎉 Version #{newVersion} is released." | ||
) | ||
end | ||
end | ||
|
||
desc "Runs all the tests" | ||
lane :runalltests do | ||
cocoapods(repo_update: false) | ||
|
||
scan( | ||
workspace: "R.swift.xcworkspace", | ||
scheme: "rswift", | ||
clean: true | ||
) | ||
scan( | ||
workspace: "R.swift.xcworkspace", | ||
scheme: "ResourceApp", | ||
sdk: "iphonesimulator", | ||
destination: "name=iPhone 6", | ||
clean: true | ||
) | ||
scan( | ||
workspace: "R.swift.xcworkspace", | ||
scheme: "ResourceApp-tvOS", | ||
sdk: "iphonesimulator", | ||
destination: "name=Apple TV 1080p", | ||
clean: true | ||
) | ||
end | ||
|
||
error do |lane, exception| | ||
unless is_ci | ||
notification( | ||
title: "R.swift.Library #{lane}", | ||
message: "❌ Failed with an exception." | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# From: https://github.com/AFNetworking/fastlane/blob/master/fastlane/actions/af_create_github_release.rb | ||
module Fastlane | ||
module Actions | ||
module SharedValues | ||
GITHUB_RELEASE_ID = :GITHUB_RELEASE_ID | ||
GITHUB_RELEASE_HTML_URL = :GITHUB_RELEASE_HTML_URL | ||
GITHUB_RELEASE_UPLOAD_URL_TEMPLATE = :GITHUB_RELEASE_UPLOAD_URL_TEMPLATE | ||
end | ||
|
||
# To share this integration with the other fastlane users: | ||
# - Fork https://github.com/KrauseFx/fastlane | ||
# - Clone the forked repository | ||
# - Move this integration into lib/fastlane/actions | ||
# - Commit, push and submit the pull request | ||
|
||
class AfCreateGithubReleaseAction < Action | ||
def self.run(params) | ||
require 'net/http' | ||
require 'net/https' | ||
require 'json' | ||
require 'base64' | ||
|
||
begin | ||
uri = URI("https://api.github.com/repos/#{params[:owner]}/#{params[:repository]}/releases") | ||
|
||
# Create client | ||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true | ||
http.verify_mode = OpenSSL::SSL::VERIFY_PEER | ||
|
||
dict = Hash.new | ||
dict["draft"] = params[:draft] | ||
dict["prerelease"] = params[:prerelease] | ||
dict["body"] = params[:body] if params[:body] | ||
dict["tag_name"] = params[:tag_name] if params[:tag_name] | ||
dict["name"] = params[:name] if params[:name] | ||
body = JSON.dump(dict) | ||
|
||
# Create Request | ||
req = Net::HTTP::Post.new(uri) | ||
# Add headers | ||
req.add_field "Content-Type", "application/json" | ||
# Add headers | ||
api_token = params[:api_token] | ||
req.add_field "Authorization", "Basic #{Base64.strict_encode64(api_token)}" | ||
# Add headers | ||
req.add_field "Accept", "application/vnd.github.v3+json" | ||
# Set header and body | ||
req.add_field "Content-Type", "application/json" | ||
req.body = body | ||
|
||
# Fetch Request | ||
res = http.request(req) | ||
rescue StandardError => e | ||
Helper.log.info "HTTP Request failed (#{e.message})".red | ||
end | ||
|
||
case res.code.to_i | ||
when 201 | ||
json = JSON.parse(res.body) | ||
Helper.log.info "Github Release Created (#{json["id"]})".green | ||
Helper.log.info "#{json["html_url"]}".green | ||
|
||
Actions.lane_context[SharedValues::GITHUB_RELEASE_ID] = json["id"] | ||
Actions.lane_context[SharedValues::GITHUB_RELEASE_HTML_URL] = json["html_url"] | ||
Actions.lane_context[SharedValues::GITHUB_RELEASE_UPLOAD_URL_TEMPLATE] = json["upload_url"] | ||
return json | ||
when 400..499 | ||
json = JSON.parse(res.body) | ||
raise "Error Creating Github Release (#{res.code}): #{json}".red | ||
else | ||
Helper.log.info "Status Code: #{res.code} Body: #{res.body}" | ||
raise "Error Creating Github Release".red | ||
end | ||
end | ||
|
||
##################################################### | ||
# @!group Documentation | ||
##################################################### | ||
|
||
def self.description | ||
"Create a Github Release" | ||
end | ||
|
||
def self.available_options | ||
[ | ||
FastlaneCore::ConfigItem.new(key: :owner, | ||
env_name: "GITHUB_OWNER", | ||
description: "The Github Owner", | ||
is_string:true, | ||
optional:false), | ||
FastlaneCore::ConfigItem.new(key: :repository, | ||
env_name: "GITHUB_REPOSITORY", | ||
description: "The Github Repository", | ||
is_string:true, | ||
optional:false), | ||
FastlaneCore::ConfigItem.new(key: :api_token, | ||
env_name: "GITHUB_API_TOKEN", | ||
description: "Personal API Token for GitHub - generate one at https://github.com/settings/tokens", | ||
is_string: true, | ||
optional: false), | ||
FastlaneCore::ConfigItem.new(key: :tag_name, | ||
env_name: "GITHUB_RELEASE_TAG_NAME", | ||
description: "Pass in the tag name", | ||
is_string: true, | ||
optional: false), | ||
FastlaneCore::ConfigItem.new(key: :target_commitish, | ||
env_name: "GITHUB_TARGET_COMMITISH", | ||
description: "Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists", | ||
is_string: true, | ||
optional: true), | ||
FastlaneCore::ConfigItem.new(key: :name, | ||
env_name: "GITHUB_RELEASE_NAME", | ||
description: "The name of the release", | ||
is_string: true, | ||
optional: true), | ||
FastlaneCore::ConfigItem.new(key: :body, | ||
env_name: "GITHUB_RELEASE_BODY", | ||
description: "Text describing the contents of the tag", | ||
is_string: true, | ||
optional: true), | ||
FastlaneCore::ConfigItem.new(key: :draft, | ||
env_name: "GITHUB_RELEASE_DRAFT", | ||
description: "true to create a draft (unpublished) release, false to create a published one", | ||
is_string: false, | ||
default_value: false), | ||
FastlaneCore::ConfigItem.new(key: :prerelease, | ||
env_name: "GITHUB_RELEASE_PRERELEASE", | ||
description: "true to identify the release as a prerelease. false to identify the release as a full release", | ||
is_string: false, | ||
default_value: false), | ||
|
||
] | ||
end | ||
|
||
def self.output | ||
[ | ||
['GITHUB_RELEASE_ID', 'The Github Release ID'], | ||
['GITHUB_RELEASE_HTML_URL', 'The Github Release URL'], | ||
['GITHUB_RELEASE_UPLOAD_URL_TEMPLATE', 'The Github Release Upload URL'] | ||
] | ||
end | ||
|
||
def self.return_value | ||
"The Hash representing the API response" | ||
end | ||
|
||
def self.authors | ||
["kcharwood"] | ||
end | ||
|
||
def self.is_supported?(platform) | ||
return true | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.