diff --git a/docker-scripts.js b/docker-scripts.js new file mode 100644 index 0000000..958ca75 --- /dev/null +++ b/docker-scripts.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node +import { execSync } from "child_process"; +import packageJson from "./package.json" with { type: "json" }; + +const version = packageJson.version; +const command = process.argv[2]; + +const cmds = { + build: `docker build --platform linux/amd64 -t gaming-music-bot:${version} -t gaming-music-bot:latest .`, + save: `docker save gaming-music-bot:${version} -o music-discord-bot-${version}.tar`, +}; + +if (!cmds[command]) { + console.error(`Unknown command: ${command}. Use 'build' or 'save'.`); + process.exit(1); +} + +console.log(`Running: ${cmds[command]}`); +execSync(cmds[command], { stdio: "inherit" }); diff --git a/package-lock.json b/package-lock.json index 084daab..6f0eaf1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "typescript": "5.9.3" }, "engines": { - "node": ">=18.x" + "node": ">=20.x" } }, "node_modules/@bufbuild/protobuf": { diff --git a/package.json b/package.json index 16b3edd..eaacbbf 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,14 @@ "main": "index.js", "type": "module", "engines": { - "node": ">=18.x" + "node": ">=20.x" }, "scripts": { "dev": "tsx watch src/index.ts", "start": "node dist/index.js", "build": "tsup src/index.ts --format esm --minify --external unfetch,ffmpeg-static", - "docker-build": "VERSION=$(node -p \"require('./package.json').version\") && docker build --platform linux/amd64 -t gaming-music-bot:$VERSION -t gaming-music-bot:latest .", - "docker-save": "VERSION=$(node -p \"require('./package.json').version\") && docker save gaming-music-bot:$VERSION -o music-discord-bot-$VERSION.tar", + "docker-build": "node docker-scripts.js build", + "docker-save": "node docker-scripts.js save", "build-prod": "npm run build && npm run docker-build && npm run docker-save", "release:patch": "npm version patch && npm run build-prod", "release:minor": "npm version minor && npm run build-prod",