<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">"use strict";(self.webpackChunk_my_org_docs=self.webpackChunk_my_org_docs||[]).push([[780],{876:(e,t,n)=&gt;{n.d(t,{Zo:()=&gt;c,kt:()=&gt;d});var a=n(2784);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&amp;&amp;(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t&lt;arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,a,o=function(e,t){if(null==e)return{};var n,a,o={},r=Object.keys(e);for(a=0;a&lt;r.length;a++)n=r[a],t.indexOf(n)&gt;=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a&lt;r.length;a++)n=r[a],t.indexOf(n)&gt;=0||Object.prototype.propertyIsEnumerable.call(e,n)&amp;&amp;(o[n]=e[n])}return o}var s=a.createContext({}),p=function(e){var t=a.useContext(s),n=t;return e&amp;&amp;(n="function"==typeof e?e(t):i(i({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(s.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,s=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),m=p(n),d=o,h=m["".concat(s,".").concat(d)]||m[d]||u[d]||r;return n?a.createElement(h,i(i({ref:t},c),{},{components:n})):a.createElement(h,i({ref:t},c))}));function d(e,t){var n=arguments,o=t&amp;&amp;t.mdxType;if("string"==typeof e||o){var r=n.length,i=new Array(r);i[0]=m;var l={};for(var s in t)hasOwnProperty.call(t,s)&amp;&amp;(l[s]=t[s]);l.originalType=e,l.mdxType="string"==typeof e?e:o,i[1]=l;for(var p=2;p&lt;r;p++)i[p]=n[p];return a.createElement.apply(null,i)}return a.createElement.apply(null,n)}m.displayName="MDXCreateElement"},4347:(e,t,n)=&gt;{n.r(t),n.d(t,{assets:()=&gt;s,contentTitle:()=&gt;i,default:()=&gt;u,frontMatter:()=&gt;r,metadata:()=&gt;l,toc:()=&gt;p});var a=n(7896),o=(n(2784),n(876));const r={},i="Publishing libraries to NPM",l={unversionedId:"product-template/npm-publish",id:"product-template/npm-publish",title:"Publishing libraries to NPM",description:"Publish flow is built on changesets.",source:"@site/docs/product-template/npm-publish.mdx",sourceDirName:"product-template",slug:"/product-template/npm-publish",permalink:"/docs/product-template/npm-publish",draft:!1,editUrl:"https://github.com/secundant/product-template/tree/main/apps/docs/docs/product-template/npm-publish.mdx",tags:[],version:"current",frontMatter:{},sidebar:"libraries",previous:{title:"Monorepo",permalink:"/docs/product-template/monorepo"},next:{title:"Deploy docs app",permalink:"/docs/product-template/how-to-deploy"}},s={},p=[{value:"Setup",id:"setup",level:2},{value:"Workflow",id:"workflow",level:2},{value:"Recipes",id:"recipes",level:2},{value:"Pin version",id:"pin-version",level:3},{value:"Prevent publication",id:"prevent-publication",level:3}],c={toc:p};function u(e){let{components:t,...n}=e;return(0,o.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"publishing-libraries-to-npm"},"Publishing libraries to NPM"),(0,o.kt)("p",null,"Publish flow is built on ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/changesets/changesets"},"changesets"),"."),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Template includes GitHub Actions workflow for automated publishing."),(0,o.kt)("p",{parentName:"admonition"},"You may install ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/apps/changeset-bot"},"Changeset Bot")," to improve your experience")),(0,o.kt)("p",null,"Changesets can work correctly with a monorepository\nand provide full control over the publication of packages,\nthanks to atomic manual specification of each change you want to describe."),(0,o.kt)("p",null,"Probably, it's looks some verbose compared to automatic changelogs, but in practice\nit's much more useful to have control and be able to fix anything before it's published."),(0,o.kt)("p",null,"So, changesets already installed and preconfigured a bit:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Actual changesets configuration placed in\n",(0,o.kt)("a",{parentName:"li",href:"https://github.com/secundant/product-template/tree/main/.changeset/config.json"},".changeset/config.json"),",\nyou can see config details in ",(0,o.kt)("a",{parentName:"li",href:"https://github.com/changesets/changesets/blob/main/docs/config-file-options.md"},"changesets documentation")),(0,o.kt)("li",{parentName:"ul"},"GitHub Action in ",(0,o.kt)("a",{parentName:"li",href:"https://github.com/secundant/product-template/tree/main/.github/workflows/release.yaml"},".github/workflows/release.yaml")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"release-version")," and ",(0,o.kt)("inlineCode",{parentName:"li"},"release-publish")," scripts in root ",(0,o.kt)("a",{parentName:"li",href:"https://github.com/secundant/product-template/tree/main/package.json"},"package.json"),",\nit used inside GitHub Action, you can cut and inline it there if you want")),(0,o.kt)("h2",{id:"setup"},"Setup"),(0,o.kt)("ol",null,(0,o.kt)("li",{parentName:"ol"},(0,o.kt)("p",{parentName:"li"},"Install ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/apps/changeset-bot"},"changeset bot")," into your repository")),(0,o.kt)("li",{parentName:"ol"},(0,o.kt)("p",{parentName:"li"},"Add ",(0,o.kt)("inlineCode",{parentName:"p"},"NPM_TOKEN")," secret (",(0,o.kt)("a",{parentName:"p",href:"https://docs.npmjs.com/creating-and-viewing-access-tokens"},"npm access token"),") to\n",(0,o.kt)("a",{parentName:"p",href:"https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-an-organization"},"GitHub Secrets"),"."),(0,o.kt)("p",{parentName:"li"},"You can see more in ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/changesets/action"},"changeset action documentation")))),(0,o.kt)("h2",{id:"workflow"},"Workflow"),(0,o.kt)("p",null,"Really very simple:"),(0,o.kt)("ol",null,(0,o.kt)("li",{parentName:"ol"},"Add changesets"),(0,o.kt)("li",{parentName:"ol"},"Create and merge PR"),(0,o.kt)("li",{parentName:"ol"},'Technical "Version bump" PR will be automatically created,\nit will contain deletions of all changesets and updates of versions and changelogs'),(0,o.kt)("li",{parentName:"ol"},"Merge it technical PR"),(0,o.kt)("li",{parentName:"ol"},"Changed packages will be automatically published")),(0,o.kt)("p",null,"You can add changesets anytime and in any quantity,\n",(0,o.kt)("a",{parentName:"p",href:"https://github.com/changesets/changesets"},"changesets")," will save them all until packages will be published"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title="Add changeset - select packages (one/some), define bumps, add message"',title:'"Add',changeset:!0,"-":!0,select:!0,packages:!0,"(one/some),":!0,define:!0,"bumps,":!0,add:!0,'message"':!0},"yarn changeset\n")),(0,o.kt)("h2",{id:"recipes"},"Recipes"),(0,o.kt)("h3",{id:"pin-version"},"Pin version"),(0,o.kt)("admonition",{title:"WIP",type:"note"},(0,o.kt)("p",{parentName:"admonition"},"If you want sync packages version")),(0,o.kt)("h3",{id:"prevent-publication"},"Prevent publication"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-json",metastring:'title=".changeset/config.json"',title:'".changeset/config.json"'},'{\n  "ignore": ["@my-org/foo"]\n}\n')))}u.isMDXComponent=!0}}]);</pre></body></html>