class Dpl::Providers::Releases
Constants
- OCTOKIT_OPTS
- TIMEOUTS
- URL
Public Instance Methods
Source
# File lib/dpl/providers/releases.rb, line 205 def api @api ||= Octokit::Client.new(**creds, auto_paginate: true, connection_options: { request: TIMEOUTS }) end
Source
# File lib/dpl/providers/releases.rb, line 185 def asset(name) api.release_assets(url).detect { |asset| asset.name == name } end
Source
# File lib/dpl/providers/releases.rb, line 137 def content_type(file) type = MIME::Types.type_for(file).first type ||= 'application/octet-stream' type.to_s end
Source
# File lib/dpl/providers/releases.rb, line 158 def create_release api.create_release(slug, local_tag, octokit_opts.merge(draft: true)) rescue Octokit::NotFound error :insufficient_perm end
Source
# File lib/dpl/providers/releases.rb, line 209 def creds username && password ? { login: username, password: } : { access_token: token } end
Source
# File lib/dpl/providers/releases.rb, line 110 def delete(asset, file) info :overwrite_existing, file api.delete_release_asset(asset.url) end
Source
# File lib/dpl/providers/releases.rb, line 91 def deploy upload_files api.update_release(url, octokit_opts) end
Source
# File lib/dpl/providers/releases.rb, line 168 def env_tag tag = ENV['TRAVIS_TAG'] tag unless tag.to_s.empty? end
Source
# File lib/dpl/providers/releases.rb, line 219 def exists?(file) return true if File.exist?(file) error :missing_file, file false end
Source
# File lib/dpl/providers/releases.rb, line 226 def file?(file) return true if File.file?(file) warn :not_a_file, file false end
Source
# File lib/dpl/providers/releases.rb, line 213 def files files = file_glob? ? Dir.glob("{#{file.join(',')}}").uniq : file files = files.select { |file| exists?(file) } files.select { |file| file?(file) } end
Source
# File lib/dpl/providers/releases.rb, line 164 def local_tag env_tag || git_tag end
Source
# File lib/dpl/providers/releases.rb, line 85 def login user.login info :login, user.login error :insufficient_scopes unless sufficient_scopes? end
Source
# File lib/dpl/providers/releases.rb, line 115 def octokit_opts opts = with_tag(self.opts.dup) opts = with_target_commitish(opts) opts = opts.select { |key, _| OCTOKIT_OPTS.include?(key) } compact(opts.merge(body: release_notes, draft: draft?)) end
Source
# File lib/dpl/providers/releases.rb, line 154 def release releases.detect { |release| release.tag_name == local_tag } end
Source
# File lib/dpl/providers/releases.rb, line 189 def release_notes super || release_notes_file || nil end
Calls superclass method
Source
# File lib/dpl/providers/releases.rb, line 193 def release_notes_file release_notes_file? && exists?(super) && read(super) end
Calls superclass method
Source
# File lib/dpl/providers/releases.rb, line 201 def releases @releases ||= api.releases(slug) end
Source
# File lib/dpl/providers/releases.rb, line 181 def same_repo? slug == repo_slug end
Source
# File lib/dpl/providers/releases.rb, line 173 def sufficient_scopes? api.scopes.include?('public_repo') || api.scopes.include?('repo') end
Source
# File lib/dpl/providers/releases.rb, line 100 def upload_file(path) file = normalize_filename(path) asset = asset(file) return info :skip_existing, file if asset && !overwrite? delete(asset, file) if asset info :upload_file, file api.upload_asset(url, path, name: file, content_type: content_type(path)) end
Source
# File lib/dpl/providers/releases.rb, line 96 def upload_files files.each { |file| upload_file(file) } end
Source
# File lib/dpl/providers/releases.rb, line 143 def url if release_number? format(URL, slug, release_number) elsif release release.rels[:self].href else create_release.rels[:self].href end end
Source
# File lib/dpl/providers/releases.rb, line 79 def validate info :deploy shell :git_fetch_tags if env_tag.nil? info :local_tag end
Source
# File lib/dpl/providers/releases.rb, line 123 def with_tag(opts) return opts if tag_name? || draft? info :set_tag_name, local_tag opts.merge(tag_name: local_tag) end
Source
# File lib/dpl/providers/releases.rb, line 130 def with_target_commitish(opts) return opts if target_commitish? || !same_repo? info :set_target_commitish, git_sha opts.merge(target_commitish: git_sha) end