Sha256: dd7f91a493470f787c7d3f1ac2e1c7a094b346d34f0571570eb38063fe758211
Contents?: true
Size: 1.6 KB
Versions: 12
Compression:
Stored size: 1.6 KB
Contents
#!/usr/bin/env ruby require 'targit' require 'mercenary' def upload(file, repo, tag, options) asset = Targit.new(file, repo, tag, options) asset.upload! puts "Successfully created asset! #{asset.url}" end # rubocop:disable Metrics/BlockLength Mercenary.program(:targit) do |p| p.version Targit::VERSION p.description 'Tool for adding GitHub release assets' p.syntax 'targit [options] USER/REPO TAG /path/to/file' p.option :force, '-f', '--force', 'Replace the asset if it already exists' p.option :create, '-c', '--create', 'Create release if it does not exist' p.option :release_name, '-r NAME', '--release NAME', 'Set the release name' p.option :prerelease, '-p', '--prerelease', 'With -c, create as a dev release' p.option :authfile, '-a FILE', '--authfile FILE', 'Set the auth files for GitHub credentials (comma-delimited)' p.option :name, '-n NAME', '--name NAME', 'Set the name for the release asset' p.option :api_endpoint, '--endpoint URL', 'Use a custom URL for the GitHub API' p.action do |_, options| repo, tag = ARGV.shift 2 if !repo || !tag puts p elsif !ARGV.empty? ARGV.each { |file| raise("#{file} not found") unless File.exist? file } ARGV.each do |file| # rubocop:disable Style/CombinableLoops puts "Adding #{file} on #{tag} of #{repo}" upload file, repo, tag, options end elsif !$stdin.tty? raise('Name required if file is passed via STDIN') unless options[:name] upload $stdin, repo, tag, options else # rubocop:disable Lint/DuplicateBranch puts p end end end # rubocop:enable Metrics/BlockLength
Version data entries
12 entries across 12 versions & 1 rubygems