Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { fetch } from "https://esm.town/v/std/fetch";
import { getTagForNextRelease } from "https://esm.town/v/vinspee/getTagForNextRelease";
import process from "node:process";
export async function createRelease(
req: express.Request,
res: express.Response
) {
if (
req.query.authentication === process.env.VERSITY_RELEASE_API_KEY
) {
const tag = await getTagForNextRelease();
const releaseRes = await fetch(
`https://api.github.com/repos/Endeavor-Digital/versity/releases`,
{
method: "POST",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${process.env.VERSITY_RELEASE_GITHUB_TOKEN}`,
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({
owner: "Endeavor-Digital",
repo: "versity",
tag_name: tag,
target_commitish: "main",
name: tag,
body: req.params.body ?? "",
draft: true,
prerelease: true,
generate_release_notes: true,
}),
}
).then((resp) => resp.json());
console.log({ releaseRes });
return res.redirect(302, releaseRes.html_url);
} else {
return res.status(403).json({
error: {
message: "No Auth",
},
});
}
}
October 23, 2023