trustedshops-public/circleci-orb-semantic-release

Support for monorepos

Closed this issue · 2 comments

Description

Hi, many thanks for this amazing orb!

We have however a monorepo with a dozen of Terraform modules, e.g:

.
├── app
│  └── example-stack
│     └── example-env
│        ├── ec2.tf
│        └── main.tf
├── common
│  └── vars
│     └── terraform.tfvars
├── LICENSE
├── modules
│  └── ec2
│     ├── docs
│     │  └── module.md
│     └── main.tf
└── README.md

What would be the required effort to make this orb create releases for each separate folder in modules directory? I know there's this little plugin that adds supports for monorepos, but:

  1. it looks unmaintained
  2. not sure if it's going to work with the orb

Thanks a lot in advance! :)

References

No response

Heya @oponomarov-tu,

foremost, thanks for using our orb! :)

The orb is primarily focused on providing an out-of-the-box experience for semantic-relaese, which includes common configurations like generating release notes etc. with "standard plugins". If that does not work, it can also just be the bridge between installing the required stuff and making it a bit easier to work with semantic-release. So, effectively, all plugins out there will work with it.

The big advantage of using our orb, is that you simply avoid copy&pasting between pipelines. We also maintain and automate the version pin in the orb, so you get a working combination of versions out of the box.

Having that said, I can recommend the solution below.

Hope that helps you, if you have another approach/solution/idea feel free to share and we will add it to the orb if reasonable.

Cheers,
Timo


Using @semantic-release/exec to achieve what you want

Doing a release for each folder with semantic-release in a repo is a bit tricky, and yes, the mentioned plugin didn't serve its purpose well at Trusted Shops too. Also, it’s unmaintained.
I had the best experience with using @semantic-release/exec

I would suggest creating a job like this inside your pipeline:

release-modules:
  executor: semantic-release/default
  steps:
     - checkout
     - semantic-release/with-existing-config:
         additional_packages: @semantic-release/exec@<version>

Adding a custom .releaserc.json

{
  # ... other config parts
  "plugins": [
    [
        "@semantic-release/exec", {
          "prepareCmd": "./.circleci/prepare-release.sh ${nextRelease.version}"
        }
    ]
  ]
}

You can also base the config on our solution for GitHub Tag + Release or GitHub Tag + Release, including a CHANGELOG.md getting commited

The script then generates changelogs bump versions etc. with a simple shell script, where the first argument to the script is the release version, allowing templating etc.

This way you can use the powerful capabilities of semantic-release and fill the gaps in the lifecycle with a custom script (shell, python, javascript, etc).

If you still have a problems or questions, feel free to open an issue. I will close this for now.

Have a lovely day ahead, Timo