Home

Awesome

gh-api-cli

travis Status Appveyor Status Go Report Card GoDoc MIT License

Package gh-api-cli is a command line utility to work with github api.

This tool is part of the go-github-release workflow

TOC

Install

Check the release page!

Glide

mkdir -p $GOPATH/src/github.com/mh-cbon/gh-api-cli
cd $GOPATH/src/github.com/mh-cbon/gh-api-cli
git clone https://github.com/mh-cbon/gh-api-cli.git .
glide install
go install

Bintray

choco source add -n=mh-cbon -s="https://api.bintray.com/nuget/mh-cbon/choco"
choco install gh-api-cli

Chocolatey

choco install gh-api-cli

linux rpm/deb repository

wget -O - https://raw.githubusercontent.com/mh-cbon/latest/master/bintray.sh \
| GH=mh-cbon/gh-api-cli sh -xe
# or
curl -L https://raw.githubusercontent.com/mh-cbon/latest/master/bintray.sh \
| GH=mh-cbon/gh-api-cli sh -xe

linux rpm/deb standalone package

curl -L https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh \
| GH=mh-cbon/gh-api-cli sh -xe
# or
wget -q -O - --no-check-certificate \
https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh \
| GH=mh-cbon/gh-api-cli sh -xe

Cli

gh-api-cli -help
NAME:
   gh-api-cli - Github api command line client

USAGE:
   gh-api-cli <cmd> <options>

VERSION:
   0.0.0

COMMANDS:
     add-auth              Add a new authorization
     list-auth             List authorizations
     rm-auth               Remove an authorization
     get-auth              Get token from a locally saved authorization
     create-release        Create a release
     rm-release            Delete a release
     upload-release-asset  Upload assets to a release
     dl-assets             Download assets
     rm-assets             Delete assets
     help, h               Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version
gh-api-cli add-auth -help
NAME:
   gh-api-cli add-auth - Add a new authorization

USAGE:
   gh-api-cli add-auth [command options] [arguments...]

OPTIONS:
   --username value, -u value  Github username
   --password value, -p value  Github password
   --name value, -n value      Name of the authorization to create
   --rights value, -r value    Permissions to set
EXAMPLE
  gh-api-cli add-auth -n test -r user -r repo # will prompt for username/password
  gh-api-cli add-auth -n test -r user -u your -p pwd # won t prompt unless you have 2F ident on
  gh-api-cli add-auth -n test -r user,repo -u your -p pwd

Where rights contains some of :

Name--
useruser:emailuser:follow
public_reporeporepo_deployment
notificationsrepo:statusdelete_repo
gistread:repo_hookwrite:repo_hook
admin:org_hookread:orgwrite:org
adminadmin:orgadmin:repo_hook
admin:public_keyread:public_keywrite:public_key
read:gpg_keywrite:gpg_keyadmin:gpg_key
gh-api-cli list-auth -help
NAME:
   gh-api-cli list-auth - List authorizations

USAGE:
   gh-api-cli list-auth [command options] [arguments...]

OPTIONS:
   --username value, -u value  Github username
   --password value, -p value  Github password
EXAMPLE
  gh-api-cli list-auth -n test # will prompt for username/password
  gh-api-cli list-auth -n test -u your -p pwd # won t prompt unless you have 2F ident on
gh-api-cli rm-auth -help
NAME:
   gh-api-cli rm-auth - Remove an authorization

USAGE:
   gh-api-cli rm-auth [command options] [arguments...]

OPTIONS:
   --username value, -u value  Github username
   --password value, -p value  Github password
   --name value, -n value      Name of the authorization to delete
EXAMPLE
  gh-api-cli rm-auth -n test # will prompt for username/password
  gh-api-cli rm-auth -n test -u your -p pwd # won t prompt unless you have 2F ident on
gh-api-cli get-auth -help
NAME:
   gh-api-cli get-auth - Get token from a locally saved authorization

USAGE:
   gh-api-cli get-auth [command options] [arguments...]

OPTIONS:
   --name value, -n value  Name of the authorization
EXAMPLE
  gh-api-cli get-auth -n test
gh-api-cli create-release -help
NAME:
   gh-api-cli create-release - Create a release

USAGE:
   gh-api-cli create-release [command options] [arguments...]

OPTIONS:
   --name value, -n value        Name of the authorization to use for identification
   --token value, -t value       Value of a personal access token
   --owner value, -o value       Repository owner
   --repository value, -r value  Repository name
   --guess                       Guess repository and user name from the cwd
   --ver value                   Version name
   --author value, -a value      Release author github username
   --draft value, -d value       Make a draft release (default: "no")
   --changelog value, -c value   A command to generate the description body of the release
EXAMPLE
  gh-api-cli create-release -n test -o mh-cbon -r gh-api-cli --ver 0.0.1
  gh-api-cli create-release -n test --guess --ver 0.0.1
gh-api-cli rm-release -help
NAME:
   gh-api-cli rm-release - Delete a release

USAGE:
   gh-api-cli rm-release [command options] [arguments...]

OPTIONS:
   --name value, -n value        Name of the authorization to use for identification
   --token value, -t value       Value of a personal access token
   --owner value, -o value       Repository owner
   --repository value, -r value  Repository name
   --guess                       Guess repository and user name from the cwd
   --ver value                   Version name
EXAMPLE
  gh-api-cli rm-release -n test -o mh-cbon -r gh-api-cli --ver 0.0.1
  gh-api-cli rm-release -n test --guess --ver 0.0.1
gh-api-cli upload-release-asset -help
NAME:
   gh-api-cli upload-release-asset - Upload assets to a release

USAGE:
   gh-api-cli upload-release-asset [command options] [arguments...]

OPTIONS:
   --name value, -n value        Name of the authorization to use for identification
   --token value, -t value       Value of a personal access token
   --glob value, -g value        Glob pattern of files to upload
   --owner value, -o value       Repository owner
   --repository value, -r value  Repository name
   --guess                       Guess repository and user name from the cwd
   --ver value                   Version name
EXAMPLE
  gh-api-cli upload-release-asset -n test -g README.md -o mh-cbon -r gh-api-cli --ver 0.0.1
  gh-api-cli upload-release-asset -n test -g README.md --guess --ver 0.0.1
gh-api-cli rm-assets -help
NAME:
   gh-api-cli rm-assets - Delete assets

USAGE:
   gh-api-cli rm-assets [command options] [arguments...]

OPTIONS:
   --name value, -n value        Name of the authorization to use for identification
   --token value, -t value       Value of a personal access token
   --glob value, -g value        Glob pattern of files to download
   --owner value, -o value       Repository owner
   --repository value, -r value  Repository name
   --guess                       Guess repository and user name from the cwd
   --ver value                   Version constraint
EXAMPLE
  gh-api-cli rm-assets -n test --glob file.package -o mh-cbon -r gh-api-cli --ver 0.0.1
  gh-api-cli rm-assets -n test -g file.package --guess --ver 0.0.1
gh-api-cli dl-assets -help
NAME:
   gh-api-cli dl-assets - Download assets

USAGE:
   gh-api-cli dl-assets [command options] [arguments...]

OPTIONS:
   --name value, -n value        Name of the authorization to use for identification
   --token value, -t value       Value of a personal access token
   --glob value, -g value        Glob pattern of files to download
   --out value                   Out format to write files (default: "%f")
   --owner value, -o value       Repository owner
   --repository value, -r value  Repository name
   --guess                       Guess repository and user name from the cwd
   --ver value                   Version constraint
   --skip-prerelease value       Skip prerelease releases (yes|no) (default: "no")
EXAMPLE
  gh-api-cli dl-assets -o mh-cbon -r gh-api-cli --ver 4.x --out "dl/%r.%v-%a.%e"
  gh-api-cli dl-assets -o mh-cbon -r gh-api-cli --ver 0.0.1 --out dl/%f
  gh-api-cli dl-assets -o mh-cbon -r gh-api-cli --ver 0.0.1 --out dl/%f -g '*amd64*deb'
  gh-api-cli dl-assets -o mh-cbon -r gh-api-cli --ver latest --out dl/%s/%r.%v-%a.%e
  gh-api-cli dl-assets -o mh-cbon -r gh-api-cli --out "dl/%s/%r-%v-%a.%e" --ver ">0.0.10"

Notes

When you add, remove, list authorizations, personal access token authentication is not permitted, see this

You are required to use a password.

Todo

Recipes

Testing

 (USER=xxx PWRD=yyy ./test.sh | grep "OK, ALL FINE") || (echo "" && echo "" && echo "beep boop failed")

Release the project

gump patch -d # check
gump patch # bump

History

CHANGELOG