Skip to content

Commit

Permalink
chore: add script (#1746)
Browse files Browse the repository at this point in the history
  • Loading branch information
acao authored Dec 28, 2020
1 parent 63ffcc3 commit 872b838
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions resources/publishCleanup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Octokit } from '@octokit/rest';

const owner = 'graphql';
const repo = 'graphiql';

const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN || process.env.GH_TOKEN,
log: {
debug: () => {},
info: console.log,
warn: console.warn,
error: console.error,
},
});

async function run() {
const releases = await octokit.repos.listReleases({
owner,
repo,
per_page: 100,
});
const exampleReleases = releases.data.filter(
({ name }) => name && (name.includes('example') || name.includes('rfc')),
);

console.log(
`deleting ${exampleReleases.length} errant releases created by lerna publish`,
);

await Promise.all(
exampleReleases.map(async release => {
await octokit.repos.deleteRelease({
owner,
repo,
release_id: release.id,
});
await octokit.git.deleteRef({
owner,
repo,
ref: `tags/${release.tag_name}`,
});
}),
);
}

(async () => {
try {
await run();
} catch (err) {
console.error(err);
}
})();

0 comments on commit 872b838

Please sign in to comment.