Add script to allow uploading the wiki artifact
This commit is contained in:
parent
97ca41c201
commit
dbfb3684b9
1 changed files with 43 additions and 0 deletions
43
src/addWikiArtifactToRelease.mjs
Normal file
43
src/addWikiArtifactToRelease.mjs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import axios from "axios";
|
||||
import { config } from "dotenv";
|
||||
import { assertEnvKey, addReleaseAsset } from "./utils.mjs";
|
||||
|
||||
config({ quiet: true });
|
||||
assertEnvKey("MANIFEST");
|
||||
assertEnvKey("TAG");
|
||||
assertEnvKey("FORGEJO_SERVER_URL");
|
||||
assertEnvKey("FORGEJO_API_URL");
|
||||
assertEnvKey("FORGEJO_REPOSITORY");
|
||||
assertEnvKey("FORGEJO_TOKEN");
|
||||
assertEnvKey("FORGEJO_REF_NAME");
|
||||
|
||||
const MANIFEST_FILE = process.env.MANIFEST;
|
||||
const MANIFEST_NAME = MANIFEST_FILE.split(`/`).at(-1);
|
||||
if (!MANIFEST_NAME) {
|
||||
console.error(`Failed to parse manifest name from: ${MANIFEST_FILE}`);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
const {
|
||||
TAG,
|
||||
FORGEJO_API_URL: API,
|
||||
FORGEJO_REPOSITORY: REPO,
|
||||
FORGEJO_TOKEN: TOKEN,
|
||||
} = process.env;
|
||||
|
||||
// Initial Release Data
|
||||
const release = await axios.get(
|
||||
`${API}/repos/${REPO}/releases/tags/${TAG}`,
|
||||
{
|
||||
headers: { Authorization: `token ${TOKEN}` },
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
await addReleaseAsset(release.data.upload_url, `wiki.zip`, `wiki.zip`);
|
||||
} catch (e) {
|
||||
console.error(`Failed to add asset to the release`);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
console.log(`Release created`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue