{"id":13527541,"url":"https://github.com/zendesk/node-publisher","last_synced_at":"2025-08-14T04:32:10.201Z","repository":{"id":33750834,"uuid":"137479825","full_name":"zendesk/node-publisher","owner":"zendesk","description":"A zero-configuration release automation tool for Node packages inspired by create-react-app and Travis CI.","archived":false,"fork":false,"pushed_at":"2024-06-13T10:51:42.000Z","size":571,"stargazers_count":76,"open_issues_count":9,"forks_count":2,"subscribers_count":273,"default_branch":"master","last_synced_at":"2024-12-11T12:46:33.040Z","etag":null,"topics":["cli","cli-app","hooks","lerna","node","npm","release-management","yarn","zero-configuration"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zendesk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-15T11:28:51.000Z","updated_at":"2024-11-30T05:49:15.000Z","dependencies_parsed_at":"2024-06-19T16:02:47.301Z","dependency_job_id":"24f0e1db-727e-447a-9922-71d36dd2f46c","html_url":"https://github.com/zendesk/node-publisher","commit_stats":{"total_commits":121,"total_committers":4,"mean_commits":30.25,"dds":"0.12396694214876036","last_synced_commit":"f06d6612e0a3fc350ba06b9925c42852e92c32c8"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fnode-publisher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fnode-publisher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fnode-publisher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fnode-publisher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zendesk","download_url":"https://codeload.github.com/zendesk/node-publisher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229800424,"owners_count":18126028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cli-app","hooks","lerna","node","npm","release-management","yarn","zero-configuration"],"created_at":"2024-08-01T06:01:50.702Z","updated_at":"2024-12-15T09:05:27.123Z","avatar_url":"https://github.com/zendesk.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/zendesk/node-publisher\"\u003e\n    \u003cimg\n      alt=\"Node Publisher by Zendesk\"\n      src=\"https://github.com/zendesk/node-publisher/raw/master/assets/logo.png\"\n      width=\"500\"\n    /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nThis is a configurable release automation tool for node packages inspired by [create-react-app](https://github.com/facebook/create-react-app) and [Travis CI](https://travis-ci.org/). It has a default configuration, which can be overriden in case of need. As a convention, this release tool defines a set of hooks that represent the release lifecycle. The default configuration can be overriden by redefining what commands should run under which hook in a `.release.yml` file. The hooks are listed under the [Lifecycle](#lifecycle) section.\n\n[![NPM version](https://badge.fury.io/js/node-publisher.svg)](https://badge.fury.io/js/node-publisher)\n![repo-checks](https://github.com/zendesk/node-publisher/workflows/repo-checks/badge.svg)\n\n# Getting started\n## 1. Install the package:\n\n```sh\nnpm install node-publisher --save-dev\n```\n\nor\n\n```sh\nyarn add --dev node-publisher\n```\n\n## 2. Setup\n\nRun the setup script:\n\n```sh\nnpx node-publisher setup\n```\n\nThe script searches for unmet requirements in your package and attempts to address them. In general, it performs the following actions:\n\n- Checks whether the package root is a git directory.\n- Generates a release script in you `package.json` with a release branch of your choice.\n- Generates a `.nvmrc` file if missing.\n- Checks whether a `build` script is defined in `package.json`.\n- Checks whether a CI script is defined in `package.json`.\n\nFor more info, read the [Prerequisites section](#prerequisites).\n\n# Usage\n\n```sh\nnpm run release -- \u003cversion\u003e\n```\n\nor \n\n```sh\nyarn release \u003cversion\u003e\n```\n\nSince `v1.2.0`, node-publisher supports the version options supported by the detected npm client. In earlier versions, only `major`, `minor` and `patch` options were accepted. When using `yarn`, the pre-release identifier (`--preid`) is ignored.\n\n```sh\nnpm run release -- \u003cversion\u003e --preid alpha\n```\n\n# Customize the release process\n\n```sh\nnpx node-publisher eject\n```\n\nAfter ejecting, a `.release.yml` file will appear in the root directory of your package. You can override the default behaviour by modifying this file.\n\n## Custom branch\nUsing the `--branch` release param, it is possible to specify which branch should be checked out during the `prepare` [lifecycle](#lifecycle) step. When no `branch` is specified, the `master` branch will be checked out by default.\n\n## Multiple configuration files\n\nUsing the `--config` release param, it is possible to specify which file to load the release steps from. This way, one can have different release procedures for different purposes.\n\nExample:\n\n```js\n// package.json\n\n{\n  \"scripts\": {\n    \"release\": \"node-publisher release\",\n    \"pre-release\": \"node-publisher release --config path/to/.pre-release.yml\"\n  }\n}\n```\n\n# Prerequisites\n\nThe default release process assumes the following:\n\n- The master branch is called `master`.\n- A `.nvmrc` file is present in the root of your package. In case it is missing, the release fails in its preparation phase.\n- The tool expects the Node version to match the one in `.nvmrc` during the release process. If the expectation is not met, the release fails in its preparation phase.\n- The tool expects the build generation script to be called `build`. Otherwise, the build step is skipped.\n- The tool expects the test triggering script to be called `travis` or `ci`. The reason is that many times the standard `test` scripts are implemented to watch the files for changes to re-trigger the tests. This tool relies on the test script to return eventually, hence the choice of the commonly used CI-friendly script names. The list of accepted script names may be extended in the future. If both `travis` and `ci` scripts are present, `travis` will be preferred.\n\n*Notice:* the test triggering script (`travis` or `ci`) has to return a value, eventually. Otherwise, the release would stall and not run correctly. Interrupting a stalling release process would also interrupt the `rollback` feature's execution.\n\n# Lifecycle\n\n1. `prepare`: The process that prepares the workspace for releasing a new version of your package. It might checkout to master, check whether the working tree is clean, check the current node version, etc. Between this step and `test`, a rollback point is created for your git repo.\n\n2. `test`: Runs the tests and/or linting. You might want to configure the tool to run the same command as your CI tool does.\n\n3. `build`: Runs your build process. By default it runs either `yarn build` or `npm run build` depending on your npm client. This step is only run if `build` is defined unders `sripts` in your `package.json` file.\n\n4. `publish`: Publishes a new version of your package. By default, the tool detects your npm/publishing client and calls the publish command. Currently supported clients are: `npm`, `yarn`, `lerna`.\n\n5. `after_publish`: Runs the declared commands immediately after publishing. By default, it pushes the changes to the remote along with the tags. In case the publishing fails, this hook will not execute.\n\n6. `after_failure`: Runs the specified commands in case the release process failed at any point. Before running the configured commands, a rollback to the state after `prepare` might happen - in case the `rollback` option is set to `true` which is the default behaviour.\n\n7. `changelog`: In case the package was successfully published, a changelog will be generated. This tool uses the [offline-github-changelog](https://github.com/sunesimonsen/offline-github-changelog) package for this purpuse.\n\n8. `after_success`: Runs the specified commands after generating the changelog, in case the release process was successful. It might be used to clean up any byproduct of the previous hooks.\n\n## Configuration\n\nThe lifecycle hooks can be redefined in the form of a configurable YAML file. Additionally to the hooks, the configuration also accepts the following options:\n\n* `rollback [Boolean]` - rolls back to the latest commit fetched after the `prepare` step. The rollback itself happens in the `after_failure` step and only if this flag is set to `true`.\n\n## Default configuration\nThe exact configuration depends on the npm client being used and the contents of your `package.json` file. In case you use yarn, the default configuration will look like this:\n\n```yaml\nrollback: true\n\nprepare:\n  - git diff-index --quiet HEAD --\n  - git checkout master\n  - git pull --rebase\n  - '[[ -f .nvmrc ]] \u0026\u0026 ./node_modules/.bin/check-node-version --node $(cat .nvmrc)'\n  - yarn install\n\ntest:\n  - yarn travis\n\nbuild: # only if \"build\" is defined as a script in your `package.json`\n  - yarn build\n  - git diff --staged --quiet || git commit -am \"Update build file\"\n\nafter_publish:\n  - git push --follow-tags origin master:master\n\nchangelog:\n  - ./node_modules/.bin/offline-github-changelog \u003e CHANGELOG.md\n  - git add CHANGELOG.md\n  - git commit --allow-empty -m \"Update changelog\"\n  - git push origin master:master\n```\n\n# Supported publishing clients\n\n`node-publisher` supports the main npm clients and Lerna as an underlying publishing tool. It automatically detects them based on the different `lock files` or `config files` they produce or require. If multiple of these files are detected, the following precedence will take place regarding the publishing tool to be used:\n\n`lerna` \u003e `yarn` \u003e `npm`\n\n# Development\n\n## Install packages\n```sh\nyarn\n```\n\n## Release a new version\n```sh\nyarn release \u003cversion\u003e\n```\n\n# Contributing\n\nContributing to `node-publisher` is fairly easy, as long as the following steps are followed:\n\n1. Fork the project\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n6. Mention one or more of the maintainers to get the Pull Request approved and merged\n\n## Maintainers\n- Attila Večerek ([@vecerek](https://github.com/vecerek/))\n- Sune Simonsen ([@sunesimonsen](https://github.com/sunesimonsen/))\n\n# Copyright and License\nCopyright (c) 2018 Zendesk Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License.\n\nYou may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fnode-publisher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzendesk%2Fnode-publisher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fnode-publisher/lists"}