Coder Social home page Coder Social logo

meatwallace / yarks Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 0.0 41.78 MB

CLI that automates the process of releasing NPM packages using Yarn v2

License: Other

JavaScript 99.34% TypeScript 0.66%
yarn berry workspaces npm-publish semantic-versioning changelog-generator

yarks's Introduction

๐Ÿ“ฆ yarks

automated package version management and publishing workflow for Yarn v2 (Berry) projects

yarks aims to fill the gap left by semantic-release when using Yarn v2 (Berry), automating a "common" package release workflow that is compatible with both single package repositories and monorepos that are powered by Yarn's workspaces.

โšก Quick Start

To quickly see how yarks would release your current project:

yarn dlx @yarks/cli release-workspaces

For ongoing usage, it's recommended you add yarks to your dependencies and run it from there:

yarn add @yarks/cli --dev
yarn release-workspaces

When releasing, yarks expects the following environment variables to be set:

export NPM_TOKEN="your NPM token for publishing"
export GITHUB_TOKEN="your GitHub token with push access to your project's repo"
export GIT_AUTHOR_NAME="the name used to author the release commits"
export GIT_AUTHOR_EMAIL="the email used to author the release commits"

By default, yarks will only release packages when ran inside a CI environment. To release locally, this behaviour can be mimiced by setting your CI environment variable to true:

export CI=true
yarn release-workspaces

โ“ Why yarks?

yarks automates your release workflow:

  • Processes your commits using conventional-changelog
  • Writes release notes to your workspaces' CHANGELOG.md
  • Bumps your workspaces' versions following the semantic versioning specification
  • Publishes your workspace package updates to the NPM registry
  • Commits your new version and pushes it back to your git repository

๐Ÿค” Why not semantic-release?

While semantic-release can be used with any package manager in any repository configuration, there are caveats when used in conjunction with Yarn workspaces that require brittle hacks and workarounds, all of which are incompatible with Yarn v2. yarks is specifically built to address these caveats and offer a robust solution that treats Yarn v2 & workspaces as first-class citizens.

๐Ÿ”ฌ What problems does yarks solve?

When working in a monorepo, a reliable release strategy requires centralized coordination to ensure workspaces that depend on sibling workspaces are queued for release as needed, and all workspaces are evaluated before final versions are applied and the release process begins.

If workspaces are simply processed and released sequentially, workspaces that depend on sibling workspaces may not be released when they should be, or if they are released, may depend on the incorrect versions of sibling workspaces, potentially introducing errors that would likely be missed by your tests.

๐Ÿ’Ž What makes yarks different?

Rather than shoehorning Yarn workspaces into another semantic-release-based workaround, yarks addresses the aforementioned issues, avoids any form of brittle integration and uses it's own release strategy, and interfaces with Yarn itself. The initial goal is to create a reliable tool that's been designed with intention and tailored to the problem, rather providing another short-term workaround.

๐Ÿ“‹ Release Strategy

The process begins by collating workspace and git metadata to determine the release strategy:

  1. Create a list of workspaces including the root of the project, allowing usage with single package repositories and workspace-based monorepos
  2. Filter out workspaces that are flagged as private
  3. For each workspace, find the latest git tag that match the pattern [email protected] that's available, if any
  4. Parse the commits that modified each workspace since the last release (or the first commit if there is no previous release) using conventional-changelog and determine what type of release is required, if any
  5. Check if each workspace's workspace dependencies have changed, and determine additional releases as required
  6. For each release required, log the release type, new version, and the relevant changes
  7. If on CI, increment workspace versions as needed

When all workspaces have been processed, if we are executing in a CI environment, release each workspace sequentially:

  1. Ammend or write a CHANGELOG.md to the workspace
  2. Publish the workspace to the package registry
  3. Commit and tag the workspace, then push the changes to your remote repository
  4. Publish a GitHub release

๐Ÿ”ญ Project Goals

Although yarks is currently a simplistic release automation tool, it's roadmap is positioned towards maturing into a lightweight and flexible Yarn workspaces task runner. At a high level, the development milestones look like:

  1. Release automation: serves as a drop in replacement for semantic-release that accounts for monorepo nuances, with 'essentials' such as changelog generation, semantic versioning, and package publishing
  2. Plugin driven: the initial release strategy is extracted to optional plugins to be used via a streamlined core API and CLI, similar to semantic-release's current architecture
  3. Generic task running: expansion of the core API, CLI, and plugins to facilitate generic task execution with access to workspace related context and convenience APIs

๐Ÿ› ๏ธ Contributing

๐Ÿ’ฌ Code of Conduct

yarks has adopted a Code of Conduct that we expect project participants to adhere to. TODO

๐Ÿ“– Contributing Guide

Read the contributing guide to learn about the development process, how to propose bug fixes and improvements, and how to build and test your changes to yarks

๐Ÿ“œ License

All yarks related packages are MIT licensed.

๐Ÿ“š Prior Art

yarks's People

Contributors

meatwallace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yarks's Issues

complete proof of concept implementation

release flow:

  • write NPM_TOKEN to yarn's configurable file for the default registry
  • handle GH_TOKEN and GH_USER authentication
  • collate workspaces & their manifests
  • filter out private workspaces
  • fetch all git tags
  • get commit log for each workspace from HEAD to
    • previous release if available
    • all commits if no previous release
  • process commits and determine
    • release type (patch/minor/major)
    • changelog
  • evaluate workspace's dependencies and if they include a changed workspace
    • queue a minor release
    • update the changelog
  • log release information

if on CI:

  • increment workspace versions as needed
  • release each workspace sequentially
    • ammend or write a CHANGELOG.md
    • publish the workspace
    • commit the workspace changes
    • tag the commit
    • push changes

usage:

  • implement simplistic CLI

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.