Coder Social home page Coder Social logo

semantic-release-monorepo-hooks's Introduction

semantic-release-monorepo-hooks

Workaround to handle semantic-release-monorepo multipublishing

CI npm (tag) Maintainability Test Coverage

Migration proposal

This project provided invaluable experience in understanding how lerna and semantic-release work. Along with this came the realization that the approach needed to be changed. Here's the short note on the evolution of these ideas. Thus, today we suggest using multi-semantic-release as the best alternative:

  • Much more robust and predictable.
  • Maintainable and maintained.
  • Compatible with the latest versions of semrel and its plugins.
  • Supports parallel release flow (faster).
  • Brings an automatic update of cross-packages dependencies.
  • Project is used and supported as part of QIWI in-house development infrastructure (not sure if this is a positive point :-).

Further development of this project seems futile. Anyway, we will regularly apply vulnerability patches for as long as possible. Thank you all for your feedback, PRs, downloads and stars.

Problem

  1. semantic-release does not support lerna-based repos aka monorepos out of box.
  2. semantic-release-monorepo can not release several packages at once: after the first sub-release it appends a new git version tag, so any next run finds no changes.
[Semantic release]: Found 0 commits for package *** since last release

Install

  npm i -D semantic-release
  npm i -D semantic-release-monorepo
  npm i -D semantic-release-monorepo-hooks

and plugins:

{
  "devDependencies": {
    "@semantic-release/changelog": "^3.0.1",
    "@semantic-release/commit-analyzer": "^6.1.0",
    "@semantic-release/git": "7.0.5",
    "@semantic-release/github": "5.2.1",
    "@semantic-release/npm": "5.0.5",
    "@semantic-release/release-notes-generator": "7.1.2",
    "lerna": "^3.4.3",
    "semantic-release": "15.10.6",
    "semantic-release-monorepo": "6.1.1",
    "semantic-release-monorepo-hooks": "2.6.2",
    "semantic-release-plugin-decorators": "^2.0.0"
  }
}

Configure

1. Configure .releaserc.js
  const hooks = require('semantic-release-monorepo-hooks')
  const output = hooks()
  
  module.exports = {
    branch: 'master',
    tagFormat: 'v${version}',
    prepare: [
      '@semantic-release/changelog',
      '@semantic-release/npm',
      {
        'path': '@semantic-release/git',
        'message': 'chore(' + output.package + '): release ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
      }
    ],
    publish: [
      '@semantic-release/npm'
    ],
    verifyConditions: [
      '@semantic-release/npm',
      '@semantic-release/git'
    ],
    monorepo: {
      analyzeCommits: [
        '@semantic-release/commit-analyzer'
      ],
      generateNotes: [
        '@semantic-release/release-notes-generator'
      ]
    }
  };
2. Configure .travis.yml
deploy:
  provider: script
  skip_cleanup: true
  script:
    - yarn lerna exec --concurrency 1 "npx --no-install semantic-release -e semantic-release-monorepo" && node -e "require('semantic-release-monorepo-hooks').hookAfterAll()"
3. Configure env vars

GH_TOKEN and GH_USER must be declared for git push. See drop_last_tag.sh for details.

hooks()

Hooks reverts some effects of previous semantic-release run and returns info map as a result:

  {
    isModified: true,
    isLastModified: false,
    isLastRun: false,
    total: 5,
    processed: 1,
    modified: 2,
    modifiedPacks: [ '@qiwi/pijma-core', '@qiwi/pijma-desktop' ],
    package: '@qiwi/pijma-core',
    tag: 'v1.5.0\n',
    run: 1
  }

Alternatives

Take a look at multi-semantic-release. With --execasync flag it produces the same effect but in a different way.

License

MIT

semantic-release-monorepo-hooks's People

Contributors

antongolub avatar meatwallace avatar qiwibot avatar renovate-bot avatar renovate[bot] avatar yinzara 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

semantic-release-monorepo-hooks's Issues

TypeError: hooks is not a function, and tags are committed before all packages are parsed

I've set up my repo following the instructions, and matching the @qiwi/substrate repo as closely as possible - but I can't seem to get this to work.

At the end of each log in Travis, I see:

[release-hooks]: err= TypeError: hooks is not a function
    at Object.<anonymous> (/home/travis/build/good-idea/sane-shopify/.releaserc.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    ...etc

I have been able to publish a single package, but it is unable to authenticate with Github for later packages. Here is an example of a build that included a single fix commit, in one of the packages, then is unable to authenticate.

Here is the next build, which included multiple fix commits. (But, I pushed these commits before the previous build had made it's chore(release) commit back to the repo - so, semantic release said The local branch master is behind the remote one, therefore a new version won't be published.). Maybe not too relevant --- but you'll see at the end that hooks is not a function

Here is the next build. This included fix commits for the server, sanity-plugin, and sync-utils packages -- but, it found a change in types from the previous tag, and deployed that instead.

Finally, this build was run after adding GH_USER to the environment variables -- which then breaks here.

I'm not sure about the hooks is not a function problem, but, as far as the other issues go - I'm guessing that one problem is that the tags are being added to the repo before the rest of the packages have been figured out by semantic-release. I guess I'm a little lost overall - - am I missing something obvious?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yaml
  • actions/checkout v4
  • mstachniuk/ci-skip v1
  • actions/checkout v4
  • actions/setup-node v4
  • actions/upload-artifact v3
  • actions/checkout v4
  • actions/setup-node v4
  • paambaati/codeclimate-action v5.0.0
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
  • actions/download-artifact v3
  • ubuntu 22.04
  • ubuntu 22.04
  • ubuntu 22.04
  • ubuntu 22.04
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
npm
package.json
  • @antongolub/git-root ^1.5.7
  • lodash ^4.17.21
  • semver ^7.3.7
  • cosmiconfig ^8.0.0
  • read-pkg ^5.2.0
  • coveralls ^3.1.1
  • jest ^29.0.0
  • mock-fs ^5.1.2
  • standard ^17.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

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.