Giter VIP home page Giter VIP logo

publish-release's Introduction

publish-release

Create GitHub releases with assets from CLI, or from JS.

Build Status

js-standard-style

Installation

NPM

npm install --save publish-release
npm install -g publish-release # CLI

CLI Usage

The CLI looks in 2 places for configuration: arguments passed, and a publishRelease object (see the API usage below for the format) in the package.json. If it can't find the info it needs from those places, it will run a wizard. This means that you can create a release just by running publish-release, and following the wizard.

$ publish-release --help
Usage: publish-release {options}

Options:

  --token [token]                 GitHub oAuth token.

  --owner [owner]                 GitHub owner of the repository.
                                  Defaults to parsing repository field in
                                  the project's package.json

  --repo [repo]                   GitHub repository name.
                                  Defaults to parsing repository field in
                                  the project's package.json

  --tag [tag]                     Git tag to base the release off of.
                                  Defaults to latest tag.

  --name [name]                   Name of the new release.
                                  Defaults to the name field in the
                                  package.json, plus the git tag.

  --notes [notes]                 Notes to add to release, written in Markdown.
                                  Defaults to opening the $EDITOR.

  --template [path to template]   Markdown file to open for editing notes.
                                  Will open the template in $EDITOR.

  --draft                         Pass this flag to set the release as a draft.

  --prerelease                    Pass this flag to set the release as a
                                  prerelease.

  --reuseRelease                  Pass this flag if you don't want the plugin to create a new release if one already
                                  exists for the given tag.

  --reuseDraftOnly                Pass this flag if you only want to reuse a release if it's a draft. It prevents
                                  you from editing already published releases.

  --skipAssetsCheck               Don't check if assets exist or not. False by default.

  --skipDuplicatedAssets          Pass this flag if you don't want the plugin to replace assets with the same
                                  name. False by default.

  --skipIfPublished               Pass this flag if you don't want a new release to be created if a release with
                                  the same tag has already been published (is not a draft). False by default.

  --editRelease                   Pass this flag if you want to edit release name, notes, type and target_commitish.
                                  It will need reuseRelease or/and reuseDraftOnly true to edit the release.

  --deleteEmptyTag                Pass this flag if you want to delete an empty tag after editing it. Usually happens
                                  when you edit from `prerelease or release` to `draft`.

  --assets [files]                Comma-separated list of filenames.
                                  Ex: --assets foo.txt,bar.zip

  --apiUrl [apiurl]               Use a custom API URL to connect to GitHub Enterprise instead of github.com.
                                  Defaults to "https://api.github.com"
                                  Ex: --apiUrl "https://myGHEserver/api/v3"

  --target_commitish [commitish]  Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA.
                                  Defaults to the default branch of the repository.
                                  Ex: --target_commitish "master"

API Usage

Using it from the API will not inherit any configuration properties from other sources (i.e. the package.json), and requires you to pass all properties in yourself.

var publishRelease = require('publish-release')

publishRelease({
  token: 'token',
  owner: 'remixz',
  repo: 'publish-release',
  tag: 'v1.0.0',
  name: 'publish-release v1.0.0',
  notes: 'very good!',
  draft: false,
  prerelease: false,
  reuseRelease: true,
  reuseDraftOnly: true,
  skipAssetsCheck: false,
  skipDuplicatedAssets: false,
  skipIfPublished: false,
  editRelease: false,
  deleteEmptyTag: false,
  assets: ['/absolute/path/to/file'],
  apiUrl: 'https://myGHEserver/api/v3',
  target_commitish: 'master'
}, function (err, release) {
  // `release`: object returned from github about the newly created release
})

publish-release emits the following events on the API:

  • create-release - Emits before the request is made to create the release.
  • created-release - Emits after the request is made successfully.
  • reuse-release - Emits if, instead of creating a new release, the assets will be uploaded to an existing one (if one can be found for the given tag).
  • 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.
  • duplicated-asset - {name} - Emits after found a duplicated asset file. Emits the name of the file.
  • duplicated-asset-deleted - {name} - Emits after delete a duplicated asset file. Emits the name of the file.
  • edit-release - {object} Emits when will edit a release. Emits the actual release object.
  • edited-release - {object} Emits after edit a release. Emits the modified object.
  • deleted-tag-release - {name} Emits after editing release from prerelease or release to draft, preventing from leaving an empty tag for a edited release. Emits the deleted tag name string.

Usage with Gulp

Please see the Gulp version of this module: https://github.com/Aluxian/gulp-github-release

publish-release's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar

publish-release's Issues

Dont use wizzard

First of all thanks for this package (looks very useful), This is a question actually not a bug.

I want to run publish-release from my build system in this case i would like to use all the defaults from package.json and not be prompted by the wizzard. Is this possible with the current version?

Create tests

Create automated tests to make application easier to grow

  • API
  • CLI

Duplicate draft release created when published release with same name exists

Hi there! I'm trying to use this library to automatically create GitHub releases and upload assets as a CI step. I've noticed that when reuseRelease and reuseDraftOnly are true, a duplicate draft release gets created if there's already a published release by the same name.

Here's what I'm trying to accomplish:

  • Create a draft release for version v1.0.0 if one doesn't already exist and there's no published release by the same name
  • If a draft v1.0.0 release exists, update the release and replace its assets
  • If a published v1.0.0 release exists, don't create a new draft release for v1.0.0 and don't update existing assets

It doesn't seem possible to do this currently since using reuseRelease and reuseDraftOnly causes a new draft release to be created if one doesn't already exist with the same name.

Is this the intended behavior? If not, could I send a PR for a new parameter that will skip draft release creation if there's already a published release with the same name?

Thanks!

Can't re-upload on corrupted assets

  • Cant re-upload or delete if connection is closed in the middle of the upload.
  • Red symbol appear next to the asset inside the release.
  • This asset is only listed inside the edit mode of the release.

Rework reuseRelease option condition

Description

When you check for reuseRelease, it returns a list of releases and only check the latest one.
If you want to reuse a release that is in the middle of road, you will probably receive an error, because it will try to create a new one.

Expected behavior

Search using Get release by tag name.

Can't use "Get a release by tag name" because "tag name" means existing git tag, but we draft release and don't create git tag.

What we can do

Search for each by the given tag

Problem

You can't get draft release with Get release by tag name.

Improve control error

Every time that there's a problem uploading a release, it throws an TypeError: Cannot read property 'split' of undefined error at

var uploadUri = obj.createRelease.upload_url.split('{')[0] + '?name=' + fileName

Cope better with `EDITOR` not being defined

There are a couple of ways this could be achieved:

  1. Fail-fast with a nice error message if EDITOR has not been defined.
  2. Ask the developer to enter the path to their editor in lieu of EDITOR not being defined.

Ideally, my preference would be for option 2, as I plan to use publish-release within the postpublish hook of all our modules, and this would allow developers who run npm publish to still have things work, rather than requiring them to define EDITOR, then re-run npm run postpublish.

Upload hangs with no events emitted

Once in a while, when uploading an asset, upload would hang with no event being emitted. The theory is that sometimes uploadAssets never calls the callback or emits any events. In that case, events logged would look like:

...

19:50:47 event upload-progress test-asset.pkg {
  percentage: 0.49955797361536614,
  transferred: 332384,
  length: 66535621,
  remaining: 66203237,
  eta: 199,
  runtime: 0,
  delta: 332384,
  speed: 332384
}

19:50:47  upload-progress test-asset.pkg {
  percentage: 1.5830317417492805,
  transferred: 1053280,
  length: 66535621,
  remaining: 65482341,
  eta: 62,
  runtime: 0,
  delta: 720896,
  speed: 1053280
}

19:50:47 event duplicated-asset test-asset.pkg

20:50:47 Error: Timeout reached while executing task publishReleaseAsync

The last line at 20:50:47 is a timeout check wrapper workaround that is used to identify upload has stalled.

Not publishing release only save as draft

Hi

i am using below command to publish release. tag published successfully but in release tab i cant see publish release it showing as pre-release/draft

publish-release --target_commitish master --draft true --prerelease true --name title --notes "Release notes here" --repo xxx --owner xxxx --tag "v5"

image

how i can publish saved draft ?

Error handling bug

see aluxian/gulp-github-release#3

I have fixed this bug in this project and in https://github.com/Aluxian/gulp-github-release and will create the Pull requests.

Basically this code as an EventEmitter should emit 'error' events.
It also needed to handle the case where createRelease had a http error status code , ie >= 400, because although it handled a request err request does not think a 400 code is an error... it is correct beacuse it is a valid http response :-).

However if the createRelease gets a 400 or above (eg 401 not authorised, due to bad token) then it need to flag an error or else the downstream uploadAssets gets a bogus body object and fails.

Anyway, PR coming shortly.

Allow to edit release

Description

By now, you can only reuse a release to:

  • Overwrite assets.

Expected behavior

Use option called editRelease, defaults false

When editRelease === true, it will overwrite all options bellow:

  • release name
  • release notes
  • release type
  • release target_commitish

release tag: to also edit release tag it would be necessary to have another input tag like newReleaseTag, because it uses the tag to reuse the release and edit it

Options

editRelease - defaults false
deleteEmptyTag - defaults false

Notes

reuseRelease or/and reuseDraftOnly need to be true or pass through the condition

Allow to

  • Edit name of release
  • Edit release notes
  • Change release type from draft to prerelease or release
  • Change release type from prerelease/release to release/prerelease or draft*
    *If any release goes from prerelease or release to draft the tag will be left alone
    • deleteEmptyTag - Delete tag if it's edditing from prerelease or release to draft (include an option to enable or not)

Emits

edit-release: Emits when will edit a release. Emits the actual release object.
edited-release: Emits after edit a release. Emits the modified object.
deleted-tag-release: Emits after editing release from prerelease or release to draft, preventing from leaving an empty tag for a edited release. Emits the deleted tag name string.

Why return the object?
Allow to compare the old one with the new one, showing the changes to the interface

Documentation

  • Update README.md
  • Update cli
  • Update help.txt

Needed first

There are four hyphens prefixing my release name

Hey guys,

just beginning to use this package. It's kinda strange, everything works except the release name. I input it properly (and I can console.log it out correctly), but it get's prefixed with four hyphens when uploaded.

Is this a known issue?

Thanks for your help!

Error! The first release should be created manually.

> np major --no-publish --yolo && release

 ✔ Prerequisite check
 ✔ Git
 ✔ Bumping version
 ✔ Pushing tags

 wifi-tracker 1.0.0 published 🎉
✔ Checking if release already exists
✖ Loading commit history

Error! The first release should be created manually.

Why should the first release be created manually?

Option to create a tag instead of a release

Seems GitHub releases are in fact tags with steroids, so it would be cool to have a boolean flag to create easily a tag or a release.

My use case is to create releases only on NodeOS master branch, but also allow to make releases for the commits in other branchs that pass the tests, but instead of doing full releases, I want to do "tag releases" so they are hidden from the list of "official" releases (the ones from the master branch).

Expected behaviour for second asset upload

Assuming reuseRelease: true, what is the expected behaviour of running release twice? At the moment the message Uploading asset MyApp.zip is displayed but the asset is not actually uploaded or replaced the second time the program runs.

I think this should replace the assets with the same name, eventually with a parameter to disable this behaviour and throw an error instead.

Update inquirer

Adding this package causes audit to report 3 vulnerabilties because the version of inquirer used the package uses an old version of lodash. Could you update inquirer to fix this?

Looking for maintainers

Soo... sorry for my radio silence! I'm not the greatest at keeping up with a bunch of open source projects.

I'm not actively using this project myself anymore, so I'd like to find some new maintainers who use this a bit more, and let them handle this module how they wish to.

@aluxian @maxcnunes I already have you two as collaborators on this repo; if you'd like, I'll add you to the npm package as well, so you can publish new versions. If you're interested, just put your npm username and I'll add you to the package ASAP.

If there are any other active users who'd like to become maintainers, leave a comment here. Thanks!

Allow to define the name of the assets

Instead of only allow a list of strings, allow an object where keys are the assets and the value the name they will have when uploaded. As a plus, allow a list of objects too, so both objects and strings (when the name will be the same) can be combined.

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.