Prevent attempt to publish to npm (#4239)

pull/4244/head
Francisco 2 years ago committed by GitHub
parent 3e1b25a5cf
commit f355bd3a2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      package-lock.json
  2. 1
      package.json
  3. 14
      scripts/release/workflow/state.js

13
package-lock.json generated

@ -48,6 +48,7 @@
"solidity-ast": "^0.4.25",
"solidity-coverage": "^0.8.0",
"solidity-docgen": "^0.6.0-beta.29",
"undici": "^5.22.1",
"web3": "^1.3.0",
"yargs": "^17.0.0"
}
@ -15175,9 +15176,9 @@
"dev": true
},
"node_modules/undici": {
"version": "5.22.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.22.0.tgz",
"integrity": "sha512-fR9RXCc+6Dxav4P9VV/sp5w3eFiSdOjJYsbtWfd4s5L5C4ogyuVpdKIVHeW0vV1MloM65/f7W45nR9ZxwVdyiA==",
"version": "5.22.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.22.1.tgz",
"integrity": "sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw==",
"dev": true,
"dependencies": {
"busboy": "^1.6.0"
@ -27985,9 +27986,9 @@
"dev": true
},
"undici": {
"version": "5.22.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.22.0.tgz",
"integrity": "sha512-fR9RXCc+6Dxav4P9VV/sp5w3eFiSdOjJYsbtWfd4s5L5C4ogyuVpdKIVHeW0vV1MloM65/f7W45nR9ZxwVdyiA==",
"version": "5.22.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.22.1.tgz",
"integrity": "sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw==",
"dev": true,
"requires": {
"busboy": "^1.6.0"

@ -89,6 +89,7 @@
"solidity-ast": "^0.4.25",
"solidity-coverage": "^0.8.0",
"solidity-docgen": "^0.6.0-beta.29",
"undici": "^5.22.1",
"web3": "^1.3.0",
"yargs": "^17.0.0"
}

@ -1,7 +1,8 @@
const { readPreState } = require('@changesets/pre');
const { default: readChangesets } = require('@changesets/read');
const { join } = require('path');
const { version } = require(join(__dirname, '../../../package.json'));
const { fetch } = require('undici');
const { version, name: packageName } = require(join(__dirname, '../../../contracts/package.json'));
module.exports = async ({ github, context, core }) => {
const state = await getState({ github, context, core });
@ -34,8 +35,8 @@ function shouldRunChangesets({ isReleaseBranch, isPush, isWorkflowDispatch, botR
return (isReleaseBranch && isPush) || (isReleaseBranch && isWorkflowDispatch && botRun);
}
function shouldRunPublish({ isReleaseBranch, isPush, hasPendingChangesets }) {
return isReleaseBranch && isPush && !hasPendingChangesets;
function shouldRunPublish({ isReleaseBranch, isPush, hasPendingChangesets, isPublishedOnNpm }) {
return isReleaseBranch && isPush && !hasPendingChangesets && !isPublishedOnNpm;
}
function shouldRunMerge({
@ -80,6 +81,8 @@ async function getState({ github, context, core }) {
state.prBackExists = prs.length === 0;
state.isPublishedOnNpm = await isPublishedOnNpm(packageName, version);
// Log every state value in debug mode
if (core.isDebug()) for (const [key, value] of Object.entries(state)) core.debug(`${key}: ${value}`);
@ -102,3 +105,8 @@ async function readChangesetState(cwd = process.cwd()) {
changesets,
};
}
async function isPublishedOnNpm(package, version) {
const res = await fetch(`https://registry.npmjs.com/${package}/${version}`);
return res.ok;
}

Loading…
Cancel
Save