node.jsgithub-actionsmonorepogithub-release

release-please github action with release-please manifest driven release


I was looking for a way to create a github release, tag, generate changelog & a npm publish, I came across semantic release, release-please, release-please-action, manifest driven release-please. I have a monorepo the structure looks like below:

root
├── packages
│   ├── hello-world-util
│   └── my-package-2
└── starters
    └── nestjs-startup-app

my-package-1 is referenced in my-app-1 there could be many more references going forward. Now since I am using a monorepo, I have a single package-lock.json at root level and all the node_modules installed at root level and each project with it's own package.json file. I have a release-please-config.json, a .release-please-manifest.json and within workflow I have a github release-please-action. I am assuming that when the github action runs it will not only update the packge.json file but also the dependencies package.json in another projects, the root package-lock.json, I have npm publish at the completion of release. The release-please-config.json looks like below:

{
    "include-component-in-tag": true,
    "include-v-in-tag": true,
    "tag-separator": "@",
    "separate-pull-requests": true,
    "packages":{
        "packages/hello-world-util": {                       
            "release-type": "node",            
            "always-link-local": true,
            "changelog-path": "CHANGELOG.md",
            "path": "packages/hello-world-util",
            "versioning-strategy": "auto",
            "intial-version": "0.0.1",
            "plugins":[
                {
                    "type": "node-workspace",
                    "updateAllPackages": true,
                    "updatePeerDependencies": true,
                    "considerAllArtifacts": true
                }
            ]
        },
       "starters/nestjs-startup-app": {
            "always-link-local": true,
            "path": "starters/nestjs-startup-app",
            "skip-github-release": true,
            "plugins":[
                {
                    "type": "node-workspace",
                    "updateAllPackages": true,
                    "updatePeerDependencies": true,
                    "considerAllArtifacts": true
                }
            ]
       }
    },
    "plugins": ["linked-versions"],
    "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
  }

The release-please-manifest.json with versions:

{
    ".": "0.0.1",
    "packages/hello-world-util": "0.0.1"
}

A minimal code describing the step in workflow to release github notes, changelogs

jobs:
    release-please:
      runs-on: ubuntu-latest
      steps:
        - uses: googleapis/release-please-action@v4
          id: release
          with:
            release-type: node
            config-file: release-please-config.json
            manifest-file: .release-please-manifest.json
            path: | 
                packages/hello-world-util

It creates a pr with changelog, updates package.json both within pacakage/hello-world directory, I was also looking after if it can also update the package.json within nestjs-startup-app and the root package-lock.json so when the npm publish is executed the build shouldn't fail due to changed dependencies after the merging the pr creation. Can someone guide if this is possible with some configurations using Manifest Driven release based approach.


Solution

  • Ok, I think config-file: release-please-config.json, manifest-file: .release-please-manifest.json in workflow are required to mention when it is created with a different name, by default it will look for both the config files by this default names which are release-please-config.json, .release-please-manifest.json in the root folder I assume it will not work if the same name is given for a created config file. I also removed path so, I don't have any more options now in the workflow, I also updated the config(config-file: release-please-config.json) to be as below

    {
        "include-v-in-tag": true,
        "tag-separator": "@",
        "always-link-local": true,
        "packages":{
            "packages/hello-world-util": {  
                "component": "hello-world-util",                     
                "release-type": "node",            
                "changelog-path": "CHANGELOG.md"
            },
            "starters/nestjs-startup-app": {
                "component": "nestjs-startup-app",
                "release-type": "node",
                "changelog-path": "CHANGELOG.md"
            }
        },
        "plugins":[
            {
                "type": "node-workspace",
                "updateAllPackages": true,
                "updatePeerDependencies": true
            },
            {
                "type": "linked-versions",
                "groupName": "linked-group",
                "components": ["hello-world-util", "nestjs-startup-app"]
            }
        ],
        "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
      }
    

    The combination of the above resulted in updating 5 files namely

    1. Bumping actual package's package.json(in this case hello-world-util).
    2. Creation of CHANGELOG for actual package.
    3. Bumping dependencies package.json (in this case nestjst-startup-app).
    4. Creation of CHANGELOG for dependent project.
    5. Finally bumping the newer version in the package-lock.json at root level.

    Hope, this may help someone.