mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
ci: testing upload build script
This commit is contained in:
parent
fa273a13f2
commit
235045dec4
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@ -14,6 +14,14 @@ jobs:
|
|||||||
- name: Check out Git repository
|
- name: Check out Git repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20.18.0
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn
|
||||||
|
|
||||||
- name: Test Upload build
|
- name: Test Upload build
|
||||||
env:
|
env:
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
@ -24,14 +32,6 @@ jobs:
|
|||||||
BUILD_WEBHOOK_URL: ${{ secrets.BUILD_WEBHOOK_URL }}
|
BUILD_WEBHOOK_URL: ${{ secrets.BUILD_WEBHOOK_URL }}
|
||||||
run: node scripts/upload-build.cjs
|
run: node scripts/upload-build.cjs
|
||||||
|
|
||||||
- name: Install Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20.18.0
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn
|
|
||||||
|
|
||||||
- name: Install Python
|
- name: Install Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
|
10645
pnpm-lock.yaml
generated
Normal file
10645
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
49
scripts/postinstall.cjs
Normal file
49
scripts/postinstall.cjs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
const { default: axios } = require("axios");
|
||||||
|
const util = require("node:util");
|
||||||
|
const fs = require("node:fs");
|
||||||
|
const path = require("node:path");
|
||||||
|
|
||||||
|
const exec = util.promisify(require("node:child_process").exec);
|
||||||
|
|
||||||
|
const fileName = {
|
||||||
|
win32: "ludusavi-v0.25.0-win64.zip",
|
||||||
|
linux: "ludusavi-v0.25.0-linux.zip",
|
||||||
|
darwin: "ludusavi-v0.25.0-mac.zip",
|
||||||
|
};
|
||||||
|
|
||||||
|
const downloadLudusavi = async () => {
|
||||||
|
if (fs.existsSync("ludusavi")) {
|
||||||
|
console.log("Ludusavi already exists, skipping download...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const file = fileName[process.platform];
|
||||||
|
const downloadUrl = `https://github.com/mtkennerly/ludusavi/releases/download/v0.25.0/${file}`;
|
||||||
|
|
||||||
|
console.log(`Downloading ${file}...`);
|
||||||
|
|
||||||
|
const response = await axios.get(downloadUrl, { responseType: "stream" });
|
||||||
|
|
||||||
|
const stream = response.data.pipe(fs.createWriteStream(file));
|
||||||
|
|
||||||
|
stream.on("finish", async () => {
|
||||||
|
console.log(`Downloaded ${file}, extracting...`);
|
||||||
|
|
||||||
|
const pwd = process.cwd();
|
||||||
|
|
||||||
|
const targetPath = path.join(pwd, "ludusavi");
|
||||||
|
|
||||||
|
await exec(`npx extract-zip ${file} ${targetPath}`);
|
||||||
|
|
||||||
|
if (process.platform !== "win32") {
|
||||||
|
fs.chmodSync(path.join(targetPath, "ludusavi"), 0o755);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Extracted. Renaming folder...");
|
||||||
|
|
||||||
|
console.log(`Extracted ${file}, removing compressed downloaded file...`);
|
||||||
|
fs.rmSync(file);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
downloadLudusavi();
|
55
scripts/upload-build.cjs
Normal file
55
scripts/upload-build.cjs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
const fs = require("node:fs");
|
||||||
|
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");
|
||||||
|
const path = require("node:path");
|
||||||
|
const packageJson = require("../package.json");
|
||||||
|
|
||||||
|
const s3 = new S3Client({
|
||||||
|
region: "auto",
|
||||||
|
endpoint: process.env.S3_ENDPOINT,
|
||||||
|
forcePathStyle: true,
|
||||||
|
credentials: {
|
||||||
|
accessKeyId: process.env.S3_ACCESS_KEY,
|
||||||
|
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const dist = path.resolve(__dirname, "..", "dist");
|
||||||
|
|
||||||
|
const extensionsToUpload = [".deb", ".exe"];
|
||||||
|
|
||||||
|
fs.readdir(dist, async (err, files) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
const results = await Promise.all(
|
||||||
|
files.map(async (file) => {
|
||||||
|
if (extensionsToUpload.includes(path.extname(file))) {
|
||||||
|
const fileName = `${new Date().getTime()}-${file}`;
|
||||||
|
|
||||||
|
const command = new PutObjectCommand({
|
||||||
|
Bucket: process.env.S3_BUILDS_BUCKET_NAME,
|
||||||
|
Key: fileName,
|
||||||
|
Body: fs.createReadStream(path.resolve(dist, file)),
|
||||||
|
});
|
||||||
|
|
||||||
|
await s3.send(command);
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: `${process.env.S3_ENDPOINT}/${process.env.S3_BUILDS_BUCKET_NAME}/${fileName}`,
|
||||||
|
name: fileName,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await fetch(process.env.BUILD_WEBHOOK_URL, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
results,
|
||||||
|
branchName: process.env.BRANCH_NAME,
|
||||||
|
version: packageJson.version,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user