Add script for creating the forgejo release
This commit is contained in:
parent
031fdb4a40
commit
351300651b
2 changed files with 54 additions and 16 deletions
51
scripts/createForgejoRelease.mjs
Normal file
51
scripts/createForgejoRelease.mjs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import fs from "fs";
|
||||
import axios from "axios";
|
||||
|
||||
const {
|
||||
TAG,
|
||||
FORGEJO_API_URL: API,
|
||||
FORGEJO_REPOSITORY: REPO,
|
||||
FORGEJO_TOKEN: TOKEN,
|
||||
} = process.env;
|
||||
|
||||
async function main() {
|
||||
|
||||
// Initial Release Data
|
||||
const release = await axios.post(
|
||||
`${API}/repos/${REPO}/releases`,
|
||||
{
|
||||
tag_name: TAG,
|
||||
draft: true,
|
||||
hide_archive_links: true,
|
||||
},
|
||||
{
|
||||
headers: { Authorization: `token ${TOKEN}` },
|
||||
}
|
||||
);
|
||||
|
||||
// Upload the release archive
|
||||
const archiveFormData = new FormData();
|
||||
const archive = await fs.openAsBlob(`release.zip`);
|
||||
archiveFormData.set(`release`, archive, `release.zip`)
|
||||
await axios.post(
|
||||
`${API}/repos/${REPO}/releases/${release.data.id}/assets`,
|
||||
archiveFormData,
|
||||
{
|
||||
headers: { Authorization: `token ${TOKEN}` },
|
||||
}
|
||||
);
|
||||
|
||||
// Upload the manifest file
|
||||
const formData = new FormData();
|
||||
const manifest = await fs.openAsBlob(`system.json`);
|
||||
formData.set(`manifest`, manifest, `system.json`)
|
||||
await axios.post(
|
||||
`${API}/repos/${REPO}/releases/${release.data.id}/assets`,
|
||||
formData,
|
||||
{
|
||||
headers: { Authorization: `token ${TOKEN}` },
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
main();
|
||||
Loading…
Add table
Add a link
Reference in a new issue