b0VIM 8.1o"_MRa_joshJoshs-Mac-mini.local~josh/Projects/fastlane/fastlane/fastlane/lib/fastlane/actions/set_github_release.rbutf-8 3210#"! UtpVPW1Had"V?0 v M $ r H  | \ :  m (    &thR3 [Z^]3 M,Y9 6" Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_JSON] = get_result[:json] ) do |get_result| } end UI.user_error!("Failed to fetch the newly created release, but it *has been created* successfully.") UI.error("GitHub responded with #{get_result[:status]}:#{get_result[:body]}") '*' => proc do |get_result| error_handlers: { path: "repos/#{repo_name}/releases/#{release_id}", http_method: 'GET', api_bearer: api_bearer, api_token: api_token, server_url: server_url, GithubApiAction.run( # fetch the release again, so that it contains the uploaded assets self.upload_assets(assets, json['upload_url'], api_token, api_bearer) # upload assets if assets && assets.count > 0 assets = params[:upload_assets] Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_JSON] = json Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_RELEASE_ID] = release_id Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_HTML_LINK] = html_url UI.important("See release at \"#{html_url}\"") UI.success("Successfully created release at tag \"#{tag_name}\" on GitHub") release_id = json['id'] html_url = json['html_url'] json = result[:json] ) do |result| } end return nil UI.error("GitHub responded with #{result[:status]}:#{result[:body]}") '*' => proc do |result| end, UI.user_error!("You are not authorized to access #{repo_name}, please make sure you provided a valid API token (GITHUB_API_TOKEN)") UI.error(result[:body]) 401 => proc do |result| end, UI.user_error!("Repository #{repo_name} cannot be found, please double check its name and that you provided a valid API token (GITHUB_API_TOKEN)") UI.error(result[:body]) 404 => proc do |result| end, return nil UI.error("Release on tag #{tag_name} already exists!") UI.error(result[:body]) 422 => proc do |result| error_handlers: { body: payload, path: "repos/#{repo_name}/releases", http_method: 'POST', api_bearer: api_bearer, api_token: api_token, server_url: server_url, GithubApiAction.run( payload['target_commitish'] = params[:commitish] if params[:commitish] } 'prerelease' => !!params[:is_prerelease] 'draft' => !!params[:is_draft], 'body' => params[:description], 'name' => params[:name], 'tag_name' => params[:tag_name], payload = { tag_name = params[:tag_name] server_url = params[:server_url] api_bearer = params[:api_bearer] api_token = params[:api_token] repo_name = params[:repository_name] UI.important("Will also upload assets #{params[:upload_assets]}.") if params[:upload_assets] UI.important("Creating release of #{params[:repository_name]} on tag \"#{params[:tag_name]}\" with name \"#{params[:name]}\".") def self.run(params) class SetGithubReleaseAction < Action end SET_GITHUB_RELEASE_JSON = :SET_GITHUB_RELEASE_JSON SET_GITHUB_RELEASE_RELEASE_ID = :SET_GITHUB_RELEASE_RELEASE_ID SET_GITHUB_RELEASE_HTML_LINK = :SET_GITHUB_RELEASE_HTML_LINK module SharedValues module Actionsmodule FastlaneadH1X r 6 x A   X {3`VU.!b;]PF<;# end end end end :source_control def self.category end ] )' upload_assets: ["example_integration.ipa", "./pkg/built.gem"] commitish: "master", description: (File.read("changelog") rescue "No changelog provided"), tag_name: "v1.22.0", name: "Super New actions", api_token: ENV["GITHUB_TOKEN"], repository_name: "fastlane/fastlane", 'github_release = set_github_release( [ def self.example_code end true def self.is_supported?(platform) end ["czechboy0", "tommeier"] def self.authors end :hash def self.return_type end ].join("\n") "Access things like 'html_url', 'tag_name', 'name', 'body'" "A hash containing all relevant information of this release", [ def self.return_value end ] ['SET_GITHUB_RELEASE_JSON', 'The whole release JSON object'] ['SET_GITHUB_RELEASE_RELEASE_ID', 'Release id (useful for subsequent editing)'], ['SET_GITHUB_RELEASE_HTML_LINK', 'Link to your created release'], [ def self.output end ] end) UI.user_error!("upload_assets must be an Array of paths to assets") unless value.kind_of?(Array) verify_block: proc do |value| type: Array, is_string: false, optional: true, description: "Path to assets to be uploaded with the release", env_name: "FL_SET_GITHUB_RELEASE_UPLOAD_ASSETS", FastlaneCore::ConfigItem.new(key: :upload_assets, is_string: false), default_value: false, optional: true, description: "Whether the release should be marked as prerelease", env_name: "FL_SET_GITHUB_RELEASE_IS_PRERELEASE", FastlaneCore::ConfigItem.new(key: :is_prerelease, is_string: false), default_value: false, optional: true, description: "Whether the release should be marked as draft", env_name: "FL_SET_GITHUB_RELEASE_IS_DRAFT", FastlaneCore::ConfigItem.new(key: :is_draft, default_value_dynamic: true),ad 1rE   T z B h  l  h  l0Z"gslT default_value: Actions.lane_context[SharedValues::FL_CHANGELOG], optional: true, is_string: true, description: "Description of this release", env_name: "FL_SET_GITHUB_RELEASE_DESCRIPTION", FastlaneCore::ConfigItem.new(key: :description, optional: true), is_string: true, 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. Default: the repository's default branch (usually master)", env_name: "FL_SET_GITHUB_RELEASE_COMMITISH", FastlaneCore::ConfigItem.new(key: :commitish, optional: true), is_string: true, description: "Name of this release", env_name: "FL_SET_GITHUB_RELEASE_NAME", FastlaneCore::ConfigItem.new(key: :name, optional: false), is_string: true, description: "Pass in the tag name", env_name: "FL_SET_GITHUB_RELEASE_TAG_NAME", FastlaneCore::ConfigItem.new(key: :tag_name, default_value: nil), optional: true, conflicting_options: [:api_token], description: "Use a Bearer authorization token. Usually generated by Github Apps, e.g. GitHub Actions GITHUB_TOKEN environment variable", code_gen_sensitive: true, sensitive: true, env_name: "FL_GITHUB_RELEASE_API_BEARER", FastlaneCore::ConfigItem.new(key: :api_bearer, optional: true), default_value_dynamic: true, default_value: ENV["GITHUB_API_TOKEN"], is_string: true, code_gen_sensitive: true, sensitive: true, conflicting_options: [:api_bearer], description: "Personal API Token for GitHub - generate one at https://github.com/settings/tokens", env_name: "FL_GITHUB_RELEASE_API_TOKEN", FastlaneCore::ConfigItem.new(key: :api_token, end), UI.user_error!("Please include the protocol in the server url, e.g. https://your.github.server/api/v3") unless value.include?("//") verify_block: proc do |value| optional: true, default_value: "https://api.github.com", description: "The server url. e.g. 'https://your.internal.github.host/api/v3' (Default: 'https://api.github.com')", env_name: "FL_GITHUB_RELEASE_SERVER_URL", FastlaneCore::ConfigItem.new(key: :server_url, end), UI.user_error!("Please only pass the path, e.g. 'fastlane/fastlane'") if value.split('/').count != 2adxP{k\3%UI?> P O $ x - O A 4 Z 2  P 3  tX4u_#  vuZ}wvUK Lxw UI.user_error!("Please only pass the path, e.g. 'fastlane/fastlane'") if value.include?("github.com") verify_block: proc do |value| description: "The path to your repo, e.g. 'fastlane/fastlane'", env_name: "FL_SET_GITHUB_RELEASE_REPOSITORY_NAME", FastlaneCore::ConfigItem.new(key: :repository_name, [ def self.available_options end ].join("\n") "Out parameters provide the release's id, which can be used for later editing and the release HTML link to GitHub. You can also specify a list of assets to be uploaded to the release with the `:upload_assets` parameter." "If the tag doesn't exist, one will be created on the commit or branch passed in as commitish.", "Creates a new release on GitHub. You must provide your GitHub Personal token (get one from [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new)), the repository name and tag name. By default, that's `master`.", [ def self.details end "This will create a new release on GitHub and upload assets for it" def self.description ##################################################### # @!group Documentation ##################################################### end end UI.success("Successfully uploaded #{file_name}.") ) do |result| } end UI.user_error!("Failed to upload asset #{file_name} to GitHub.") UI.error("GitHub responded with #{result[:status]}:#{result[:body]}") '*' => proc do |result| error_handlers: { raw_body: File.read(file), url: expanded_url, headers: headers, http_method: 'POST', api_bearer: api_bearer, api_token: api_token, GithubApiAction.run( UI.important("Uploading #{file_name}") headers = { 'Content-Type' => 'application/zip' } # works for all binary files expanded_url = Addressable::Template.new(url_template).expand(name: file_name).to_s file_name = File.basename(file) require 'addressable/template' def self.upload_file(file, url_template, api_token, api_bearer) end end self.upload_file(absolute_path, upload_url_template, api_token, api_bearer) else end self.upload_file(tmpzip, upload_url_template, api_token, api_bearer) sh("cd \"#{File.dirname(absolute_path)}\"; zip -r --symlinks \"#{tmpzip}\" \"#{File.basename(absolute_path)}\" 2>&1 >/dev/null") tmpzip = File.join(dir, File.basename(absolute_path) + '.zip') Dir.mktmpdir do |dir| if File.directory?(absolute_path) UI.user_error!("Asset #{absolute_path} doesn't exist") unless File.exist?(absolute_path) # check that the asset even exists absolute_path = File.absolute_path(asset_path) # if it's a directory, zip it first in a temp directory, because we can only upload binary files def self.upload(asset_path, upload_url_template, api_token, api_bearer) end end self.upload(asset, upload_url_template, api_token, api_bearer) assets.each do |asset| def self.upload_assets(assets, upload_url_template, api_token, api_bearer) end end end return json || result[:body] else end return get_result[:json] UI.success("Successfully uploaded assets #{assets} to release \"#{html_url}\"")