Skip to content

Commit 020e854

Browse files
committed
chore: make github release optional
1 parent 4e6ea0d commit 020e854

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

scripts/release-cdn.mts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if (!process.env.CDN_BUCKET_NAME) {
6565
const { CDN_BUCKET_NAME } = process.env
6666

6767
if (!process.env.GITHUB_TOKEN && !isDryRun) {
68-
throw new Error('You are missing an environment variable GITHUB_TOKEN.')
68+
console.warn('You are missing an environment variable GITHUB_TOKEN. The github release will not be created.')
6969
}
7070

7171
console.log('I will now process the files:')
@@ -141,17 +141,20 @@ if (!isDryRun) {
141141

142142
const semverRegex = /^v[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$/
143143
if (semverRegex.test(targetVersion)) {
144-
const ghRelease = await getReleaseForTag(OWNER, REPO, targetVersion)
145-
console.log(`I have found the latest version to be: ${ghRelease.tag_name} named "${ghRelease.name}."`)
146-
147-
console.log('Appending CDN instructions to release description.')
148-
if (isDryRun) {
149-
console.log('Following would be added to the release notes:')
150-
console.log('------')
151-
console.log(cdnLinks.join('\n'))
152-
console.log('------')
153-
} else {
154-
await patchGithubReleaseBody(ghRelease, ghRelease.body + cdnLinks.join('\n'))
155-
console.log(`Please verify that instructions are correct by navigating to: ${ghRelease.html_url}`)
144+
console.log('Following will be added to the release notes:')
145+
console.log('------')
146+
console.log(cdnLinks.join('\n'))
147+
console.log('------')
148+
149+
try {
150+
const ghRelease = await getReleaseForTag(OWNER, REPO, targetVersion)
151+
console.log(`I have found the latest version to be: ${ghRelease.tag_name} named "${ghRelease.name}."`)
152+
console.log('Appending CDN instructions to release description.')
153+
if (!isDryRun) {
154+
await patchGithubReleaseBody(ghRelease, ghRelease.body + cdnLinks.join('\n'))
155+
console.log(`Please verify that instructions are correct by navigating to: ${ghRelease.html_url}`)
156+
}
157+
} catch (error) {
158+
console.error('Failed to update release notes:', error)
156159
}
157160
}

0 commit comments

Comments
 (0)