diff --git a/dist/index.js b/dist/index.js index 269118b..c164218 100644 --- a/dist/index.js +++ b/dist/index.js @@ -997,5 +997,5 @@ module.exports=["cent","copy","divide","gt","lt","not","para","times"]; },{"unified":"EJQW","remark-parse":"+8Y3","remark-stringify":"eCnT","mdast-util-to-string":"ljHw","@actions/exec":"utFe","@actions/core":"4FTV","get-workspaces":"kAcF"}],"aric":[function(require,module,exports) { var e;exports=module.exports=f,e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},exports.SEMVER_SPEC_VERSION="2.0.0";var r=256,t=Number.MAX_SAFE_INTEGER||9007199254740991,n=16,o=exports.re=[],s=exports.src=[],i=exports.tokens={},a=0;function E(e){i[e]=a++}E("NUMERICIDENTIFIER"),s[i.NUMERICIDENTIFIER]="0|[1-9]\\d*",E("NUMERICIDENTIFIERLOOSE"),s[i.NUMERICIDENTIFIERLOOSE]="[0-9]+",E("NONNUMERICIDENTIFIER"),s[i.NONNUMERICIDENTIFIER]="\\d*[a-zA-Z-][a-zA-Z0-9-]*",E("MAINVERSION"),s[i.MAINVERSION]="("+s[i.NUMERICIDENTIFIER]+")\\.("+s[i.NUMERICIDENTIFIER]+")\\.("+s[i.NUMERICIDENTIFIER]+")",E("MAINVERSIONLOOSE"),s[i.MAINVERSIONLOOSE]="("+s[i.NUMERICIDENTIFIERLOOSE]+")\\.("+s[i.NUMERICIDENTIFIERLOOSE]+")\\.("+s[i.NUMERICIDENTIFIERLOOSE]+")",E("PRERELEASEIDENTIFIER"),s[i.PRERELEASEIDENTIFIER]="(?:"+s[i.NUMERICIDENTIFIER]+"|"+s[i.NONNUMERICIDENTIFIER]+")",E("PRERELEASEIDENTIFIERLOOSE"),s[i.PRERELEASEIDENTIFIERLOOSE]="(?:"+s[i.NUMERICIDENTIFIERLOOSE]+"|"+s[i.NONNUMERICIDENTIFIER]+")",E("PRERELEASE"),s[i.PRERELEASE]="(?:-("+s[i.PRERELEASEIDENTIFIER]+"(?:\\."+s[i.PRERELEASEIDENTIFIER]+")*))",E("PRERELEASELOOSE"),s[i.PRERELEASELOOSE]="(?:-?("+s[i.PRERELEASEIDENTIFIERLOOSE]+"(?:\\."+s[i.PRERELEASEIDENTIFIERLOOSE]+")*))",E("BUILDIDENTIFIER"),s[i.BUILDIDENTIFIER]="[0-9A-Za-z-]+",E("BUILD"),s[i.BUILD]="(?:\\+("+s[i.BUILDIDENTIFIER]+"(?:\\."+s[i.BUILDIDENTIFIER]+")*))",E("FULL"),E("FULLPLAIN"),s[i.FULLPLAIN]="v?"+s[i.MAINVERSION]+s[i.PRERELEASE]+"?"+s[i.BUILD]+"?",s[i.FULL]="^"+s[i.FULLPLAIN]+"$",E("LOOSEPLAIN"),s[i.LOOSEPLAIN]="[v=\\s]*"+s[i.MAINVERSIONLOOSE]+s[i.PRERELEASELOOSE]+"?"+s[i.BUILD]+"?",E("LOOSE"),s[i.LOOSE]="^"+s[i.LOOSEPLAIN]+"$",E("GTLT"),s[i.GTLT]="((?:<|>)?=?)",E("XRANGEIDENTIFIERLOOSE"),s[i.XRANGEIDENTIFIERLOOSE]=s[i.NUMERICIDENTIFIERLOOSE]+"|x|X|\\*",E("XRANGEIDENTIFIER"),s[i.XRANGEIDENTIFIER]=s[i.NUMERICIDENTIFIER]+"|x|X|\\*",E("XRANGEPLAIN"),s[i.XRANGEPLAIN]="[v=\\s]*("+s[i.XRANGEIDENTIFIER]+")(?:\\.("+s[i.XRANGEIDENTIFIER]+")(?:\\.("+s[i.XRANGEIDENTIFIER]+")(?:"+s[i.PRERELEASE]+")?"+s[i.BUILD]+"?)?)?",E("XRANGEPLAINLOOSE"),s[i.XRANGEPLAINLOOSE]="[v=\\s]*("+s[i.XRANGEIDENTIFIERLOOSE]+")(?:\\.("+s[i.XRANGEIDENTIFIERLOOSE]+")(?:\\.("+s[i.XRANGEIDENTIFIERLOOSE]+")(?:"+s[i.PRERELEASELOOSE]+")?"+s[i.BUILD]+"?)?)?",E("XRANGE"),s[i.XRANGE]="^"+s[i.GTLT]+"\\s*"+s[i.XRANGEPLAIN]+"$",E("XRANGELOOSE"),s[i.XRANGELOOSE]="^"+s[i.GTLT]+"\\s*"+s[i.XRANGEPLAINLOOSE]+"$",E("COERCE"),s[i.COERCE]="(^|[^\\d])(\\d{1,"+n+"})(?:\\.(\\d{1,"+n+"}))?(?:\\.(\\d{1,"+n+"}))?(?:$|[^\\d])",E("COERCERTL"),o[i.COERCERTL]=new RegExp(s[i.COERCE],"g"),E("LONETILDE"),s[i.LONETILDE]="(?:~>?)",E("TILDETRIM"),s[i.TILDETRIM]="(\\s*)"+s[i.LONETILDE]+"\\s+",o[i.TILDETRIM]=new RegExp(s[i.TILDETRIM],"g");var p="$1~";E("TILDE"),s[i.TILDE]="^"+s[i.LONETILDE]+s[i.XRANGEPLAIN]+"$",E("TILDELOOSE"),s[i.TILDELOOSE]="^"+s[i.LONETILDE]+s[i.XRANGEPLAINLOOSE]+"$",E("LONECARET"),s[i.LONECARET]="(?:\\^)",E("CARETTRIM"),s[i.CARETTRIM]="(\\s*)"+s[i.LONECARET]+"\\s+",o[i.CARETTRIM]=new RegExp(s[i.CARETTRIM],"g");var u="$1^";E("CARET"),s[i.CARET]="^"+s[i.LONECARET]+s[i.XRANGEPLAIN]+"$",E("CARETLOOSE"),s[i.CARETLOOSE]="^"+s[i.LONECARET]+s[i.XRANGEPLAINLOOSE]+"$",E("COMPARATORLOOSE"),s[i.COMPARATORLOOSE]="^"+s[i.GTLT]+"\\s*("+s[i.LOOSEPLAIN]+")$|^$",E("COMPARATOR"),s[i.COMPARATOR]="^"+s[i.GTLT]+"\\s*("+s[i.FULLPLAIN]+")$|^$",E("COMPARATORTRIM"),s[i.COMPARATORTRIM]="(\\s*)"+s[i.GTLT]+"\\s*("+s[i.LOOSEPLAIN]+"|"+s[i.XRANGEPLAIN]+")",o[i.COMPARATORTRIM]=new RegExp(s[i.COMPARATORTRIM],"g");var c="$1$2$3";E("HYPHENRANGE"),s[i.HYPHENRANGE]="^\\s*("+s[i.XRANGEPLAIN]+")\\s+-\\s+("+s[i.XRANGEPLAIN]+")\\s*$",E("HYPHENRANGELOOSE"),s[i.HYPHENRANGELOOSE]="^\\s*("+s[i.XRANGEPLAINLOOSE]+")\\s+-\\s+("+s[i.XRANGEPLAINLOOSE]+")\\s*$",E("STAR"),s[i.STAR]="(<|>)?=?\\s*\\*";for(var l=0;lr)return null;if(!(t.loose?o[i.LOOSE]:o[i.FULL]).test(e))return null;try{return new f(e,t)}catch(n){return null}}function I(e,r){var t=h(e,r);return t?t.version:null}function R(e,r){var t=h(e.trim().replace(/^[=v]+/,""),r);return t?t.version:null}function f(n,s){if(s&&"object"==typeof s||(s={loose:!!s,includePrerelease:!1}),n instanceof f){if(n.loose===s.loose)return n;n=n.version}else if("string"!=typeof n)throw new TypeError("Invalid Version: "+n);if(n.length>r)throw new TypeError("version is longer than "+r+" characters");if(!(this instanceof f))return new f(n,s);e("SemVer",n,s),this.options=s,this.loose=!!s.loose;var a=n.trim().match(s.loose?o[i.LOOSE]:o[i.FULL]);if(!a)throw new TypeError("Invalid Version: "+n);if(this.raw=n,this.major=+a[1],this.minor=+a[2],this.patch=+a[3],this.major>t||this.major<0)throw new TypeError("Invalid major version");if(this.minor>t||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>t||this.patch<0)throw new TypeError("Invalid patch version");a[4]?this.prerelease=a[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var r=+e;if(r>=0&&r=0;)"number"==typeof this.prerelease[t]&&(this.prerelease[t]++,t=-2);-1===t&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},exports.inc=O,exports.diff=N,exports.compareIdentifiers=v;var L=/^[0-9]+$/;function v(e,r){var t=L.test(e),n=L.test(r);return t&&n&&(e=+e,r=+r),e===r?0:t&&!n?-1:n&&!t?1:e0}function y(e,r,t){return w(e,r,t)<0}function M(e,r,t){return 0===w(e,r,t)}function F(e,r,t){return 0!==w(e,r,t)}function G(e,r,t){return w(e,r,t)>=0}function U(e,r,t){return w(e,r,t)<=0}function j(e,r,t,n){switch(r){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),e===t;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof t&&(t=t.version),e!==t;case"":case"=":case"==":return M(e,t,n);case"!=":return F(e,t,n);case">":return x(e,t,n);case">=":return G(e,t,n);case"<":return y(e,t,n);case"<=":return U(e,t,n);default:throw new TypeError("Invalid operator: "+r)}}function X(r,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),r instanceof X){if(r.loose===!!t.loose)return r;r=r.value}if(!(this instanceof X))return new X(r,t);e("comparator",r,t),this.options=t,this.loose=!!t.loose,this.parse(r),this.semver===b?this.value="":this.value=this.operator+this.semver.version,e("comp",this)}exports.rcompareIdentifiers=m,exports.major=T,exports.minor=A,exports.patch=S,exports.compare=w,exports.compareLoose=g,exports.compareBuild=P,exports.rcompare=C,exports.sort=d,exports.rsort=D,exports.gt=x,exports.lt=y,exports.eq=M,exports.neq=F,exports.gte=G,exports.lte=U,exports.cmp=j,exports.Comparator=X;var b={};function $(e,r){if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),e instanceof $)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new $(e.raw,r);if(e instanceof X)return new $(e.value,r);if(!(this instanceof $))return new $(e,r);if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function B(e,r){for(var t=!0,n=e.slice(),o=n.pop();t&&n.length;)t=n.every(function(e){return o.intersects(e,r)}),o=n.pop();return t}function V(e,r){return new $(e,r).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})}function k(r,t){return e("comp",r,t),r=q(r,t),e("caret",r),r=Y(r,t),e("tildes",r),r=Z(r,t),e("xrange",r),r=K(r,t),e("stars",r),r}function H(e){return!e||"x"===e.toLowerCase()||"*"===e}function Y(e,r){return e.trim().split(/\s+/).map(function(e){return _(e,r)}).join(" ")}function _(r,t){var n=t.loose?o[i.TILDELOOSE]:o[i.TILDE];return r.replace(n,function(t,n,o,s,i){var a;return e("tilde",r,t,n,o,s,i),H(n)?a="":H(o)?a=">="+n+".0.0 <"+(+n+1)+".0.0":H(s)?a=">="+n+"."+o+".0 <"+n+"."+(+o+1)+".0":i?(e("replaceTilde pr",i),a=">="+n+"."+o+"."+s+"-"+i+" <"+n+"."+(+o+1)+".0"):a=">="+n+"."+o+"."+s+" <"+n+"."+(+o+1)+".0",e("tilde return",a),a})}function q(e,r){return e.trim().split(/\s+/).map(function(e){return z(e,r)}).join(" ")}function z(r,t){e("caret",r,t);var n=t.loose?o[i.CARETLOOSE]:o[i.CARET];return r.replace(n,function(t,n,o,s,i){var a;return e("caret",r,t,n,o,s,i),H(n)?a="":H(o)?a=">="+n+".0.0 <"+(+n+1)+".0.0":H(s)?a="0"===n?">="+n+"."+o+".0 <"+n+"."+(+o+1)+".0":">="+n+"."+o+".0 <"+(+n+1)+".0.0":i?(e("replaceCaret pr",i),a="0"===n?"0"===o?">="+n+"."+o+"."+s+"-"+i+" <"+n+"."+o+"."+(+s+1):">="+n+"."+o+"."+s+"-"+i+" <"+n+"."+(+o+1)+".0":">="+n+"."+o+"."+s+"-"+i+" <"+(+n+1)+".0.0"):(e("no pr"),a="0"===n?"0"===o?">="+n+"."+o+"."+s+" <"+n+"."+o+"."+(+s+1):">="+n+"."+o+"."+s+" <"+n+"."+(+o+1)+".0":">="+n+"."+o+"."+s+" <"+(+n+1)+".0.0"),e("caret return",a),a})}function Z(r,t){return e("replaceXRanges",r,t),r.split(/\s+/).map(function(e){return J(e,t)}).join(" ")}function J(r,t){r=r.trim();var n=t.loose?o[i.XRANGELOOSE]:o[i.XRANGE];return r.replace(n,function(n,o,s,i,a,E){e("xRange",r,n,o,s,i,a,E);var p=H(s),u=p||H(i),c=u||H(a),l=c;return"="===o&&l&&(o=""),E=t.includePrerelease?"-0":"",p?n=">"===o||"<"===o?"<0.0.0-0":"*":o&&l?(u&&(i=0),a=0,">"===o?(o=">=",u?(s=+s+1,i=0,a=0):(i=+i+1,a=0)):"<="===o&&(o="<",u?s=+s+1:i=+i+1),n=o+s+"."+i+"."+a+E):u?n=">="+s+".0.0"+E+" <"+(+s+1)+".0.0"+E:c&&(n=">="+s+"."+i+".0"+E+" <"+s+"."+(+i+1)+".0"+E),e("xRange return",n),n})}function K(r,t){return e("replaceStars",r,t),r.trim().replace(o[i.STAR],"")}function Q(e,r,t,n,o,s,i,a,E,p,u,c,l){return((r=H(t)?"":H(n)?">="+t+".0.0":H(o)?">="+t+"."+n+".0":">="+r)+" "+(a=H(E)?"":H(p)?"<"+(+E+1)+".0.0":H(u)?"<"+E+"."+(+p+1)+".0":c?"<="+E+"."+p+"."+u+"-"+c:"<="+a)).trim()}function W(r,t,n){for(var o=0;o0){var s=r[o].semver;if(s.major===t.major&&s.minor===t.minor&&s.patch===t.patch)return!0}return!1}return!0}function ee(e,r,t){try{r=new $(r,t)}catch(n){return!1}return r.test(e)}function re(e,r,t){var n=null,o=null;try{var s=new $(r,t)}catch(i){return null}return e.forEach(function(e){s.test(e)&&(n&&-1!==o.compare(e)||(o=new f(n=e,t)))}),n}function te(e,r,t){var n=null,o=null;try{var s=new $(r,t)}catch(i){return null}return e.forEach(function(e){s.test(e)&&(n&&1!==o.compare(e)||(o=new f(n=e,t)))}),n}function ne(e,r){e=new $(e,r);var t=new f("0.0.0");if(e.test(t))return t;if(t=new f("0.0.0-0"),e.test(t))return t;t=null;for(var n=0;n":0===r.prerelease.length?r.patch++:r.prerelease.push(0),r.raw=r.format();case"":case">=":t&&!x(t,r)||(t=r);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: "+e.operator)}})}return t&&e.test(t)?t:null}function oe(e,r){try{return new $(e,r).range||"*"}catch(t){return null}}function se(e,r,t){return ae(e,r,"<",t)}function ie(e,r,t){return ae(e,r,">",t)}function ae(e,r,t,n){var o,s,i,a,E;switch(e=new f(e,n),r=new $(r,n),t){case">":o=x,s=U,i=y,a=">",E=">=";break;case"<":o=y,s=G,i=x,a="<",E="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ee(e,r,n))return!1;for(var p=0;p=0.0.0")),c=c||e,l=l||e,o(e.semver,c.semver,n)?c=e:i(e.semver,l.semver,n)&&(l=e)}),c.operator===a||c.operator===E)return!1;if((!l.operator||l.operator===a)&&s(e,l.semver))return!1;if(l.operator===E&&i(e,l.semver))return!1}return!0}function Ee(e,r){var t=h(e,r);return t&&t.prerelease.length?t.prerelease:null}function pe(e,r,t){return e=new $(e,t),r=new $(r,t),e.intersects(r)}function ue(e,r){if(e instanceof f)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;var t=null;if((r=r||{}).rtl){for(var n;(n=o[i.COERCERTL].exec(e))&&(!t||t.index+t[0].length!==e.length);)t&&n.index+n[0].length===t.index+t[0].length||(t=n),o[i.COERCERTL].lastIndex=n.index+n[1].length+n[2].length;o[i.COERCERTL].lastIndex=-1}else t=e.match(o[i.COERCE]);return null===t?null:h(t[2]+"."+(t[3]||"0")+"."+(t[4]||"0"),r)}X.prototype.parse=function(e){var r=this.options.loose?o[i.COMPARATORLOOSE]:o[i.COMPARATOR],t=e.match(r);if(!t)throw new TypeError("Invalid comparator: "+e);this.operator=void 0!==t[1]?t[1]:"","="===this.operator&&(this.operator=""),t[2]?this.semver=new f(t[2],this.options.loose):this.semver=b},X.prototype.toString=function(){return this.value},X.prototype.test=function(r){if(e("Comparator.test",r,this.options.loose),this.semver===b||r===b)return!0;if("string"==typeof r)try{r=new f(r,this.options)}catch(t){return!1}return j(r,this.operator,this.semver,this.options)},X.prototype.intersects=function(e,r){if(!(e instanceof X))throw new TypeError("a Comparator is required");var t;if(r&&"object"==typeof r||(r={loose:!!r,includePrerelease:!1}),""===this.operator)return""===this.value||(t=new $(e.value,r),ee(this.value,t,r));if(""===e.operator)return""===e.value||(t=new $(this.value,r),ee(e.semver,t,r));var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),o=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),s=this.semver.version===e.semver.version,i=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),a=j(this.semver,"<",e.semver,r)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),E=j(this.semver,">",e.semver,r)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||o||s&&i||a||E},exports.Range=$,$.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},$.prototype.toString=function(){return this.range},$.prototype.parseRange=function(r){var t=this.options.loose;r=r.trim();var n=t?o[i.HYPHENRANGELOOSE]:o[i.HYPHENRANGE];r=r.replace(n,Q),e("hyphen replace",r),r=r.replace(o[i.COMPARATORTRIM],c),e("comparator trim",r,o[i.COMPARATORTRIM]),r=(r=(r=r.replace(o[i.TILDETRIM],p)).replace(o[i.CARETTRIM],u)).split(/\s+/).join(" ");var s=t?o[i.COMPARATORLOOSE]:o[i.COMPARATOR],a=r.split(" ").map(function(e){return k(e,this.options)},this).join(" ").split(/\s+/);return this.options.loose&&(a=a.filter(function(e){return!!e.match(s)})),a=a.map(function(e){return new X(e,this.options)},this)},$.prototype.intersects=function(e,r){if(!(e instanceof $))throw new TypeError("a Range is required");return this.set.some(function(t){return B(t,r)&&e.set.some(function(e){return B(e,r)&&t.every(function(t){return e.every(function(e){return t.intersects(e,r)})})})})},exports.toComparators=V,$.prototype.test=function(e){if(!e)return!1;if("string"==typeof e)try{e=new f(e,this.options)}catch(t){return!1}for(var r=0;r{let e=process.env.GITHUB_TOKEN;if(!e)return void i.setFailed("Please add the GITHUB_TOKEN to the changesets action");let n=`${s.context.repo.owner}/${s.context.repo.repo}`;const a=new s.GitHub(e);let o=a.repos.get(s.context.repo).then(e=>e.data.default_branch);console.log("setting git user"),await r.exec("git",["config","--global","user.name",'"github-actions[bot]"']),await r.exec("git",["config","--global","user.email",'"github-actions[bot]@users.noreply.github.com"']),console.log("setting GitHub credentials"),await l.default.writeFile(`${process.env.HOME}/.netrc`,`machine github.com\nlogin github-actions[bot]\npassword ${e}`);let d=await o;if(s.context.ref.replace("refs/heads/","")!==d)return void i.setFailed(`The changesets action should only run on ${d} but it's running on ${s.context.ref.replace("refs/heads/","")}, please change your GitHub actions config to only run the Changesets action on ${d}`);let p=l.default.readdirSync(`${process.cwd()}/.changeset`).some(e=>"README.md"!==e&&(e.endsWith(".md")||e.endsWith("changes.json"))),f=i.getInput("publish");if(p||f)if(p||!f){if(p){let{stderr:e}=await g.execWithOutput("git",["checkout","changeset-release"],{ignoreReturnCode:!0});!e.toString().includes("Switched to a new branch 'changeset-release'")&&await r.exec("git",["checkout","-b","changeset-release"]),await r.exec("git",["reset","--hard",s.context.sha]);let o=await l.default.readJson(u.default.join("node_modules","@changesets","cli","package.json")),i=h.lt(o.version,"2.0.0")?"bump":"version",c=(await g.execWithOutput("node",["./node_modules/.bin/changeset",i]),`repo:${n}+state:open+head:changeset-release+base:${d}`),p=a.search.issuesAndPullRequests({q:c}),b=await g.getChangedPackages(process.cwd()),w=(async()=>`This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and ${f?"the packages will be published to npm automatically":"publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing)"}. If you're not ready to do a release yet, that's fine, whenever you add more changesets to ${d}, this PR will be updated.\n\n# Releases\n`+(await Promise.all(b.map(async e=>{let t=await l.default.readFile(u.default.join(e.dir,"CHANGELOG.md"),"utf8"),n=g.getChangelogEntry(t,e.config.version);return{highestLevel:n.highestLevel,private:!!e.config.private,content:`## ${e.name}@${e.config.version}\n\n`+n.content}}))).filter(e=>e).sort(g.sortTheThings).map(e=>e.content).join("\n "))();await r.exec("git",["add","."]),await r.exec("git",["commit","-m","Version Packages"]),await r.exec("git",["push","origin","changeset-release","--force"]);let m=await p;console.log(JSON.stringify(m.data,null,2)),0===m.data.items.length?(console.log("creating pull request"),await a.pulls.create(t({base:d,head:"changeset-release",title:"Version Packages",body:await w},s.context.repo))):(a.pulls.update(t({pull_number:m.data.items[0].number,body:await w},s.context.repo)),console.log("pull request found"))}}else{console.log("No changesets found, attempting to publish any unpublished packages to npm");let e=await c.default({tools:["bolt","yarn","root"]});if(!e)return i.setFailed("Could not find workspaces");let n=new Map(e.map(e=>[e.name,e]));l.default.writeFileSync(`${process.env.HOME}/.npmrc`,`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`);let[o,...h]=f.split(/\s+/),p=await g.execWithOutput(o,h);await r.exec("git",["push","origin",`HEAD:${d}`,"--follow-tags"]);let b=/New tag:\s+(@[^\/]+\/[^@]+|[^\/]+)@([^\s]+)/,w=[];for(let t of p.stdout.split("\n")){let e=t.match(b);if(null===e)continue;let a=e[1],o=n.get(a);if(void 0===o)return i.setFailed("Workspace not found for "+a+". This is probably a bug in the action, please open an issue");w.push(o)}await Promise.all(w.map(async e=>{try{let o=u.default.join(e.dir,"CHANGELOG.md"),r=await l.default.readFile(o,"utf8"),c=g.getChangelogEntry(r,e.config.version);if(!c)return i.setFailed(`Could not find changelog entry for ${e.name}@${e.config.version}`);await a.repos.createRelease(t({tag_name:`${e.name}@${e.config.version}`,body:c.content,prerelease:e.config.version.includes("-")},s.context.repo))}catch(n){if("ENOENT"!==n.code)throw n}}))}else console.log("No changesets found")})().catch(e=>{console.error(e),i.setFailed(e.message)}); +"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function t(t){for(var a=1;a{let e=process.env.GITHUB_TOKEN;if(!e)return void i.setFailed("Please add the GITHUB_TOKEN to the changesets action");let n=`${s.context.repo.owner}/${s.context.repo.repo}`;const a=new s.GitHub(e);let o=a.repos.get(s.context.repo).then(e=>e.data.default_branch);console.log("setting git user"),await r.exec("git",["config","--global","user.name",'"github-actions[bot]"']),await r.exec("git",["config","--global","user.email",'"github-actions[bot]@users.noreply.github.com"']),console.log("setting GitHub credentials"),await c.default.writeFile(`${process.env.HOME}/.netrc`,`machine github.com\nlogin github-actions[bot]\npassword ${e}`);let h=await o;if(s.context.ref.replace("refs/heads/","")!==h)return void i.setFailed(`The changesets action should only run on ${h} but it's running on ${s.context.ref.replace("refs/heads/","")}, please change your GitHub actions config to only run the Changesets action on ${h}`);let p=c.default.readdirSync(`${process.cwd()}/.changeset`).some(e=>"README.md"!==e&&(e.endsWith(".md")||e.endsWith("changes.json")));console.log(c.default.readdirSync(`${process.cwd()}/.changeset`));let f=i.getInput("publish");if(p||f)if(p||!f){if(p){let{stderr:e}=await g.execWithOutput("git",["checkout","changeset-release"],{ignoreReturnCode:!0});!e.toString().includes("Switched to a new branch 'changeset-release'")&&await r.exec("git",["checkout","-b","changeset-release"]),await r.exec("git",["reset","--hard",s.context.sha]);let o=await c.default.readJson(u.default.join("node_modules","@changesets","cli","package.json")),i=d.lt(o.version,"2.0.0")?"bump":"version",l=(await g.execWithOutput("node",["./node_modules/.bin/changeset",i]),`repo:${n}+state:open+head:changeset-release+base:${h}`),p=a.search.issuesAndPullRequests({q:l}),b=await g.getChangedPackages(process.cwd()),w=(async()=>`This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and ${f?"the packages will be published to npm automatically":"publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing)"}. If you're not ready to do a release yet, that's fine, whenever you add more changesets to ${h}, this PR will be updated.\n\n# Releases\n`+(await Promise.all(b.map(async e=>{let t=await c.default.readFile(u.default.join(e.dir,"CHANGELOG.md"),"utf8"),n=g.getChangelogEntry(t,e.config.version);return{highestLevel:n.highestLevel,private:!!e.config.private,content:`## ${e.name}@${e.config.version}\n\n`+n.content}}))).filter(e=>e).sort(g.sortTheThings).map(e=>e.content).join("\n "))();await r.exec("git",["add","."]),await r.exec("git",["commit","-m","Version Packages"]),await r.exec("git",["push","origin","changeset-release","--force"]);let m=await p;console.log(JSON.stringify(m.data,null,2)),0===m.data.items.length?(console.log("creating pull request"),await a.pulls.create(t({base:h,head:"changeset-release",title:"Version Packages",body:await w},s.context.repo))):(a.pulls.update(t({pull_number:m.data.items[0].number,body:await w},s.context.repo)),console.log("pull request found"))}}else{console.log("No changesets found, attempting to publish any unpublished packages to npm");let e=await l.default({tools:["bolt","yarn","root"]});if(!e)return i.setFailed("Could not find workspaces");let n=new Map(e.map(e=>[e.name,e]));c.default.writeFileSync(`${process.env.HOME}/.npmrc`,`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`);let[o,...d]=f.split(/\s+/),p=await g.execWithOutput(o,d);await r.exec("git",["push","origin",`HEAD:${h}`,"--follow-tags"]);let b=/New tag:\s+(@[^\/]+\/[^@]+|[^\/]+)@([^\s]+)/,w=[];for(let t of p.stdout.split("\n")){let e=t.match(b);if(null===e)continue;let a=e[1],o=n.get(a);if(void 0===o)return i.setFailed("Workspace not found for "+a+". This is probably a bug in the action, please open an issue");w.push(o)}await Promise.all(w.map(async e=>{try{let o=u.default.join(e.dir,"CHANGELOG.md"),r=await c.default.readFile(o,"utf8"),l=g.getChangelogEntry(r,e.config.version);if(!l)return i.setFailed(`Could not find changelog entry for ${e.name}@${e.config.version}`);await a.repos.createRelease(t({tag_name:`${e.name}@${e.config.version}`,body:l.content,prerelease:e.config.version.includes("-")},s.context.repo))}catch(n){if("ENOENT"!==n.code)throw n}}))}else console.log("No changesets found")})().catch(e=>{console.error(e),i.setFailed(e.message)}); },{"@actions/core":"4FTV","@actions/exec":"utFe","@actions/github":"8Dol","fs-extra":"JTJ9","get-workspaces":"kAcF","./utils":"UnXq","semver":"aric"}]},{},["7QCb"], null) \ No newline at end of file diff --git a/index.ts b/index.ts index 5a0e540..5c70397 100644 --- a/index.ts +++ b/index.ts @@ -65,6 +65,8 @@ import * as semver from "semver"; x !== "README.md" && (x.endsWith(".md") || x.endsWith("changes.json")) ); + console.log(fs.readdirSync(`${process.cwd()}/.changeset`)); + let publishScript = core.getInput("publish"); if (!hasChangesets && !publishScript) {