Skip to content

Instantly share code, notes, and snippets.

@broofa
Last active May 13, 2019 20:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save broofa/900a2eee67634ff5da02d7b921b34f0b to your computer and use it in GitHub Desktop.
Save broofa/900a2eee67634ff5da02d7b921b34f0b to your computer and use it in GitHub Desktop.
The Idiot's Guide to Managing an OpenSource Project on Github (and NPM)

The Idiot's Guide to Managing an OpenSource Project on Github (and NPM)

This doc attempts to capture some of the more nuanced tips and tricks involved in managing an NPM-based open source project, specifically with an eye toward maintaining a structured release process that limits the pain and surprises you cause your audience.

Preface

Contrary to the title, this guide is going to assume you're not an idiot. In fact, a working knowledge of git, GitHub, and NPM are assumed. Moreover, we're going to gloss over the basic steps involved in creating a project and instead focus on the less-obvious aspects of how you maintain a project. So, things this guide assumes you've done before you got here:

Changing Code

Users care about what's changed and what's changing.

As the maintainer of a project, one of your jobs is to document the changes between releases. To that end, use the Github Flow when developing. Creating branches and PRs may seem unnecessary, but it's good practice, and PRS (not commits) are the basis for documentation. In addition, you should also get in the habit of creating an Issue for any major changes you expect to make. Note only will this make your project's Issues and PR pages a useful source of information, it enables tools like github-release-notes to auto-generate changelog and release notes. (More on this below)

npm version

npm version is your friend. It takes care of 3 slightly-onerous tasks in a single, simple, command:

  1. Bump the version number in package.json
  2. Commit the change to your local repo
  3. Create an appropriately named version tag

Note: Be sure to bump your version number in accordance with Semantic Versioning rules. Failing to do this is great way to piss off your users.

git push

Use git push the commit and tag created by npm version to your GitHub repo

npm publish

Use npm publish to publish your new version to NPM.

Voila, you're done... or not.

Update changelog and release notes

Maintaining a change log and release notes is optional, but good practice. It's also a bit of a hassle. This is where an automated tool like github-release-notes can make your life easier. I'd refer you to the docs for that project, but they're a little unclear at the moment. Here's the flow I'm currently using, but I'm not sure how correct this is:

Prior to git pushing your release to GitHub:

  1. gren --action=changelog --generate --tags=all to auto-generate CHANGELOG.md
  2. git commit -am "Update CHANGELOG.md"
  3. git rebase -i HEAD~2, then reverse order of commits to have CHANGELOG update included with tag
  4. git push -f to push the rebase'd version of your repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment