Skip to content

Commit

Permalink
fix: update package type and handle 404 for the current release status
Browse files Browse the repository at this point in the history
  • Loading branch information
phinpho committed Aug 5, 2024
1 parent 411ac1a commit 912d330
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@sceneforge/dev-docs",
"version": "0.0.1",
"description": "Development Documentation for the Scene Forge",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/sceneforge/docs"
Expand All @@ -27,4 +26,4 @@
"typescript": "^5.5.3"
},
"packageManager": "yarn@4.3.1"
}
}
39 changes: 26 additions & 13 deletions scripts/validateRelease.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const RELEASE_STATUS_URL = "https://docs.sceneforge.org/.release-status.json";

module.exports = async ({ github, core }) => {
const draft = process.env.RELEASE_DRAFT;
const name = process.env.RELEASE_NAME;
Expand Down Expand Up @@ -35,22 +37,33 @@ module.exports = async ({ github, core }) => {
}

try {
const result = await fetch("https://docs.sceneforge.org/.release-status.json");
const currentReleaseStatus = await result.json();
const result = await fetch(RELEASE_STATUS_URL);
if (result.status >= 200 && result.status < 300) {
const currentReleaseStatus = await result.json();

if (
typeof currentReleaseStatus === "object"
&& currentReleaseStatus !== null
&& "name" in currentReleaseStatus
&& typeof currentReleaseStatus.name === "string"
) {
if (currentReleaseStatus.name === name) {
errors.push({
title: "Already released",
message: `The release "${name}" is currently published`,
});
if (
typeof currentReleaseStatus === "object"
&& currentReleaseStatus !== null
&& "name" in currentReleaseStatus
&& typeof currentReleaseStatus.name === "string"
) {
if (currentReleaseStatus.name === name) {
errors.push({
title: "Already released",
message: `The release "${name}" is currently published`,
});
}
}
}
else if (result.status === 404) {
core.warning("Current release status is not found");
}
else {
errors.push({
title: "Unable to fetch current release status",
message: `Failed to fetch "${RELEASE_STATUS_URL}", status code: ${result.status}`,
});
}
} catch (error) {
errors.push({
title: "Current Release Status not found",
Expand Down

0 comments on commit 912d330

Please sign in to comment.