Coder Social home page Coder Social logo

github-release-cli's Introduction

github-release-cli build status

NPM

A command-line tool for managing release assets on a GitHub repository.

Installation

npm install -g github-release-cli

Command Line Usage

Run github-release with -h or --help options:

Usage: github-release <command> [<args>]

Options:
  -V, --version          output the version number
  --baseurl <baseurl>    API endpoint (default: "https://api.github.com")
  --token <token>        OAuth2 token (default: null)
  --owner <owner>        The repository owner. (default: "")
  --repo <repo>          The repository name. (default: "")
  --tag <tag>            The name of the tag.
  --commitish <value>    Specifies the commitish value for tag. Unused if the tag already exists.
  --release-id <id>      The release id.
  --release-name <name>  The name of the release. (default: "")
  --body <body>          Text describing the contents of the tag.
  --draft [value]        `true` makes the release a draft, and `false` publishes the release.
  --prerelease [value]   `true` to identify the release as a prerelease, `false` to identify the release as a full release.
  -h, --help             display help for command

Commands

List

github-release list
  --owner cheton \
  --repo github-release-cli

Upload

github-release upload \
  --owner cheton \
  --repo github-release-cli \
  --tag "v0.1.0" \
  --release-name "v0.1.0" \
  --body "This release contains bug fixes and imporvements, including:\n..." \
  archive.zip index.html app.min.css app.min.js

Specify the commitish value for tag

github-release upload \
    --owner cheton \
    --repo github-release-cli \
    --commitish 6a8e375 \
    --tag "v0.1.0" \
    --release-name "v0.1.0" \
    --body "The commitish value for tag"

Create a prerelease

github-release upload \
  --owner cheton \
  --repo github-release-cli \
  --tag "v0.1.0" \
  --release-name "v0.1.0" \
  --body "This is a prerelease" \
  --prerelease

Change a prerelease to a published release

github-release upload \
  --owner cheton \
  --repo github-release-cli \
  --tag "v0.1.0" \
  --release-name "v0.1.0" \
  --body "This is a published release" \
  --prerelease=false

Delete

Delete release assets

You can use glob expressions to match files:

github-release delete \
  --owner cheton \
  --repo github-release-cli \
  --tag "v0.1.0" \
  archive.zip index.html "app.*"

Delete a release by specifying the tag name

github-release delete \
  --owner cheton \
  --repo github-release-cli \
  --tag "v0.1.0"

Delete a release by specifying the release id

github-release delete \
  --owner cheton \
  --repo github-release-cli \
  --release-id 17994985

Examples

https://github.com/cncjs/cncjs-pendant-tinyweb/blob/master/.travis.yml

Secure Setup

1. Get an OAuth token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note":

curl \
  -u 'username' \
  -d '{"scopes":["repo"], "note":"Publish to GitHub Releases"}' \
  https://api.github.com/authorizations

For users with two-factor authentication enabled, you must send the user's authentication code (i.e., one-time password) in the X-GitHub-OTP header:

curl \
  -u 'username' \
  -H 'X-GitHub-OTP: 000000' \
  -d '{"scopes":["repo"], "note":"Publish to GitHub Releases"}' \
  https://api.github.com/authorizations

2. Storing the OAuth token in an environment variable

For reducing security risks, you can store your OAuth token in an environment variable.

Export the token using the one you got from above:

export GITHUB_TOKEN=your_token

3. Set up a CI build

Now you're ready to upload assets to a GitHub repository from a CI server. For example:

COMMIT_LOG=`git log -1 --format='%ci %H %s'`
github-release upload \
  --owner=cheton \
  --repo=github-release-cli \
  --tag="latest" \
  --release-name="${TRAVIS_BRANCH}" \
  --body="${COMMIT_LOG}" \
  "releases/myapp-0.1.0-win-x32.exe" \
  "releases/myapp-0.1.0-win-x64.exe"

If you're using Travis CI, you may want to encrypt environment variables:

travis encrypt GITHUB_TOKEN=your_token

Learn how to define encrypted variables in .travis.yml:
https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml

License

MIT

github-release-cli's People

Contributors

cheton avatar hex0cter avatar kspearrin avatar matthewdolman avatar retorquere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

github-release-cli's Issues

crash on MSpanList_Insert

on MacOS catelina
$ yarn global add github-release
$ github-release

failed MSpanList_Insert 0x1304000 0x1a94657c7f438 0x0
fatal error: MSpanList_Insert

runtime stack:
runtime.throw(0x50a3cb)
/usr/local/Cellar/go/1.4/libexec/src/runtime/panic.go:491 +0xad fp=0x7ffeefbfed80 sp=0x7ffeefbfed50
runtime.MSpanList_Insert(0x530de8, 0x1304000)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mheap.c:692 +0x8f fp=0x7ffeefbfeda8 sp=0x7ffeefbfed80
MHeap_FreeSpanLocked(0x52d9e0, 0x1304000, 0x100)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mheap.c:583 +0x163 fp=0x7ffeefbfede8 sp=0x7ffeefbfeda8
MHeap_Grow(0x52d9e0, 0x8, 0x0)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mheap.c:420 +0x1a8 fp=0x7ffeefbfee28 sp=0x7ffeefbfede8
MHeap_AllocSpanLocked(0x52d9e0, 0x1, 0xcf4c020)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mheap.c:298 +0x365 fp=0x7ffeefbfee68 sp=0x7ffeefbfee28
mheap_alloc(0x52d9e0, 0x1, 0x12, 0xce7f000)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mheap.c:190 +0x121 fp=0x7ffeefbfee90 sp=0x7ffeefbfee68
runtime.MHeap_Alloc(0x52d9e0, 0x1, 0x10000000012, 0x1d0d9)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mheap.c:240 +0x66 fp=0x7ffeefbfeec8 sp=0x7ffeefbfee90
MCentral_Grow(0x535758, 0x7ffeefbfefb8)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mcentral.c:197 +0x8b fp=0x7ffeefbfef30 sp=0x7ffeefbfeec8
runtime.MCentral_CacheSpan(0x535758, 0x1007ffeefbfefe8)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mcentral.c:85 +0x167 fp=0x7ffeefbfef68 sp=0x7ffeefbfef30
runtime.MCache_Refill(0x1300000, 0x7ffe00000012, 0x7ffeefbff030)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mcache.c:90 +0xa0 fp=0x7ffeefbfef90 sp=0x7ffeefbfef68
runtime.mcacheRefill_m()
/usr/local/Cellar/go/1.4/libexec/src/runtime/malloc.c:368 +0x57 fp=0x7ffeefbfefb0 sp=0x7ffeefbfef90
runtime.onM(0x4136f0)
/usr/local/Cellar/go/1.4/libexec/src/runtime/asm_amd64.s:273 +0x9a fp=0x7ffeefbfefb8 sp=0x7ffeefbfefb0
runtime.mallocgc(0x120, 0x35c0a0, 0x0, 0x0)
/usr/local/Cellar/go/1.4/libexec/src/runtime/malloc.go:178 +0x849 fp=0x7ffeefbff068 sp=0x7ffeefbfefb8
runtime.newobject(0x35c0a0, 0x1300000)
/usr/local/Cellar/go/1.4/libexec/src/runtime/malloc.go:353 +0x49 fp=0x7ffeefbff090 sp=0x7ffeefbff068
runtime.newG(0x3676a)
/usr/local/Cellar/go/1.4/libexec/src/runtime/proc.go:233 +0x2a fp=0x7ffeefbff0a8 sp=0x7ffeefbff090
allocg(0x51e240)
/usr/local/Cellar/go/1.4/libexec/src/runtime/proc.c:925 +0x1f fp=0x7ffeefbff0b8 sp=0x7ffeefbff0a8
runtime.malg(0x8000, 0x51e400)
/usr/local/Cellar/go/1.4/libexec/src/runtime/proc.c:2106 +0x1f fp=0x7ffeefbff0e8 sp=0x7ffeefbff0b8
runtime.mpreinit(0x51ea20)
/usr/local/Cellar/go/1.4/libexec/src/runtime/os_darwin.c:137 +0x27 fp=0x7ffeefbff100 sp=0x7ffeefbff0e8
mcommoninit(0x51ea20)
/usr/local/Cellar/go/1.4/libexec/src/runtime/proc.c:201 +0xc9 fp=0x7ffeefbff128 sp=0x7ffeefbff100
runtime.schedinit()
/usr/local/Cellar/go/1.4/libexec/src/runtime/proc.c:138 +0x55 fp=0x7ffeefbff150 sp=0x7ffeefbff128
runtime.rt0_go(0x7ffeefbff188, 0x1, 0x7ffeefbff188, 0x0, 0x0, 0x1, 0x7ffeefbff468, 0x0, 0x7ffeefbff477, 0x7ffeefbff4b3, ...)
/usr/local/Cellar/go/1.4/libexec/src/runtime/asm_amd64.s:95 +0x116 fp=0x7ffeefbff158 sp=0x7ffeefbff150

Github warning for depreciation of "file" parameter

Hey!

I am getting a warning since uploads that [@octokit/rest] "file" parameter is deprecated for ".repos.uploadReleaseAsset()". Use "data" instead. Below is the complete log.

aayush@packet:/raid/los/out/target/product/PL2$ github-release upload --owner nokia-dev --repo android_device_nokia_sdm660-common --tag "test" --name "lineage-17.1-20200311-UNOFFICIAL" lineage-17.1-20200311-UNOFFICIAL-PL2.zip
[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
> getReleaseByTag: owner=nokia-dev, repo=android_device_nokia_sdm660-common, tag=test
No release found.
> createRelease: tag_name=test, target_commitish=, name=lineage-17.1-20200311-UNOFFICIAL, draft=false, prerelease=false
> uploadReleaseAsset: assets_url=https://api.github.com/repos/nokia-dev/android_device_nokia_sdm660-common/releases/24431050/assets
  #1: name="lineage-17.1-20200311-UNOFFICIAL-PL2.zip" filePath="lineage-17.1-20200311-UNOFFICIAL-PL2.zip"
{ Deprecation: [@octokit/rest] "file" parameter is deprecated for ".repos.uploadReleaseAsset()". Use "data" instead
    at Object.keys.forEach.key (/usr/local/lib/node_modules/github-release-cli/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js:13145:26)
    at Array.forEach (<anonymous>)
    at Object.patchedMethod [as uploadReleaseAsset] (/usr/local/lib/node_modules/github-release-cli/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js:13142:26)
    at _callee2$ (/usr/local/lib/node_modules/github-release-cli/lib/index.js:412:50)
    at tryCatch (/usr/local/lib/node_modules/github-release-cli/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/github-release-cli/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/github-release-cli/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/usr/local/lib/node_modules/github-release-cli/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /usr/local/lib/node_modules/github-release-cli/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
    at process._tickCallback (internal/process/next_tick.js:68:7) name: 'Deprecation' }

I wonder if the following commit is responsible for it: octokit/rest.js@dc2cc51

Problem with core-js

Hey, there,

I got an error when using the tool with an iOS build through buddybuild. This is it:

npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.

It started happening today. Tried to manually update the core-js dependency to over version 3 but the issue persists.

Programmatic usage

Is there a programmatic interface for this project? Instead of writing the entire shell script, I'd like to create a reusable and cross-platform node tool that can be used in the npm script:

{
  // ...
  "scripts": {
    // ...
    "postversion": "git push --follow-tags && create-github-release"
  },
  "github-release": {
    "changelog": "npm run generate-changelog --silent",
    "assets": [
      "dist/*"
    ]
  }
}

Body overwritten when --body not specified

We call upload from multiple build machines for each release. Only one of those uploads contain a body. Any call to upload that doesn't include a body causes the body of the release to be overwritten with an empty string. Could you not write body if it's empty? For example:

case 22:
	var data = {
		owner: owner,
		repo: repo,
		release_id: release.id,
		tag_name: tag,
		name: name || tag,
		draft: draft === undefined ? !!release.draft : false,
		prerelease: prerelease === undefined ? !!release.prerelease : false
	};
	var body = (body === undefined ? release.body || '' : body || '');
	
	if(body !== '')
		data['body'] = body;
	console.log('> updateRelease: release_id=' + release.id + ', tag_name=' + tag + ', name=' + (name || tag));
	_context.next = 25;
	return octokit.repos.updateRelease(data);

Cannot use Markdown in the body

When adding adding the body I would like to be able to pass in markdown in the release notes to the body. Problem is that if the markdown is stored in a variable line breaks are interpreted as assets. If I wrap the string in quotes like body="notes" the quotation marks are included in the request and so GitHub doesn't parse the markdown.

Possible to discard a draft?

If I create a draft with --draft can I then discard the draft using this library? I've experimented and haven't found a way to do it with the existing options.

Required @babel/runtime as a dependency

I installed v2.0.0 of github-release-cli and when I first ran it, I got the following error:
Error: Cannot find module '@babel/runtime/helpers/interopRequireWildcard'. Following a Google trail, I found that @babel/runtime needed to be installed as a dependency, so I manually installed it (npm install -g @babel/runtime), and the cli worked.

This suggests that @babel/runtime should be a required dependency in the package.json. I see that package.json has "babel-runtime": "^6.26.0",, but this apparently didn't work for me.

I was installing on RHEL 7.0

please add --gh-repo (combined owner and repo)

This would ease the use from GH actions, which does not have the "single" repo name in its default environment variables, only:

GITHUB_REPOSITORY The owner and repository name. For example, octocat/Hello-World.

While it is possible to split this combined one in a GH action before calling github-release it would be more useful to be able to pass that variable directly and let github-release split it (single place instead of many GH actions).

Github Enterprise Usage?

So github enterprise would have a unique URL such as

https://my_company.com/api/v3/[normal_request_header]

Should be an easy feature if not already there to add support to pass a custom URL as an argument to support Github Enterprise

Files not actually uploaded

I'm trying to upload to my release with the following code:

token=$(cat ${HOME}/.PAT)
github-release upload \
  --owner zwhitchcox \
  --repo cruster \
  --token ${token} \
  --tag "v0.0.1" \
  --name "Initial Release" \
  --body "My description"\
  --prerelease \
  cruster-0.1.0.AppImage

But the file simply isn't being uploaded. I seem to have followed the instructions. Any idea as to what's going wrong?

Specify the commit hash to tag

Unless I'm missing something, it would be awesome if you could specify a commit hash to tag as opposed to just tagging the latest commit. It seems to be supported in the github UI when you make a new release.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.