GithubHelp home page GithubHelp logo

fastify / releasify Goto Github PK

View Code? Open in Web Editor NEW
59.0 15.0 12.0 172 KB

A tool to release in a simpler way your module

License: MIT License

JavaScript 100.00%
cli release release-notes github-releases changelog hacktoberfest fastify-tool

releasify's Introduction

releasify

CI NPM version NPM downloads JavaScript Style Guide

A CLI tool to simplify your release process!

Important note: This tool simplifies your release process, if you don't have one, it is the right time to start adopting one!

The Release Process with releasify

This is what you can achieve with releasify:

  1. You want to release your awesome-module
  2. Go to the local directory and checkout the branch you want to release
  3. Execute releasify publish (see the examples).

At this point, the tool will perform the following actions for you:

  • It checks that your local repo is aligned with your git remote
  • It updates the version of your package.json (version bump)
  • It publishes the module in the npm registry using your default settings
  • It commits & pushes the bumped version to your remote
  • It creates a GitHub release with a CHANGELOG description also creating a tag with the same version as per your package.json

A new version of your module is now published! šŸŽ‰

Install

// global install
npm i releasify -g

// npx usage
npx releasify <command>

// show man of a command
npx releasify <command> --help

// check the version installed
releasify -v

Note: You need Node.js >= 10 to use this CLI.

Commands

Check the man directory to see all the arguments detail or type npx releasify help to get a preview.

ā˜„ Publish

You need a GitHub OAUTH Token with scope repo:public_repo to run this command.

releasify publish [--path|-p <path>]             āž” The path to the project to release. Default `pwd`
                  [--tag|-t <pattern>]           āž” The pattern of the tag to release. Useful for multi-branch project. It is necessary to find the last tag released of that pipeline. Default `v${major version of the project}.\d+.\d+`
                  [--semver|-s <release>]        āž” Force the release type. The value must be [major, premajor, minor, preminor, patch, prepatch, prerelease]
                  [--verbose|-v <level>]         āž” Print out more info. The value must be [trace, debug, info, warn, error]. Default `warn`
                  [--remote|-r <string>]         āž” The remote git where push the bumped version. Useful if you are releasing. Default `origin`
                  [--branch|-b <string>]         āž” The branch you want to release. Useful when you need to release a multi-branch module. Default `master`
                  [--silent]                     āž” never ask for user input. Note that if 2FA is required for publishing this flag must be used with `npm-otp` flag
                  [--no-verify|-n]               āž” Add the `--no-verify` to the commit, useful for slow test you don't need to run in case of bump
                  [--gh-token|-k <env | token>]  āž” The GitHub OAUTH token. You can set it with an env var name or a valid token. Default env var `GITHUB_OAUTH_TOKEN`
                  [--gh-release-edit|-e]         āž” Open an editor to modify the release message before creating it on GitHub
                  [--gh-release-draft]           āž” Create the GitHub Release as draft. Default `false`
                  [--gh-release-prerelease]      āž” Create the GitHub Release as pre-release. Default `false`
                  [--gh-release-body|-x]            āž” Automatically generate body via Github. When `true` will take priority over `--gh-release-edit`. Default `false`
                  [--gh-group-by-label|-l <label>] āž” Group the commits in the changelog message by PR's labels
                  [--npm-access|-a <string>]       āž” It will set the --access flag of `npm publish` command. Useful for scoped modules. The value must be [public, restricted]
                  [--npm-dist-tag <string>]        āž” It will add a npm tag to the module, like `beta` or `next`
                  [--npm-otp <code>]               āž” It will provide the otp code to the npm publish. Use this only for CI. For publishing from your machine, omit this argument and you will be asked to enter OTP code just before the npm publish command gets executed.
                  [--major|-m]                     āž” It will unlock the release of a major release
                  [--help|-h]                      āž” Show this help message

Examples

The following example shows how to release a minor version of your-module to NPM (using 2FA authentication) with a custom GitHub release message:

export MY_ENV_OAUTH_KEY 0000000000000000000000000000000000000000
cd /your-module
releasify publish -v debug -s minor -k MY_ENV_OAUTH_KEY -e --npm-otp 123456

This example releases a patch version of mod in the branch 1.x. Here 2FA auth is disabled on NPM and the GitHub OAUTH token in stored as an environment variable as GITHUB_OAUTH_TOKEN:

releasify publish -p ./mod -b 1.x -t v1.* -v debug -s patch

Explanation:

  • -b: it will check that your local repository is in the right branch and it will be used in the bump phase
  • -t: it will be used to explore the git history to find the commit messages. This is necessary when your tag name pattern doesn't follow the v<semver-version> pattern. By default the value of this parameter is v${major version read from package.json}*

The following example release a major version of your-module to NPM with a grouped GitHub release message. If a PR has many matching labels, it will be assigned to the first label in the command line. If a PR doesn't have any match with the label in the args, it will append at the end of the message.

cd /your-module
releasify publish -v debug -m -s major -l feature -l bugfix -l documentation

# example message:
**feature**:
- four this is feature (#4)


**bugfix**:
- two this is a bugfix (#2)
- three this is a doc bugfix (#3)


**commit**:
- five this is a typescript pr (#5)

ā˜„ Draft

Print out the new version that should be released with its changelog listing the commit messages.

The commits shown are

  • from: the HEAD of your local project
  • to: the first commit or the last version tag you created

Moreover, if the commit message is written with the pattern: text describing (#123), where (#123) is the pull request ID, the labels of that PR are downloaded and processed by the template engine. These info are fetched from GitHub, keep in mind that there are rate limits.

releasify draft [--path|-p <path>]        āž” The path to the project to draft. Default `pwd`
                [--tag|-t <pattern>]      āž” The pattern of the tag to draft. Useful for multi-branch project. Default `v${major version of the project}.\d+.\d+`
                [--from-commit <hash>]    āž” Specify a commit hash where to start to generate the release message. Default `HEAD`
                [--to-commit <hash>]      āž” Specify a commit hash where to stop to generate the release message. The --tag arg will be ignored
                [--semver|-s <release>]   āž” Force the release type. The value must be [major, premajor, minor, preminor, patch, prepatch, prerelease]
                [--verbose|-v <level>]    āž” Print out more info. The value must be [trace, debug, info, warn, error]
                [--gh-group-by-label|-l <label>] āž” Group the commits in the changelog message by PR's labels
                [--help|-h]               āž” Show this help message

Examples

View the release message for your next release:

releasify draft

Build release messages between old commits in order to create a changelog if you don't have one:

releasify draft --from-commit 93c914beb07eede9635d1234c20cff0e41f093a1 --to-commit 8797fc32812fb988957145877429aa937af292f1

āš™ Config

Save your default settings to speed up even more your release! Whan you run this command a prompt will ask you the value to store for the arg setting. The values are saved in an encrypted file, so it is human-unreadable.

releasify config [--arg <string>]          āž” The argument to save
                 [--verbose|-v <level>]    āž” Print out more info. The value must be [trace, debug, info, warn, error]
                 [--help|-h]               āž” Show this help message

Examples

Save your github token (then digit it in the prompt):

releasify config --arg gh-token

Save the default logging and print out where the store file is saved:

releasify config --arg verbose -v info

License

Licensed under MIT.

releasify's People

Contributors

capaj avatar dancastillo avatar dependabot-preview[bot] avatar dependabot[bot] avatar eomm avatar fdawgs avatar jarrodconnolly avatar jsumners avatar lmammino avatar mcollina avatar piemme avatar simoneb avatar uzlopak avatar zekth 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

Watchers

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

releasify's Issues

Define CLI commands and parameters

We should define the big picture of what we want to do with the tool.

The commands I think could be needed are:

# will process the release
releasify publish

# print out all the info as if I release right now
releasify publish --dry-run

# print out the login of git and npm
releasify whoami

# do what will need for the login process
releasify login

Others?

add files to bump commit

šŸš€ Feature Proposal

Right now this tool bump a new version and push the package.json in the repo:

await git.add('package.json')

If a user (like me šŸ˜‡) have a prepublish or postpublish script that updates some files like the README.md will have a mismatch between the published version and the repository version (unless the user will commit the additional files to master by himself)

So it would be good to add a flag to let the user:

  • define a list of files to add to the bump commit
  • or simply run git add -A (since the publish command to check if the local repo is aligned with the remote branch).
  • or add a flag that will run git add -A

WDYT?

Remove octokit warning

The recent version of @octokit/rest has a warning:

[@octokit/rest] const Octokit = require("@octokit/rest") is deprecated. Use const { Octokit } = require("@octokit/rest") instead

We should update the codebase accordingly

add --version

Right now is not possible to check the releasify version installed with the simple:

releasify -v
releasify --version

We should support it

Ask for npm OTP token in the terminal at the point of publishing the package

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

šŸš€ Feature Proposal

ask a user to enter the 6 digit TOTP code at runtime of the CLI

Motivation

at the moment you have to input yout TOTP token upfront as CLI parameter --npm-otp 123456. This is not a good solution because this code changes every 30 seconds.
If operations of releasify take more than that user cannot use releasify, because it would always fail with

[] ERROR: npm publish returned code 1 and signal null 
    Error: npm publish returned code 1 and signal null 
        at ChildProcess.<anonymous> (/home/capaj/.nvm/versions/node/v16.7.0/lib/node_modules/releasify/lib/npm.js:22:14)
        at ChildProcess.emit (node:events:394:28)
        at maybeClose (node:internal/child_process:1064:16)
        at Socket.<anonymous> (node:internal/child_process:450:11)
        at Socket.emit (node:events:394:28)
        at Pipe.<anonymous> (node:net:672:12)

This is not a typical usecase, but it could occur on slower connections

Example

No response

Ping command doesn't returned success

When I run releasify publish -s minor -k TOKENĀ , I get:

ERROR: Ping command doesn't returned success
    Error: Ping command doesn't returned success
        at Object.ping (/Users/matteo/.nvm/versions/node/v10.15.2/lib/node_modules/releasify/lib/npm.js:32:15)

Apart from the grammar error (correct Ping command was not successful) - I don't see what I'm doing wrong.

Release automation per Fastify org

šŸš€ Feature Proposal

The manual trigger on github action with easy input of parameter. This lets us build an action on GH that will run releasify and input the OTP: so we could release without the needs of a laptop.

Questions:

  • Will the OTP expires during the workflow?
  • Who is authorized to run the action?

ERROR: There are ZERO commit to release! is thrown when doing a very first release of a package

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

x

Plugin version

x

Node.js version

16

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Ubuntu 21.04

Description

throw new Error('There are ZERO commit to release!')

Steps to Reproduce

try to make a very first release of some package by calling

releasify publish

for example you can check out this one:
https://github.com/nearform/mercurius-apollo-tracing/tree/bab75dee4988e47b0ee776ca21dab1a6f07edc0b

Expected Behavior

No error is thrown, package get's published

Include logs from NPM

šŸš€ Feature Proposal

The very useful logs were commented out, so any useful output from npm is hidden.

// TODO these streams are useful for debug!

Motivation

I was having npm authentication and publishing issues, but no matter the error, we just see this fairly unhelpful info.

reject(new Error(`${cmd} ${args} returned code ${code} and signal ${signal} ${stdout || ''}`))

I had to uncomment the lines in my local version to see what NPM was complaining about.

Example

Uncomment these two lines

    // cli.stdout.pipe(process.stdout)
    // cli.stderr.pipe(process.stdout)

error from/to commit delta

This works:
releasify draft --from-commit 96a621462e612da048837c923bb4b570c1e0b8be --to-commit HEAD

this not:
releasify draft --from-commit 96a621462e612da048837c923bb4b570c1e0b8be

when the repository doesn't have any tag already created.

We just need to add a || HEAD

toCommit = await git.getLastTagCommit(tagPattern)

  • test

Error doing publishing

šŸ› Bug Report

[1588343990110] ERROR (HttpError): Not Found
    HttpError: Not Found
        at /Users/matteo/.nvm/versions/node/v12.16.1/lib/node_modules/releasify/node_modules/@octokit/request/dist-node/index.js:66:23
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
        at async module.exports (/Users/matteo/.nvm/versions/node/v12.16.1/lib/node_modules/releasify/lib/commands/publish.js:155:27)
        at async Command.func (/Users/matteo/.nvm/versions/node/v12.16.1/lib/node_modules/releasify/lib/cli.js:18:7)
ERROR: Something went wrong creating the relase on GitHub.
The 'npm publish' and 'git push' has been done!
Consider creating a release on GitHub by yourself with this message:

To Reproduce

Steps to reproduce the behavior:

releasify publish -s major -m --npm-dist-tag next --gh-release-prerelease --npm-otp

Expected behavior

The release should be created on gh.

Type error is thrown, when repository in package.json is a string, not an object

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

x

Plugin version

x

Node.js version

16

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Ubuntu 21.04

Description

a valid value like:
"repository": "github:nearform/mercurius-apollo-tracing",

causes error like this:

    TypeError: Cannot destructure property 'owner' of 'parseGitUrl(...)' as it is null.
        at github (/home/capaj/.nvm/versions/node/v16.7.0/lib/node_modules/releasify/lib/github.js:7:11)
        at module.exports (/home/capaj/.nvm/versions/node/v16.7.0/lib/node_modules/releasify/lib/commands/draft.js:63:18)
        at async module.exports (/home/capaj/.nvm/versions/node/v16.7.0/lib/node_modules/releasify/lib/commands/publish.js:106:21)
        at async Command.func (/home/capaj/.nvm/versions/node/v16.7.0/lib/node_modules/releasify/lib/cli.js:18:7)

Steps to Reproduce

use
"repository": "github:nearform/mercurius-apollo-tracing",

Expected Behavior

no type error is thrown for plain string value in repository

saved config doen't apply

šŸ› Bug Report

The config command in the example doesn't works for gh-token

To Reproduce

  • Execute the example command
  • Run a publish
  • Error token too short

Expected behavior

The default values in args.js overwrite the config values configured

Unstable open-editor

We notice that opening the editor in "wait" mode is not stable in:

  • windows with vscode, notepad, notepad++

The issue happens when the editor is already opened, when it is closed it works (with tons of absolute path configured in order to run in windows).

The module used is open, preferred to open-editor because the last one doesn't have the wait option.

A snippet to try locally:

const { editMessage } = require('./lib/editor')

async function run () {
  const e = await editMessage('hello', 'hello.md')
  console.log(e)
}

run()

First release

I think we can release this. Iā€™m eager to start using it, it would speed up my dev workflow significantly already.

Package name

The name releasify it is used

Could we ask if the user is so kind to free the name or should we squeeze our fantasy? šŸ˜

Switch to official dependabot

šŸš€ Feature Proposal

Use the official github dependabot instead of the old one.

Example

The user opening dependabot PRs is dependabot-preview, suggesting that it's old one. #115

It should be changed to use the GitHub official app now.

Better error handling for "Clean Repo" check

šŸš€ Feature Proposal

When publishing we do a deep check on a clean "git status" object, and check it against the actual result of git.status on the path to the project we provide.

here:

assert.deepStrictEqual(compare, CLEAN_REPO, 'The git repo must be clean (committed and pushed) before releasing!')

Motivation

The issue is that no matter what the differences of the two objects is, the error prints:
The git repo must be clean (committed and pushed) before releasing!

My issue was that my branch was named "main" instead of the default "master". But the error message was throwing me off.

I propose to print the result of assert.deepStrictEqual, as it provides the expected vs. received, so it would flag up if the tracking or any other properties on those objects didn't match.

Alternatively, if we only care about the ahead & behind properties to determine the git status, we could only compare those 2 properties.

Example

   try {
      assert.deepStrictEqual(compare, CLEAN_REPO)
    } catch (err) {
      console.log(err)
    }

or something like:

  const CLEAN_REPO = {
    ahead: 0,
    behind: 0
  }

  const compare = {
    ahead: status.ahead,
    behind: status.behind
  }

  assert.deepStrictEqual(compare, CLEAN_REPO, 'The git repo must be clean (committed and pushed) before releasing!')

skip npm

šŸš€ Feature Proposal

A parameter to skip npm phase.
The bump of the version will be skipped as well

Motivation

if i have a published module, I need to skip npm but i need to create the GH release

Example

releasify publish --skip-npm --from-commit xxx --to-commit yyy

Deprecation warnings

{ Deprecation: [@octokit/rest] "number" parameter is deprecated for "GET /repos/:owner/:repo/issues/:issue_number/labels", use "issue_number" instead
    at Object.keys.forEach.parameterName (/Users/matteo/.nvm/versions/node/v10.15.2/lib/node_modules/@fastify/releasify/node_modules/@octokit/rest/plugins/validate/validate.js:34:22)
    at Array.forEach (<anonymous>)
    at validate (/Users/matteo/.nvm/versions/node/v10.15.2/lib/node_modules/@fastify/releasify/node_modules/@octokit/rest/plugins/validate/validate.js:17:23)
    at process._tickCallback (internal/process/next_tick.js:68:7) name: 'Deprecation' }
{ Deprecation: [@octokit/rest] "number" parameter is deprecated for "GET /repos/:owner/:repo/issues/:issue_number/labels", use "issue_number" instead
    at Object.keys.forEach.parameterName (/Users/matteo/.nvm/versions/node/v10.15.2/lib/node_modules/@fastify/releasify/node_modules/@octokit/rest/plugins/validate/validate.js:34:22)
    at Array.forEach (<anonymous>)
    at validate (/Users/matteo/.nvm/versions/node/v10.15.2/lib/node_modules/@fastify/releasify/node_modules/@octokit/rest/plugins/validate/validate.js:17:23)
    at process._tickCallback (internal/process/next_tick.js:68:7) name: 'Deprecation' }

releasify says that it couldn't create the github release but it did

šŸ› Bug Report

As per subject

To Reproduce

releasify publish

generates error:

   Error: Something went wrong creating the relase on GitHub.
    The 'npm publish' and 'git push' has been done!
    Consider creating a release on GitHub by yourself with this message:

but the github release was created

Expected behavior

No error message printed

Your Environment

  • node version: 14
  • os: Windows

Use Github Auto-Generated Release Notes

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

šŸš€ Feature Proposal

Instead of self modify one or using the old format.
Github provide it's well-formatted and pretty release notes.

We can enable to use the release notes with a single option generate_release_notes.
https://docs.github.com/en/rest/releases/releases#create-a-release

The idea is pretty simple. If the user do not pass --gh-release-edit | -e for a custom one.
We use the auto-generate one.

Motivation

No response

Example

No response

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.