Gatsby-theme-novela: Continuous Deployment

Created on 30 Aug 2019  路  14Comments  路  Source: narative/gatsby-theme-novela

If you want to try setting up or playing with CD yourself here are my notes.

Lerna - A tool for managing JavaScript projects with multiple packages

yarn add lerna --dev -W
yarn lerna init     => updates package.json , creates ./packages/ and lerna.json

Now remove directory ./packages/

Then update lerna.json so it looks like:

{
  "workspaces": [
    "www/*",
    "@narative/gatsby-theme-novela"
  ],
  "version": "0.4.6" // or whatever the current version is, it needs to match
}

Try running it locally to get an impression, there is a y/n choice where you can prevent the publishing.

yarn lerna publish patch --loglevel debug

You'll see it wil update package.json for all workspaces but will not publish www because it is private.

Most helpful comment

Lerna Config: https://github.com/OHIF/Viewers/blob/master/lerna.json#L6-L18
CI for NPM Publish: https://github.com/OHIF/Viewers/blob/master/.circleci/config.yml#L154-L171

conventionalCommits to use conventional commit syntax to bump version numbers, scoped to package, to indicate how versions should change when you run lerna version

Lerna has each command documented. Here is version: https://github.com/lerna/lerna/tree/master/commands/version

All 14 comments

Out of curiosity @bravo-kernel, do you think GitHub Actions could be helpful for this?

@jpvalery ofcourse, any ci/cd platform will do. CI/CD is basically nothing more than automating commands. FYI the consensus was to start with Travis because Github Actions was not available then. More details here https://github.com/narative/gatsby-theme-novela/pull/91. However, since I cannot use this theme for my corporate website (due to enforced post images) I will not spend any more time on this so feel free to pick this up if you like. Implementing CD will speed up the release cycle 10x (at least, based on my experience).

@bravo-kernel Why not fork it and then change it so that you can have posts without hero images?

If you fork it you will have more control and then just release it on npm

@mabasic that would be an option but would also defeat the whole idea behind themes and the updates/shadowing benefits that come with it (especially as I am no theme expert where you/narative most definitely are).

To prevent misunderstandings... this not intended as a negative in any way, you folks are doing an most excellent job here. It's just that this feature is a must for my intended blog implementation so I will just wait for something to come by. 馃挴

I've read a bit about Lerna and it seems indeed pretty easy.

Although it will require commits message to follow https://www.conventionalcommits.org/en/v1.0.0-beta.4/#summary to work really well and automatically generate the correct version number and changelogs.

That being said, I discovered that they have plugins to help with that such as https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/travis-cli.

I'll start tinkering with that - sounds a bit scary and beyond my skills, but who knows!

There is no need for a/that plugin if you follow conventional commits as that will automatically generate the release notes. To get comfortable just checkout a novela-theme brach and run the above, it will push to your branch. Nothing can break.

Yeah but seen that most of the commits haven't followed that convention I felt that adding commitlint would help prevent errors. I've added it in a branch and works well so far.

Right now I'm trying to see if lerna is the best way to go or if semantic-release would be a more automated solution.
The only issue with semantic-release is that they currently don't support monorepo or workspaces (see https://github.com/semantic-release/semantic-release/issues/193); trying to figure out if this is an issue here or not.

I'm betting a bottle of 馃嵎 that lerna is the way to go. Automated releases do require onboarding commit messages. Furthermore, semantic-release is way less friendly on the versioning, check their issues.

But isn't the goal of CD to have automated releases?

(Thanks a lot for chipping in! Learning a ton today 馃 )

Lerna IS the automated release tool ;)

The only issue with semantic-release is that they currently don't support monorepo or workspaces (see semantic-release/semantic-release#193); trying to figure out if this is an issue here or not.

FWIW, we recently switched from many repositories to a monorepo. Having used semantic-release for the individual repository's we looked to leveraging it for the monorepo as well, but ran into a ton of issues.

After a while, we begrudgingly gave yarn workspaces + lerna a try, and it's been smooth sailing since.

@bravo-kernel That's not what I understood from their documentation- but maybe something is escaping me 馃槙

@dannyrb thanks for sharing! ~I can't seem to find any doc to automate the release on npm and github - how did you manage that?~ 馃う鈥嶁檪 think I found my answer to my stupid question 馃槆

Lerna Config: https://github.com/OHIF/Viewers/blob/master/lerna.json#L6-L18
CI for NPM Publish: https://github.com/OHIF/Viewers/blob/master/.circleci/config.yml#L154-L171

conventionalCommits to use conventional commit syntax to bump version numbers, scoped to package, to indicate how versions should change when you run lerna version

Lerna has each command documented. Here is version: https://github.com/lerna/lerna/tree/master/commands/version

Thanks both of you for sharing and helping! I've opened #124, feel free to comment/review it :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SabariVig picture SabariVig  路  4Comments

mabasic picture mabasic  路  4Comments

brotzky picture brotzky  路  4Comments

zactony picture zactony  路  3Comments

mabasic picture mabasic  路  4Comments