Git Product home page Git Product logo

gh-release-assets's Introduction

gh-release-assets

npm travis

Upload assets to a GitHub release. Based on the awesome work of @remixz as part of publish-release.

Install

npm install gh-release-assets

Usage

Pass in the upload url and an array of local files you'd like to upload. If you want to specify a new name for the file once it is uploaded, use an object with a name and path keys.

var ghReleaseAssets = require('gh-release-assets')

ghReleaseAssets({
  url: 'https://uploads.github.com/repos/octocat/Hello-World/releases/1197692/assets{?name}',
  token: [MY_GITHUB_TOKEN],
  assets: [
    '/path/to/foo.txt',
    '/path/to/bar.zip',
    {
      name: 'baz.txt',
      path: '/path/to/baz.txt'
    }
  ]
}, function (err, assets) {
  console.log(assets)
})

GitHub returns the upload url in the correct format after you create a release as upload_url. You can also get the upload url from the releases endpoint like:

curl -i https://api.github.com/repos/:owner/:repo/releases

You can also use a username/password instead of a token by passing an auth object:

var ghReleaseAssets = require('gh-release-assets')

ghReleaseAssets({
  url: 'https://uploads.github.com/repos/octocat/Hello-World/releases/1197692/assets{?name}',
  auth: {
    username: 'CoolGuy'
    password: 'KeepItSecret'
  },
  assets: [
    '/path/to/foo.txt',
    '/path/to/bar.zip',
    {
      name: 'baz.txt',
      path: '/path/to/baz.txt'
    }
  ]
}, function (err, assets) {
  console.log(assets)
})

Either a token or auth is required.

gh-release-assets also emits the following events:

  • upload-asset - {name} - Emits before an asset file starts uploading. Emits the name of the file.
  • upload-progress - {name, progress} - Emits while a file is uploading. Emits the name of the file, and a progress object from progress-stream.
  • uploaded-asset - {name} - Emits after an asset file is successfully uploaded. Emits the name of the file.

Contributing

Contributions welcome! Please read the contributing guidelines before opening an issue or making a pull request.

License

ISC

gh-release-assets's People

Contributors

paulcpederson avatar ungoldman avatar

Watchers

 avatar  avatar  avatar

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.