Add CI scripts and workflow for forgejo
This commit is contained in:
parent
ee99ab15dd
commit
9c95e4b1f6
6 changed files with 262 additions and 56 deletions
54
scripts/createForgejoRelease.mjs
Normal file
54
scripts/createForgejoRelease.mjs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import axios from "axios";
|
||||
|
||||
const {
|
||||
TAG,
|
||||
FORGEJO_SERVER_URL: WEB_URL,
|
||||
FORGEJO_API_URL: API,
|
||||
FORGEJO_REPOSITORY: REPO,
|
||||
FORGEJO_TOKEN: TOKEN,
|
||||
CDN_URL,
|
||||
} = process.env;
|
||||
|
||||
async function addReleaseAsset(releaseID, name) {
|
||||
return axios.post(
|
||||
`${API}/repos/${REPO}/releases/${releaseID}/assets`,
|
||||
{ external_url: `${CDN_URL}/${REPO}/${TAG}/${name}`, },
|
||||
{
|
||||
headers: {
|
||||
Authorization: `token ${TOKEN}`,
|
||||
"Content-Type": `multipart/form-data`,
|
||||
},
|
||||
params: { name },
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
async function main() {
|
||||
|
||||
// Initial Release Data
|
||||
const release = await axios.post(
|
||||
`${API}/repos/${REPO}/releases`,
|
||||
{
|
||||
name: TAG,
|
||||
tag_name: TAG,
|
||||
draft: true,
|
||||
hide_archive_links: true,
|
||||
body: `<!-- Manifest URL: ${WEB_URL}/${REPO}/releases/download/${TAG}/system.json -->`,
|
||||
},
|
||||
{
|
||||
headers: { Authorization: `token ${TOKEN}` },
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
await addReleaseAsset(release.data.id, `release.zip`);
|
||||
await addReleaseAsset(release.data.id, `system.json`);
|
||||
} catch (e) {
|
||||
console.error(`Failed to add assets to the release`);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
console.log(`Release created`);
|
||||
};
|
||||
|
||||
main();
|
||||
Loading…
Add table
Add a link
Reference in a new issue