Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gh-release-assets

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh-release-assets

Upload assets to a GitHub release

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1K
decreased by-16.22%
Maintainers
4
Weekly downloads
 
Created
Source

gh-release-assets

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

npm build downloads

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

Keywords

FAQs

Package last updated on 14 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc