diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0811967b..b846293b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,6 @@ name: Build on: pull_request -env: - AWS_REGION: us-east-1 - jobs: build: strategy: @@ -17,6 +14,16 @@ jobs: - name: Check out Git repository uses: actions/checkout@v4 + - name: Test Upload build + env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} + S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} + S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} + S3_BUILDS_BUCKET_NAME: ${{ secrets.S3_BUILDS_BUCKET_NAME }} + BUILD_WEBHOOK_URL: ${{ secrets.BUILD_WEBHOOK_URL }} + run: node scripts/upload-build.cjs + - name: Install Node.js uses: actions/setup-node@v4 with: diff --git a/package.json b/package.json index 7d17cd91..74c25f56 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "start": "electron-vite preview", "dev": "electron-vite dev", "build": "npm run typecheck && electron-vite build", - "postinstall": "electron-builder install-app-deps && node ./postinstall.cjs", + "postinstall": "electron-builder install-app-deps && node ./scripts/postinstall.cjs", "build:unpack": "npm run build && electron-builder --dir", "build:win": "electron-vite build && electron-builder --win", "build:mac": "electron-vite build && electron-builder --mac", @@ -78,6 +78,7 @@ "zod": "^3.23.8" }, "devDependencies": { + "@aws-sdk/client-s3": "^3.705.0", "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.5.0", "@electron-toolkit/eslint-config-prettier": "^2.0.0", diff --git a/postinstall.cjs b/postinstall.cjs deleted file mode 100644 index 25d27c0a..00000000 --- a/postinstall.cjs +++ /dev/null @@ -1,49 +0,0 @@ -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();