Files
vercel/utils/update-latest-release.js
Nathan Rajlich 2da72bc5e4 Fix promoting CLI release to "latest" GH Release (#10003)
The logic to retrieve the latest release was not working correctly, so use the `getLatestRelease()` function instead of assuming that `release[0]` is tagged as the latest.
2023-05-22 18:49:51 +00:00

29 lines
775 B
JavaScript
Vendored

function isVercelCliRelease(release) {
return release.tag_name.startsWith('vercel@');
}
module.exports = async ({ github, context }) => {
const { owner, repo } = context.repo;
const { data: latestRelease } = await github.rest.repos.getLatestRelease({
owner,
repo,
});
if (isVercelCliRelease(latestRelease)) {
console.log(`Latest release is "${latestRelease.tag_name}" - skipping`);
return;
}
const response = await github.rest.repos.listReleases({ owner, repo });
const latestCliRelease = response.data.find(isVercelCliRelease);
console.log(`Promoting "${latestCliRelease.tag_name}" to latest release`);
await github.rest.repos.updateRelease({
owner,
repo,
release_id: latestCliRelease.id,
make_latest: true,
});
};