Setup CI/CD for typescript based npm package publishing

Samayun Miah Chowdhury
2 min readOct 7, 2022

--

Hi Coder .
I’m Samayun Chowdhury .
I am a learner & love explore new things. I am building some open source npm package…

I have to setup many individual repositories for separated packages. (monorepo would be a sexy solutions I know but my purpose is different )

I think re-setup each packages’s scripting, linting, testing, publishing to npm registry is so boring & time greedy.

To respect myself as a lazy developer. I like to write code using intellisense & push to code repository.

I don’t like to update version on package.json , tag this version then login to npm, re-type OTP verification code after chacking email, then write another command npm publish then you have successfully upgraded a version.

When you are fixing bugs & implementing features continously . Isn’t it so boring manually versioning and publish to npm registry?

I think so . I took decision to automate this setup for forever.

" When you see something that is needed you either find it or you create it "

- JOHN SONMEZ

(Author of `Soft Skills: The Software Developer's Life Manual`)

I found it so I’m implementing it and sharing with you. Sharing is caring :)
I followed this video content : YouTube Content .

I am still writing this article because of frustration . A whole night I was nightmare for me.

CI wasn’t working properly for some silly mistakes.

If you follow this video tutorial and your CI/CD pipeline working properly . that’s fine you can skip this article from here.

Otherwise if you like articles before video content or pipeline doesn’t work properly then please continue exploring from here.

Step by Step:
* Bootstrap using TSDX
* Environment Setup for CI/CD
* Semantic Versioning
* Setup GitHub Actions

Bootstrap using TSDX

npx tsdx create my-package

Environment Setup for CI

Setup secrets first GH_TOKEN is a PAT token of GitHub . It will be used for release tag versions via CI . and NPM_TOKEN is for NPM registry package publish/write access .

Setup Semantic Versioning

Setup GitHub Actions

.github/workflow/publish.yml

--

--

Samayun Miah Chowdhury
Samayun Miah Chowdhury

Written by Samayun Miah Chowdhury

Fan of JavaScript & Python lover Feels good to introduced as a realtime web application developer sunglasses PWA is my crushwink I do 2 times teeth brush

No responses yet