From fcc8d8881aa338c5011f1173ad2d16efa13591c3 Mon Sep 17 00:00:00 2001 From: MarcoCoreDuo <90222533+MarcoCoreDuo@users.noreply.github.com> Date: Thu, 18 Jul 2024 06:32:16 +0200 Subject: [PATCH 01/47] Switch to Distube's ytdl-core fork (resolves playback issue) (#1042) --- .github/workflows/lint.yml | 2 +- .github/workflows/type-check.yml | 2 +- CHANGELOG.md | 1 + Dockerfile | 3 +- README.md | 2 +- package.json | 4 +- patches/ytdl-core+4.11.5.patch | 172 ------------------------------- src/services/player.ts | 4 +- yarn.lock | 105 ++++++++++++++++--- 9 files changed, 100 insertions(+), 195 deletions(-) delete mode 100644 patches/ytdl-core+4.11.5.patch diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1ce6166..fffe189 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-node@v2 with: - node-version: '16' + node-version: '18' cache: 'yarn' - name: Install dependencies run: yarn install diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml index b4c765a..ac61d5b 100644 --- a/.github/workflows/type-check.yml +++ b/.github/workflows/type-check.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-node@v2 with: - node-version: '16' + node-version: '18' cache: 'yarn' - name: Install dependencies run: yarn install diff --git a/CHANGELOG.md b/CHANGELOG.md index 40a9e87..0071efd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed +- Fixed playback issue - Audioplayer not stopping properly ## [2.8.1] - 2024-04-28 diff --git a/Dockerfile b/Dockerfile index dc21173..6541a2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18.7.0-slim AS base +FROM node:18-bullseye-slim AS base # openssl will be a required package if base is updated to 18.16+ due to node:*-slim base distro change # https://github.com/prisma/prisma/issues/19729#issuecomment-1591270599 @@ -19,7 +19,6 @@ FROM base AS dependencies WORKDIR /usr/app COPY package.json . -COPY patches ./patches COPY yarn.lock . RUN yarn install --prod diff --git a/README.md b/README.md index e4f1f25..ac85050 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ services: ### Node.js **Prerequisites**: -* Node.js (16.x is recommended because it's the current LTS version) +* Node.js (18.17.0 or later is required and latest 18.x.x LTS is recommended) * ffmpeg (4.1 or later) 1. `git clone https://github.com/codetheweb/muse.git && cd muse` diff --git a/package.json b/package.json index 6a80e0a..cdb7452 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "types": "dts/types", "type": "module", "engines": { - "node": ">=16.0.0" + "node": ">=18.17.0" }, "files": [ "src" @@ -89,6 +89,7 @@ "@discordjs/opus": "^0.8.0", "@discordjs/rest": "1.0.1", "@discordjs/voice": "0.11.0", + "@distube/ytdl-core": "^4.13.5", "@prisma/client": "4.16.0", "@types/libsodium-wrappers": "^0.7.9", "array-shuffle": "^3.0.0", @@ -126,7 +127,6 @@ "sync-fetch": "^0.3.1", "tsx": "3.8.2", "xbytes": "^1.7.0", - "ytdl-core": "^4.11.5", "ytsr": "^3.8.4" }, "resolutions": { diff --git a/patches/ytdl-core+4.11.5.patch b/patches/ytdl-core+4.11.5.patch deleted file mode 100644 index 7d3abf3..0000000 --- a/patches/ytdl-core+4.11.5.patch +++ /dev/null @@ -1,172 +0,0 @@ -diff --git a/node_modules/ytdl-core/lib/sig.js b/node_modules/ytdl-core/lib/sig.js -index eb7bfaa..b2eee87 100644 ---- a/node_modules/ytdl-core/lib/sig.js -+++ b/node_modules/ytdl-core/lib/sig.js -@@ -3,6 +3,9 @@ const Cache = require('./cache'); - const utils = require('./utils'); - const vm = require('vm'); - -+ -+let nTransformWarning = false; -+ - // A shared cache to keep track of html5player js functions. - exports.cache = new Cache(); - -@@ -23,6 +26,49 @@ exports.getFunctions = (html5playerfile, options) => exports.cache.getOrSet(html - return functions; - }); - -+// eslint-disable-next-line max-len -+// https://github.com/TeamNewPipe/NewPipeExtractor/blob/41c8dce452aad278420715c00810b1fed0109adf/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java#L816 -+const DECIPHER_REGEXPS = [ -+ '(?:\\b|[^a-zA-Z0-9$])([a-zA-Z0-9$]{2,})\\s*=\\s*function\\(\\s*a\\s*\\)' + -+ '\\s*\\{\\s*a\\s*=\\s*a\\.split\\(\\s*""\\s*\\)', -+ '\\bm=([a-zA-Z0-9$]{2,})\\(decodeURIComponent\\(h\\.s\\)\\)', -+ '\\bc&&\\(c=([a-zA-Z0-9$]{2,})\\(decodeURIComponent\\(c\\)\\)', -+ '([\\w$]+)\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(""\\)\\s*;', -+ '\\b([\\w$]{2,})\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(""\\)\\s*;', -+ '\\bc\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\(', -+]; -+ -+const DECIPHER_ARGUMENT = 'sig'; -+const N_ARGUMENT = 'ncode'; -+ -+const matchGroup1 = (regex, str) => { -+ const match = str.match(new RegExp(regex)); -+ if (!match) throw new Error(`Could not match ${regex}`); -+ return match[1]; -+}; -+ -+const getFuncName = (body, regexps) => { -+ try { -+ let fn; -+ for (const regex of regexps) { -+ try { -+ fn = matchGroup1(regex, body); -+ const idx = fn.indexOf('[0]'); -+ if (idx > -1) fn = matchGroup1(`${fn.slice(0, 3)}=\\[([a-zA-Z0-9$\\[\\]]{2,})\\]`, body); -+ } catch (err) { -+ continue; -+ } -+ } -+ if (!fn || fn.includes('[')) throw Error("Couldn't find fn name"); -+ return fn; -+ } catch (e) { -+ throw Error(`Please open an issue on ytdl-core GitHub: ${e.message}`); -+ } -+}; -+ -+const getDecipherFuncName = body => getFuncName(body, DECIPHER_REGEXPS); -+ -+ - /** - * Extracts the actions that should be taken to decipher a signature - * and tranform the n parameter -@@ -31,44 +77,45 @@ exports.getFunctions = (html5playerfile, options) => exports.cache.getOrSet(html - * @returns {Array.} - */ - exports.extractFunctions = body => { -+ body = body.replace(/\n|\r/g, ''); - const functions = []; -- const extractManipulations = caller => { -- const functionName = utils.between(caller, `a=a.split("");`, `.`); -- if (!functionName) return ''; -- const functionStart = `var ${functionName}={`; -- const ndx = body.indexOf(functionStart); -- if (ndx < 0) return ''; -- const subBody = body.slice(ndx + functionStart.length - 1); -- return `var ${functionName}=${utils.cutAfterJS(subBody)}`; -- }; -+ // This is required function, so we can't continue if it's not found. - const extractDecipher = () => { -- const functionName = utils.between(body, `a.set("alr","yes");c&&(c=`, `(decodeURIC`); -- if (functionName && functionName.length) { -- const functionStart = `${functionName}=function(a)`; -- const ndx = body.indexOf(functionStart); -- if (ndx >= 0) { -- const subBody = body.slice(ndx + functionStart.length); -- let functionBody = `var ${functionStart}${utils.cutAfterJS(subBody)}`; -- functionBody = `${extractManipulations(functionBody)};${functionBody};${functionName}(sig);`; -- functions.push(functionBody); -- } -+ const decipherFuncName = getDecipherFuncName(body); -+ try { -+ const functionPattern = `(${decipherFuncName.replace(/\$/g, '\\$')}=function\\([a-zA-Z0-9_]+\\)\\{.+?\\})`; -+ const decipherFunction = `var ${matchGroup1(functionPattern, body)};`; -+ const helperObjectName = matchGroup1(';([A-Za-z0-9_\\$]{2,})\\.\\w+\\(', decipherFunction) -+ .replace(/\$/g, '\\$'); -+ const helperPattern = `(var ${helperObjectName}=\\{[\\s\\S]+?\\}\\};)`; -+ const helperObject = matchGroup1(helperPattern, body); -+ const callerFunction = `${decipherFuncName}(${DECIPHER_ARGUMENT});`; -+ const resultFunction = helperObject + decipherFunction + callerFunction; -+ functions.push(resultFunction); -+ } catch (err) { -+ throw Error(`Could not parse decipher function: ${err}`); - } - }; -- const extractNCode = () => { -- let functionName = utils.between(body, `&&(b=a.get("n"))&&(b=`, `(b)`); -- if (functionName.includes('[')) functionName = utils.between(body, `var ${functionName.split('[')[0]}=[`, `]`); -- if (functionName && functionName.length) { -- const functionStart = `${functionName}=function(a)`; -- const ndx = body.indexOf(functionStart); -- if (ndx >= 0) { -- const subBody = body.slice(ndx + functionStart.length); -- const functionBody = `var ${functionStart}${utils.cutAfterJS(subBody)};${functionName}(ncode);`; -- functions.push(functionBody); -+ // This is optional, so we can continue if it's not found, but it will bottleneck the download. -+ const extractNTransform = () => { -+ let nFuncName = utils.between(body, `(b=a.get("n"))&&(b=`, `(b)`); -+ if (nFuncName.includes('[')) nFuncName = utils.between(body, `${nFuncName.split('[')[0]}=[`, `]`); -+ if (nFuncName && nFuncName.length) { -+ const nBegin = `${nFuncName}=function(a)`; -+ const nEnd = '.join("")};'; -+ const nFunction = utils.between(body, nBegin, nEnd); -+ if (nFunction) { -+ const callerFunction = `${nFuncName}(${N_ARGUMENT});`; -+ const resultFunction = nBegin + nFunction + nEnd + callerFunction; -+ functions.push(resultFunction); -+ } else if (!nTransformWarning) { -+ console.warn('Could not parse n transform function, please report it on @distube/ytdl-core GitHub.'); -+ nTransformWarning = true; - } - } - }; - extractDecipher(); -- extractNCode(); -+ extractNTransform(); - return functions; - }; - -@@ -82,22 +129,25 @@ exports.extractFunctions = body => { - exports.setDownloadURL = (format, decipherScript, nTransformScript) => { - const decipher = url => { - const args = querystring.parse(url); -- if (!args.s || !decipherScript) return args.url; -+ if (!args.s) return args.url; - const components = new URL(decodeURIComponent(args.url)); -- components.searchParams.set(args.sp ? args.sp : 'signature', -- decipherScript.runInNewContext({ sig: decodeURIComponent(args.s) })); -+ const context = {}; -+ context[DECIPHER_ARGUMENT] = decodeURIComponent(args.s); -+ components.searchParams.set(args.sp || 'sig', decipherScript.runInNewContext(context)); - return components.toString(); - }; -- const ncode = url => { -+ const nTransform = url => { - const components = new URL(decodeURIComponent(url)); - const n = components.searchParams.get('n'); - if (!n || !nTransformScript) return url; -- components.searchParams.set('n', nTransformScript.runInNewContext({ ncode: n })); -+ const context = {}; -+ context[N_ARGUMENT] = n; -+ components.searchParams.set('n', nTransformScript.runInNewContext(context)); - return components.toString(); - }; - const cipher = !format.url; - const url = format.url || format.signatureCipher || format.cipher; -- format.url = cipher ? ncode(decipher(url)) : ncode(url); -+ format.url = cipher ? nTransform(decipher(url)) : nTransform(url); - delete format.signatureCipher; - delete format.cipher; - }; diff --git a/src/services/player.ts b/src/services/player.ts index 0da80a4..5e284a6 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -1,7 +1,7 @@ import {VoiceChannel, Snowflake} from 'discord.js'; import {Readable} from 'stream'; import hasha from 'hasha'; -import ytdl, {videoFormat} from 'ytdl-core'; +import ytdl, {videoFormat} from '@distube/ytdl-core'; import {WriteStream} from 'fs-capacitor'; import ffmpeg from 'fluent-ffmpeg'; import shuffle from 'array-shuffle'; @@ -280,8 +280,8 @@ export default class { if (this.getCurrent() && this.status !== STATUS.PAUSED) { await this.play(); } else { - this.audioPlayer?.stop(true); this.status = STATUS.IDLE; + this.audioPlayer?.stop(true); const settings = await getGuildSettings(this.guildId); diff --git a/yarn.lock b/yarn.lock index 2cebf90..abf2426 100644 --- a/yarn.lock +++ b/yarn.lock @@ -152,6 +152,18 @@ tslib "^2.5.0" ws "^8.13.0" +"@distube/ytdl-core@^4.13.5": + version "4.13.5" + resolved "https://registry.yarnpkg.com/@distube/ytdl-core/-/ytdl-core-4.13.5.tgz#f9bacaa43225953d0ccd2a682a31d9dbbc378973" + integrity sha512-g+4UJIR/auAJbia7iB0aWvaJDbs22P53NySWa47b1NT4xMTDJYguxHFArPrvRkcJrb/AgKjv/XoSZGghpL0CJA== + dependencies: + http-cookie-agent "^6.0.5" + m3u8stream "^0.8.6" + miniget "^4.2.3" + sax "^1.4.1" + tough-cookie "^4.1.4" + undici "^6.19.2" + "@esbuild-kit/cjs-loader@^2.3.3": version "2.3.3" resolved "https://registry.npmjs.org/@esbuild-kit/cjs-loader/-/cjs-loader-2.3.3.tgz" @@ -673,6 +685,13 @@ agent-base@6, agent-base@^6.0.0, agent-base@^6.0.2: dependencies: debug "4" +agent-base@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317" + integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== + dependencies: + debug "^4.3.4" + ajv@^6.10.0, ajv@^6.12.4: version "6.12.6" resolved "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz" @@ -1290,6 +1309,13 @@ debug@^3.2.7: dependencies: ms "^2.1.1" +debug@^4.3.4: + version "4.3.5" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" + integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== + dependencies: + ms "2.1.2" + decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz" @@ -2584,6 +2610,13 @@ http-cache-semantics@^4.0.0: resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz" integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== +http-cookie-agent@^6.0.5: + version "6.0.5" + resolved "https://registry.yarnpkg.com/http-cookie-agent/-/http-cookie-agent-6.0.5.tgz#23b490439464424a689d80ea7f3a560a4a893ab8" + integrity sha512-sfZ8fDgDP3B1YB+teqSnAK1aPgBu8reUUGxSsndP2XnYN6cM29EURXWXZqQQiaRdor3B4QjpkUNfv21syaO4DA== + dependencies: + agent-base "^7.1.1" + http-errors@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz" @@ -3310,7 +3343,7 @@ lru-cache@^6.0.0: m3u8stream@^0.8.6: version "0.8.6" - resolved "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.8.6.tgz" + resolved "https://registry.yarnpkg.com/m3u8stream/-/m3u8stream-0.8.6.tgz#0d6de4ce8ee69731734e6b616e7b05dd9d9a55b1" integrity sha512-LZj8kIVf9KCphiHmH7sbFQTVe4tOemb202fWwvJwR9W5ENW/1hxJN6ksAWGhQgSBSa3jyWhnjKU1Fw1GaOdbyA== dependencies: miniget "^4.2.2" @@ -3393,6 +3426,11 @@ miniget@^4.2.2: resolved "https://registry.npmjs.org/miniget/-/miniget-4.2.2.tgz" integrity sha512-a7voNL1N5lDMxvTMExOkg+Fq89jM2vY8pAi9ZEWzZtfNmdfP6RXkvUtFnCAXoCv2T9k1v/fUJVaAEuepGcvLYA== +miniget@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/miniget/-/miniget-4.2.3.tgz#3707a24c7c11c25d359473291638ab28aab349bd" + integrity sha512-SjbDPDICJ1zT+ZvQwK0hUcRY4wxlhhNpHL9nJOB2MEAXRGagTljsO8MEDzQMTFf0Q8g4QNi8P9lEm/g7e+qgzA== + minimatch@^3.0.4, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" @@ -3996,6 +4034,11 @@ proxy-from-env@^1.0.0, proxy-from-env@^1.1.0: resolved "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== +psl@^1.1.33: + version "1.9.0" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" + integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== + pump@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz" @@ -4009,6 +4052,11 @@ punycode@^2.1.0: resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== +punycode@^2.1.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + pupa@^2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/pupa/-/pupa-2.1.1.tgz" @@ -4033,6 +4081,11 @@ query-string@^6.13.8: split-on-first "^1.0.0" strict-uri-encode "^2.0.0" +querystringify@^2.1.1: + version "2.2.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" + integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== + queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz" @@ -4182,6 +4235,11 @@ require-from-string@^2.0.2: resolved "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz" integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== +requires-port@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== + resolve-alpn@^1.2.0: version "1.2.1" resolved "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz" @@ -4317,10 +4375,10 @@ safe-regex-test@^1.0.3: resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -sax@^1.1.3, sax@^1.2.4: - version "1.2.4" - resolved "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz" - integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== +sax@^1.2.4, sax@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f" + integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg== semver-compare@^1.0.0: version "1.0.0" @@ -4780,6 +4838,16 @@ token-types@^5.0.0-alpha.2, token-types@^5.0.1: "@tokenizer/token" "^0.3.0" ieee754 "^1.2.1" +tough-cookie@^4.1.4: + version "4.1.4" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.4.tgz#945f1461b45b5a8c76821c33ea49c3ac192c1b36" + integrity sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag== + dependencies: + psl "^1.1.33" + punycode "^2.1.1" + universalify "^0.2.0" + url-parse "^1.5.3" + tr46@~0.0.3: version "0.0.3" resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz" @@ -4955,6 +5023,11 @@ undici@^5.8.0: resolved "https://registry.npmjs.org/undici/-/undici-5.8.1.tgz" integrity sha512-iDRmWX4Zar/4A/t+1LrKQRm102zw2l9Wgat3LtTlTn8ykvMZmAmpq9tjyHEigx18FsY7IfATvyN3xSw9BDz0eA== +undici@^6.19.2: + version "6.19.2" + resolved "https://registry.yarnpkg.com/undici/-/undici-6.19.2.tgz#231bc5de78d0dafb6260cf454b294576c2f3cd31" + integrity sha512-JfjKqIauur3Q6biAtHJ564e3bWa8VvT+7cSiOJHFbX4Erv6CLGDpg8z+Fmg/1OI/47RA+GI2QZaF48SSaLvyBA== + unique-string@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz" @@ -4972,6 +5045,11 @@ universalify@^0.1.0: resolved "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== +universalify@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0" + integrity sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg== + universalify@^2.0.0: version "2.0.1" resolved "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz" @@ -5021,6 +5099,14 @@ url-parse-lax@^3.0.0: dependencies: prepend-http "^2.0.0" +url-parse@^1.5.3: + version "1.5.10" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1" + integrity sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ== + dependencies: + querystringify "^2.1.1" + requires-port "^1.0.0" + util-deprecate@^1.0.1: version "1.0.2" resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" @@ -5228,15 +5314,6 @@ yocto-queue@^1.0.0: resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz" integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g== -ytdl-core@^4.11.5: - version "4.11.5" - resolved "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.11.5.tgz" - integrity sha512-27LwsW4n4nyNviRCO1hmr8Wr5J1wLLMawHCQvH8Fk0hiRqrxuIu028WzbJetiYH28K8XDbeinYW4/wcHQD1EXA== - dependencies: - m3u8stream "^0.8.6" - miniget "^4.2.2" - sax "^1.1.3" - ytsr@^3.8.4: version "3.8.4" resolved "https://registry.npmjs.org/ytsr/-/ytsr-3.8.4.tgz" From 62b1abcba04c776f2a7f8c53478bf4be47011516 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Thu, 18 Jul 2024 00:43:26 -0400 Subject: [PATCH 02/47] Switch from node-ytsr to Distube's fork (#1024) Co-authored-by: Max Isom --- package.json | 1 + src/services/youtube-api.ts | 2 +- yarn.lock | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cdb7452..804d145 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "@discordjs/opus": "^0.8.0", "@discordjs/rest": "1.0.1", "@discordjs/voice": "0.11.0", + "@distube/ytsr": "^2.0.0", "@distube/ytdl-core": "^4.13.5", "@prisma/client": "4.16.0", "@types/libsodium-wrappers": "^0.7.9", diff --git a/src/services/youtube-api.ts b/src/services/youtube-api.ts index b7d68b9..143033a 100644 --- a/src/services/youtube-api.ts +++ b/src/services/youtube-api.ts @@ -1,7 +1,7 @@ import {inject, injectable} from 'inversify'; import {toSeconds, parse} from 'iso8601-duration'; import got, {Got} from 'got'; -import ytsr, {Video} from 'ytsr'; +import ytsr, {Video} from '@distube/ytsr'; import PQueue from 'p-queue'; import {SongMetadata, QueuedPlaylist, MediaSource} from './player.js'; import {TYPES} from '../types.js'; diff --git a/yarn.lock b/yarn.lock index abf2426..c8b1cf2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -164,6 +164,13 @@ tough-cookie "^4.1.4" undici "^6.19.2" +"@distube/ytsr@^2.0.0": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@distube/ytsr/-/ytsr-2.0.4.tgz#873b7ca767b5ff362bc0e136ae0d9ca5cbde8f7b" + integrity sha512-OiSWgARQ9LTj+dXt3jmMFzUH4l86VVCD4dVC4hEHNXdqp+DyU4QEzc+W6YY6//kWkvzTaUxOo7JUY7lBzwIF0A== + dependencies: + undici "^6.18.2" + "@esbuild-kit/cjs-loader@^2.3.3": version "2.3.3" resolved "https://registry.npmjs.org/@esbuild-kit/cjs-loader/-/cjs-loader-2.3.3.tgz" @@ -5023,7 +5030,7 @@ undici@^5.8.0: resolved "https://registry.npmjs.org/undici/-/undici-5.8.1.tgz" integrity sha512-iDRmWX4Zar/4A/t+1LrKQRm102zw2l9Wgat3LtTlTn8ykvMZmAmpq9tjyHEigx18FsY7IfATvyN3xSw9BDz0eA== -undici@^6.19.2: +undici@^6.18.2, undici@^6.19.2: version "6.19.2" resolved "https://registry.yarnpkg.com/undici/-/undici-6.19.2.tgz#231bc5de78d0dafb6260cf454b294576c2f3cd31" integrity sha512-JfjKqIauur3Q6biAtHJ564e3bWa8VvT+7cSiOJHFbX4Erv6CLGDpg8z+Fmg/1OI/47RA+GI2QZaF48SSaLvyBA== From d7261260a3eb6bbe8f5af50dda215ef7b501a8ab Mon Sep 17 00:00:00 2001 From: MintyFreshers Date: Thu, 18 Jul 2024 05:47:01 +0100 Subject: [PATCH 03/47] Added skip currently playing track option into the /play options. (#1046) Co-authored-by: Max Isom --- CHANGELOG.md | 3 +++ src/commands/favorites.ts | 6 +++++- src/commands/play.ts | 6 +++++- src/services/add-query-to-queue.ts | 14 ++++++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0071efd..37e6e32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- A `skip` option to the `/play` command + ### Fixed - Fixed playback issue - Audioplayer not stopping properly diff --git a/src/commands/favorites.ts b/src/commands/favorites.ts index f00c96f..d635826 100644 --- a/src/commands/favorites.ts +++ b/src/commands/favorites.ts @@ -28,7 +28,10 @@ export default class implements Command { .setDescription('shuffle the input if you\'re adding multiple tracks')) .addBooleanOption(option => option .setName('split') - .setDescription('if a track has chapters, split it'))) + .setDescription('if a track has chapters, split it')) + .addBooleanOption(option => option + .setName('skip') + .setDescription('skip the currently playing track'))) .addSubcommand(subcommand => subcommand .setName('list') .setDescription('list all favorites')) @@ -124,6 +127,7 @@ export default class implements Command { shuffleAdditions: interaction.options.getBoolean('shuffle') ?? false, addToFrontOfQueue: interaction.options.getBoolean('immediate') ?? false, shouldSplitChapters: interaction.options.getBoolean('split') ?? false, + skipCurrentTrack: interaction.options.getBoolean('skip') ?? false, }); } diff --git a/src/commands/play.ts b/src/commands/play.ts index 65f28d4..25aef1c 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -29,7 +29,10 @@ export default class implements Command { .setDescription('shuffle the input if you\'re adding multiple tracks')) .addBooleanOption(option => option .setName('split') - .setDescription('if a track has chapters, split it')); + .setDescription('if a track has chapters, split it')) + .addBooleanOption(option => option + .setName('skip') + .setDescription('skip the currently playing track')); public requiresVC = true; @@ -52,6 +55,7 @@ export default class implements Command { addToFrontOfQueue: interaction.options.getBoolean('immediate') ?? false, shuffleAdditions: interaction.options.getBoolean('shuffle') ?? false, shouldSplitChapters: interaction.options.getBoolean('split') ?? false, + skipCurrentTrack: interaction.options.getBoolean('skip') ?? false, }); } diff --git a/src/services/add-query-to-queue.ts b/src/services/add-query-to-queue.ts index 2b84b63..401ad90 100644 --- a/src/services/add-query-to-queue.ts +++ b/src/services/add-query-to-queue.ts @@ -38,12 +38,14 @@ export default class AddQueryToQueue { addToFrontOfQueue, shuffleAdditions, shouldSplitChapters, + skipCurrentTrack, interaction, }: { query: string; addToFrontOfQueue: boolean; shuffleAdditions: boolean; shouldSplitChapters: boolean; + skipCurrentTrack: boolean; interaction: ChatInputCommandInteraction; }): Promise { const guildId = interaction.guild!.id; @@ -169,6 +171,14 @@ export default class AddQueryToQueue { await player.play(); } + if (skipCurrentTrack) { + try { + await player.forward(1); + } catch (_: unknown) { + throw new Error('no song to skip to'); + } + } + // Build response message if (statusMsg !== '') { if (extraMsg === '') { @@ -183,9 +193,9 @@ export default class AddQueryToQueue { } if (newSongs.length === 1) { - await interaction.editReply(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${extraMsg}`); + await interaction.editReply(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${skipCurrentTrack ? 'and current track skipped' : ''}${extraMsg}`); } else { - await interaction.editReply(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`); + await interaction.editReply(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${skipCurrentTrack ? 'and current track skipped' : ''}${extraMsg}`); } } From 94c24263ba58057e3fa4023339541aae0fc2487b Mon Sep 17 00:00:00 2001 From: Max Isom Date: Wed, 17 Jul 2024 21:48:07 -0700 Subject: [PATCH 04/47] Release 2.9.0 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37e6e32..2d98c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.9.0] - 2024-07-17 + ### Added - A `skip` option to the `/play` command @@ -315,7 +317,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[unreleased]: https://github.com/codetheweb/muse/compare/v2.8.1...HEAD +[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.0...HEAD +[2.9.0]: https://github.com/codetheweb/muse/compare/v2.8.1...v2.9.0 [2.8.1]: https://github.com/codetheweb/muse/compare/v2.8.0...v2.8.1 [2.8.0]: https://github.com/codetheweb/muse/compare/v2.7.1...v2.8.0 [2.7.1]: https://github.com/codetheweb/muse/compare/v2.7.0...v2.7.1 diff --git a/package.json b/package.json index 804d145..bc84a18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muse", - "version": "2.8.1", + "version": "2.9.0", "description": "🎧 a self-hosted Discord music bot that doesn't suck ", "repository": "git@github.com:codetheweb/muse.git", "author": "Max Isom ", From 0a82d6908b0f2346130942880bda24c0b7ef90b8 Mon Sep 17 00:00:00 2001 From: Bobby <30593201+luciferreeves@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:57:05 -0400 Subject: [PATCH 05/47] Updated ytdl-core (#1053) --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index bc84a18..10b3896 100644 --- a/package.json +++ b/package.json @@ -89,8 +89,8 @@ "@discordjs/opus": "^0.8.0", "@discordjs/rest": "1.0.1", "@discordjs/voice": "0.11.0", + "@distube/ytdl-core": "^4.13.7", "@distube/ytsr": "^2.0.0", - "@distube/ytdl-core": "^4.13.5", "@prisma/client": "4.16.0", "@types/libsodium-wrappers": "^0.7.9", "array-shuffle": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index c8b1cf2..5fa5f69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -152,10 +152,10 @@ tslib "^2.5.0" ws "^8.13.0" -"@distube/ytdl-core@^4.13.5": - version "4.13.5" - resolved "https://registry.yarnpkg.com/@distube/ytdl-core/-/ytdl-core-4.13.5.tgz#f9bacaa43225953d0ccd2a682a31d9dbbc378973" - integrity sha512-g+4UJIR/auAJbia7iB0aWvaJDbs22P53NySWa47b1NT4xMTDJYguxHFArPrvRkcJrb/AgKjv/XoSZGghpL0CJA== +"@distube/ytdl-core@^4.13.7": + version "4.13.7" + resolved "https://registry.yarnpkg.com/@distube/ytdl-core/-/ytdl-core-4.13.7.tgz#4b48e009eb8df6ea21623c18999a4dd76d893fbf" + integrity sha512-xpovwZVPwQ0R4Mrwt/fhh1rqmBjiZ5qj30ck5kz+mQJ5XPzW9dUiTDz89qCxO3YvgbCAqaC5BNNnWiFC2uCV5Q== dependencies: http-cookie-agent "^6.0.5" m3u8stream "^0.8.6" From 8ad0558da356a9413127738cf9a58003865ed05a Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 4 Aug 2024 11:57:59 -0700 Subject: [PATCH 06/47] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d98c8a..7b5a452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- bumped ytdl-core + ## [2.9.0] - 2024-07-17 ### Added From 938a2b19c1d183715416eb58c306c1c35e133006 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 4 Aug 2024 11:58:13 -0700 Subject: [PATCH 07/47] Release 2.9.1 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b5a452..783217a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.9.1] - 2024-08-04 + ### Fixed - bumped ytdl-core @@ -321,7 +323,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.0...HEAD +[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.1...HEAD +[2.9.1]: https://github.com/codetheweb/muse/compare/v2.9.0...v2.9.1 [2.9.0]: https://github.com/codetheweb/muse/compare/v2.8.1...v2.9.0 [2.8.1]: https://github.com/codetheweb/muse/compare/v2.8.0...v2.8.1 [2.8.0]: https://github.com/codetheweb/muse/compare/v2.7.1...v2.8.0 diff --git a/package.json b/package.json index 10b3896..ae5aecf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muse", - "version": "2.9.0", + "version": "2.9.1", "description": "🎧 a self-hosted Discord music bot that doesn't suck ", "repository": "git@github.com:codetheweb/muse.git", "author": "Max Isom ", From 62c954943d275d004e1c1a65ba372421f0fad345 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 11 Aug 2024 21:07:30 -0700 Subject: [PATCH 08/47] Add looking for maintainers --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac85050..0538183 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

-🚨: v1.0.0 was a breaking change. Please take a look at the [release notes](https://github.com/codetheweb/muse/releases/tag/v1.0.0) for upgrade instructions +**🔎 I'm currently looking for maintainers.** Check out [this issue](https://github.com/codetheweb/muse/issues/1063) for details. ------ From b5a8a4e5a29df772af4ecd06f979631b7d1d49e2 Mon Sep 17 00:00:00 2001 From: Michael <13820335+shiftybitshiftr@users.noreply.github.com> Date: Thu, 15 Aug 2024 23:20:56 -0700 Subject: [PATCH 09/47] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ae5aecf..4515e6b 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "@discordjs/opus": "^0.8.0", "@discordjs/rest": "1.0.1", "@discordjs/voice": "0.11.0", - "@distube/ytdl-core": "^4.13.7", + "@distube/ytdl-core": "^4.14.4", "@distube/ytsr": "^2.0.0", "@prisma/client": "4.16.0", "@types/libsodium-wrappers": "^0.7.9", From 5812a8bf0aeaf2537adae2e54f7b8e6be82731f2 Mon Sep 17 00:00:00 2001 From: Michael <13820335+shiftybitshiftr@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:04:10 -0700 Subject: [PATCH 10/47] Update yarn.lock --- yarn.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5fa5f69..8ecb57c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -152,17 +152,17 @@ tslib "^2.5.0" ws "^8.13.0" -"@distube/ytdl-core@^4.13.7": - version "4.13.7" - resolved "https://registry.yarnpkg.com/@distube/ytdl-core/-/ytdl-core-4.13.7.tgz#4b48e009eb8df6ea21623c18999a4dd76d893fbf" - integrity sha512-xpovwZVPwQ0R4Mrwt/fhh1rqmBjiZ5qj30ck5kz+mQJ5XPzW9dUiTDz89qCxO3YvgbCAqaC5BNNnWiFC2uCV5Q== +"@distube/ytdl-core@^4.14.4": + version "4.14.4" + resolved "https://registry.npmjs.org/@distube/ytdl-core/-/ytdl-core-4.14.4.tgz" + integrity sha512-dHb4GW3qATIjRsS6VIhm3Pop7FdUcDFhsnyQlsPeXW7UhTPuNS0BmraKiTpFbpp0Ky+rxBQjJBfPRFsM+dT1fg== dependencies: http-cookie-agent "^6.0.5" m3u8stream "^0.8.6" miniget "^4.2.3" sax "^1.4.1" tough-cookie "^4.1.4" - undici "^6.19.2" + undici five "@distube/ytsr@^2.0.0": version "2.0.4" From ee6a2a088497f6cce3551a43a3ec0a9d47274b96 Mon Sep 17 00:00:00 2001 From: Michael <13820335+shiftybitshiftr@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:06:41 -0700 Subject: [PATCH 11/47] Update yarn.lock --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 8ecb57c..72db2cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -162,7 +162,7 @@ miniget "^4.2.3" sax "^1.4.1" tough-cookie "^4.1.4" - undici five + undici "^6.19.2" "@distube/ytsr@^2.0.0": version "2.0.4" From 5bf5547cd1fc7cc90a2e34e1c569d91bff47da51 Mon Sep 17 00:00:00 2001 From: Michael <13820335+shiftybitshiftr@users.noreply.github.com> Date: Fri, 16 Aug 2024 22:47:48 -0700 Subject: [PATCH 12/47] update discordjs/voice --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 4515e6b..092dc6f 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "@discordjs/builders": "1.1.0", "@discordjs/opus": "^0.8.0", "@discordjs/rest": "1.0.1", - "@discordjs/voice": "0.11.0", + "@discordjs/voice": "0.17.0", "@distube/ytdl-core": "^4.14.4", "@distube/ytsr": "^2.0.0", "@prisma/client": "4.16.0", diff --git a/yarn.lock b/yarn.lock index 72db2cb..c965d69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -126,16 +126,16 @@ resolved "https://registry.npmjs.org/@discordjs/util/-/util-0.3.1.tgz" integrity sha512-HxXKYKg7vohx2/OupUN/4Sd02Ev3PBJ5q0gtjdcvXb0ErCva8jNHWfe/v5sU3UKjIB/uxOhc+TDOnhqffj9pRA== -"@discordjs/voice@0.11.0": - version "0.11.0" - resolved "https://registry.npmjs.org/@discordjs/voice/-/voice-0.11.0.tgz" - integrity sha512-6+9cj1dxzBJm7WJ9qyG2XZZQ8rcLl6x2caW0C0OxuTtMLAaEDntpb6lqMTFiBg/rDc4Rd59g1w0gJmib33CuHw== +"@discordjs/voice@^0.17.0": + version "0.17.0" + resolved "https://registry.npmjs.org/@discordjs/voice/-/voice-0.17.0.tgz" + integrity sha512-hArn9FF5ZYi1IkxdJEVnJi+OxlwLV0NJYWpKXsmNOojtGtAZHxmsELA+MZlu2KW1F/K1/nt7lFOfcMXNYweq9w== dependencies: - "@types/ws" "^8.5.3" - discord-api-types "^0.36.2" - prism-media "^1.3.4" - tslib "^2.4.0" - ws "^8.8.1" + "@types/ws" "^8.5.10" + discord-api-types "0.37.83" + prism-media "^1.3.5" + tslib "^2.6.2" + ws "^8.16.0" "@discordjs/ws@^0.8.3": version "0.8.3" From e494287d1d4e220c98856ac1c5c3a34231debe7f Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 20:22:57 -0700 Subject: [PATCH 13/47] Update Docker builds to publish to ghcr.io & update README (#1067) --- .github/workflows/pr-release.yml | 78 ++++++++++++++++++++++++++ .github/workflows/pr-snapshot.yml | 86 +++++++++++++++++++++++++++++ .github/workflows/pr.yml | 91 ------------------------------- .github/workflows/publish.yml | 68 ++++++++++++++--------- README.md | 16 +++--- package.json | 2 +- src/events/guild-create.ts | 2 +- 7 files changed, 218 insertions(+), 125 deletions(-) create mode 100644 .github/workflows/pr-release.yml create mode 100644 .github/workflows/pr-snapshot.yml delete mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml new file mode 100644 index 0000000..4665802 --- /dev/null +++ b/.github/workflows/pr-release.yml @@ -0,0 +1,78 @@ +name: Release snapshot of PR +on: + workflow_run: + workflows: ["Build snapshot of PR"] + types: + - completed + +jobs: + release-and-comment: + name: Release snapshot and comment in PR + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - name: Download images + uses: actions/download-artifact@v4 + with: + path: /tmp/images + pattern: image-* + merge-multiple: true + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.WORKFLOW_PAT }} + + - name: Load image + run: | + docker load --input /tmp/images/image-amd64.tar + docker load --input /tmp/images/image-arm64.tar + + - name: Download PR number + uses: actions/download-artifact@v4 + with: + path: /tmp/pull_request_number + pattern: pull_request_number + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.WORKFLOW_PAT }} + + - name: Read the pull_request_number.txt file + id: pull_request_number_reader + uses: juliangruber/read-file-action@v1.0.0 + with: + path: ./pull_request_number/pull_request_number.txt + + - name: Set up Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push + working-directory: /tmp/digests + run: docker buildx imagetools create -t 'ghcr.io/museofficial/muse:pr-${{ github.event.number }}' -t 'ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}' 'ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}-arm64' 'ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}-amd64' + + - name: Create comment + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: "pr-release" + number: ${{ steps.pull_request_number_reader.outputs.content }} + message: | + #### :package: A new release has been made for this pull request. + + To play around with this PR, pull `ghcr.io/museofficial/muse:pr-${{ github.event.number }}` or `ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}`. + + Images are available for x86_64 and ARM64. + + > Latest commit: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/pr-snapshot.yml b/.github/workflows/pr-snapshot.yml new file mode 100644 index 0000000..882a5ad --- /dev/null +++ b/.github/workflows/pr-snapshot.yml @@ -0,0 +1,86 @@ +name: Build snapshot of PR + +on: pull_request + +env: + REGISTRY_IMAGE: ghcr.io/museofficial/muse + +jobs: + build: + name: Build snapshot + strategy: + matrix: + runner-platform: + - ubuntu-latest + - namespace-profile-default-arm64 + include: + - runner-platform: ubuntu-latest + build-arch: linux/amd64 + tagged-platform: amd64 + - runner-platform: namespace-profile-default-arm64 + build-arch: linux/arm64 + tagged-platform: arm64 + runs-on: ${{ matrix.runner-platform }} + steps: + - name: Prepare + run: | + platform=${{ matrix.build-arch }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: type=ref,event=pr + + - name: Set up Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get current time + uses: josStorer/get-current-time@v2 + id: current-time + + - name: Build + id: build + uses: docker/build-push-action@v6 + with: + outputs: type=docker,dest=/tmp/image.tar + tags: ${{ steps.meta.outputs.tags }} + platforms: ${{ matrix.build-arch }} + build-args: | + COMMIT_HASH=${{ github.sha }} + BUILD_DATE=${{ steps.current-time.outputs.time }} + + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload image + uses: actions/upload-artifact@v4 + with: + name: image-${{ env.PLATFORM_PAIR }} + path: /tmp/image.tar + if-no-files-found: error + retention-days: 1 + + - name: Save PR number in artifact + shell: bash + env: + PR_NUMBER: ${{ github.event.number }} + run: echo $PR_NUMBER > /tmp/pull_request_number.txt + - name: Upload PR number + uses: actions/upload-artifact@v4 + with: + name: pull_request_number + path: /tmp/pull_request_number.txt + overwrite: true diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 7c611ac..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: PR Workflow - -on: pull_request_target - -jobs: - release-snapshot: - name: Release snapshot - strategy: - matrix: - runner-platform: - - ubuntu-latest - - buildjet-4vcpu-ubuntu-2204-arm - include: - - runner-platform: ubuntu-latest - build-arch: linux/amd64 - tagged-platform: amd64 - - runner-platform: buildjet-4vcpu-ubuntu-2204-arm - build-arch: linux/arm64 - tagged-platform: arm64 - runs-on: ${{ matrix.runner-platform }} - steps: - - name: Set up Buildx - uses: docker/setup-buildx-action@v1 - - - name: Cache Docker layers - # AWS data transfer is pricy - if: ${{ matrix.runner-platform != 'buildjet-4vcpu-ubuntu-2204-arm' }} - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-prs-${{ matrix.build-arch }}-${{ github.event.pull_request.head.sha }} - restore-keys: | - ${{ runner.os }}-buildx-prs-${{ matrix.build-arch }} - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: Get current time - uses: josStorer/get-current-time@v2 - id: current-time - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: codetheweb/muse:${{ github.event.pull_request.head.sha }}-${{ matrix.tagged-platform }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache,mode=min - platforms: ${{ matrix.build-arch }} - build-args: | - COMMIT_HASH=${{ github.sha }} - BUILD_DATE=${{ steps.current-time.outputs.time }} - - combine-and-comment: - name: Combine platform tags and leave comment - runs-on: ubuntu-latest - needs: release-snapshot - steps: - - name: Set up Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Combine tags - run: docker buildx imagetools create -t 'codetheweb/muse:pr-${{ github.event.number }}' -t 'codetheweb/muse:${{ github.event.pull_request.head.sha }}' 'codetheweb/muse:${{ github.event.pull_request.head.sha }}-arm64' 'codetheweb/muse:${{ github.event.pull_request.head.sha }}-amd64' - - - name: Create comment - uses: marocchino/sticky-pull-request-comment@v2 - with: - header: "pr-release" - message: | - #### :package: A new release has been made for this pull request. - - To play around with this PR, pull `codetheweb/muse:pr-${{ github.event.number }}` or `codetheweb/muse:${{ github.event.pull_request.head.sha }}`. - - Images are available for x86_64 and ARM64. - - > Latest commit: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 08acff9..7e7a4f6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,28 +11,23 @@ jobs: matrix: runner-platform: - ubuntu-latest - - buildjet-4vcpu-ubuntu-2204-arm + - namespace-profile-default-arm64 include: - runner-platform: ubuntu-latest build-arch: linux/amd64 tagged-platform: amd64 - - runner-platform: buildjet-4vcpu-ubuntu-2204-arm + - runner-platform: namespace-profile-default-arm64 build-arch: linux/arm64 tagged-platform: arm64 runs-on: ${{ matrix.runner-platform }} + permissions: + contents: read + packages: write + attestations: write + id-token: write steps: - name: Set up Buildx - uses: docker/setup-buildx-action@v1 - - - name: Cache Docker layers - # AWS data transfer is pricy - if: ${{ matrix.runner-platform != 'buildjet-4vcpu-ubuntu-2204-arm' }} - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-prs-${{ matrix.build-arch }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx-prs-${{ matrix.build-arch }} + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub uses: docker/login-action@v1 @@ -40,19 +35,26 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Get current time uses: josStorer/get-current-time@v2 id: current-time - name: Build and push id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: push: true - tags: codetheweb/muse:${{ github.sha }}-${{ matrix.tagged-platform }} + tags: | + codetheweb/muse:${{ github.sha }}-${{ matrix.tagged-platform }} + ghcr.io/museofficial/muse:${{ github.sha }}-${{ matrix.tagged-platform }} platforms: ${{ matrix.build-arch }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache,mode=min build-args: | COMMIT_HASH=${{ github.sha }} BUILD_DATE=${{ steps.current-time.outputs.time }} @@ -73,21 +75,37 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Get tags - id: get-tags + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get tags (Docker Hub) + id: get-tags-dockerhub uses: Surgo/docker-smart-tag-action@v1 with: docker_image: codetheweb/muse - - name: Combine tags - run: docker buildx imagetools create $(echo '${{ steps.get-tags.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') 'codetheweb/muse:${{ github.sha }}-arm64' 'codetheweb/muse:${{ github.sha }}-amd64' + - name: Get tags (ghcr.io) + id: get-tags-ghcr + uses: Surgo/docker-smart-tag-action@v1 + with: + docker_image: codetheweb/muse + + - name: Combine tags (Docker Hub) + run: docker buildx imagetools create $(echo '${{ steps.get-tags-dockerhub.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') 'codetheweb/muse:${{ github.sha }}-arm64' 'codetheweb/muse:${{ github.sha }}-amd64' + + - name: Combine tags (GitHub Container Registry) + run: docker buildx imagetools create $(echo '${{ steps.get-tags-ghcr.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') 'ghcr.io/museofficial/muse:${{ github.sha }}-arm64' 'ghcr.io/museofficial/muse:${{ github.sha }}-amd64' - name: Update Docker Hub description uses: peter-evans/dockerhub-description@v2.4.3 - env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - DOCKERHUB_REPOSITORY: codetheweb/muse + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + repository: codetheweb/muse release: name: Create GitHub release diff --git a/README.md b/README.md index 0538183..ced7722 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@

- +

-**🔎 I'm currently looking for maintainers.** Check out [this issue](https://github.com/codetheweb/muse/issues/1063) for details. +> [!WARNING] +> [@codetheweb](https://github.com/codetheweb) (me) is no longer the primary maintainer of Muse. **If you use the Docker image, update your image source to `ghcr.io/museofficial/muse`.** We are currently publishing new releases to both `ghcr.io/museofficial/muse` and `codetheweb/muse`, but this may change in the future. +> Thank you to all the people who stepped up to help maintain Muse! ------ @@ -42,7 +44,7 @@ A 64-bit OS is required to run Muse. The `master` branch acts as the developing / bleeding edge branch and is not guaranteed to be stable. -When running a production instance, I recommend that you use the [latest release](https://github.com/codetheweb/muse/releases/). +When running a production instance, I recommend that you use the [latest release](https://github.com/museofficial/muse/releases/). ### 🐳 Docker @@ -56,7 +58,7 @@ There are a variety of image tags available: (Replace empty config strings with correct values.) ```bash -docker run -it -v "$(pwd)/data":/data -e DISCORD_TOKEN='' -e SPOTIFY_CLIENT_ID='' -e SPOTIFY_CLIENT_SECRET='' -e YOUTUBE_API_KEY='' codetheweb/muse:latest +docker run -it -v "$(pwd)/data":/data -e DISCORD_TOKEN='' -e SPOTIFY_CLIENT_ID='' -e SPOTIFY_CLIENT_SECRET='' -e YOUTUBE_API_KEY='' ghcr.io/museofficial/muse:latest ``` This starts Muse and creates a data directory in your current directory. @@ -68,7 +70,7 @@ version: '3.4' services: muse: - image: codetheweb/muse:latest + image: ghcr.io/museofficial/muse:latest restart: always volumes: - ./muse:/data @@ -85,13 +87,13 @@ services: * Node.js (18.17.0 or later is required and latest 18.x.x LTS is recommended) * ffmpeg (4.1 or later) -1. `git clone https://github.com/codetheweb/muse.git && cd muse` +1. `git clone https://github.com/museofficial/muse.git && cd muse` 2. Copy `.env.example` to `.env` and populate with values 3. I recommend checking out a tagged release with `git checkout v[latest release]` 4. `yarn install` (or `npm i`) 5. `yarn start` (or `npm run start`) -**Note**: if you're on Windows, you may need to manually set the ffmpeg path. See [#345](https://github.com/codetheweb/muse/issues/345) for details. +**Note**: if you're on Windows, you may need to manually set the ffmpeg path. See [#345](https://github.com/museofficial/muse/issues/345) for details. ## ⚙️ Additional configuration (advanced) diff --git a/package.json b/package.json index ae5aecf..0d8631e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "muse", "version": "2.9.1", "description": "🎧 a self-hosted Discord music bot that doesn't suck ", - "repository": "git@github.com:codetheweb/muse.git", + "repository": "git@github.com:museofficial/muse.git", "author": "Max Isom ", "license": "MIT", "private": true, diff --git a/src/events/guild-create.ts b/src/events/guild-create.ts index 1d60910..c903009 100644 --- a/src/events/guild-create.ts +++ b/src/events/guild-create.ts @@ -40,5 +40,5 @@ export default async (guild: Guild): Promise => { } const owner = await guild.fetchOwner(); - await owner.send('👋 Hi! Someone (probably you) just invited me to a server you own. By default, I\'m usable by all guild member in all guild channels. To change this, check out the wiki page on permissions: https://github.com/codetheweb/muse/wiki/Configuring-Bot-Permissions.'); + await owner.send('👋 Hi! Someone (probably you) just invited me to a server you own. By default, I\'m usable by all guild member in all guild channels. To change this, check out the wiki page on permissions: https://github.com/museofficial/muse/wiki/Configuring-Bot-Permissions.'); }; From 6d6fc4c09dfb42149805332ef4d0302bb9ffa253 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 20:42:08 -0700 Subject: [PATCH 14/47] Update PR release workflow --- .github/workflows/pr-release.yml | 37 +++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 4665802..35e12aa 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -19,15 +19,18 @@ jobs: uses: actions/download-artifact@v4 with: path: /tmp/images - pattern: image-* + pattern: image-linux-* merge-multiple: true run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.WORKFLOW_PAT }} + github-token: ${{ secrets.GH_PAT }} + + - name: Set up Buildx + uses: docker/setup-buildx-action@v1 - name: Load image run: | - docker load --input /tmp/images/image-amd64.tar - docker load --input /tmp/images/image-arm64.tar + docker load --input /tmp/images/image-linux-amd64.tar + docker load --input /tmp/images/image-linux-arm64.tar - name: Download PR number uses: actions/download-artifact@v4 @@ -35,7 +38,7 @@ jobs: path: /tmp/pull_request_number pattern: pull_request_number run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.WORKFLOW_PAT }} + github-token: ${{ secrets.GH_PAT }} - name: Read the pull_request_number.txt file id: pull_request_number_reader @@ -43,15 +46,6 @@ jobs: with: path: ./pull_request_number/pull_request_number.txt - - name: Set up Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -59,9 +53,18 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Push + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - name: Create manifest list and push working-directory: /tmp/digests - run: docker buildx imagetools create -t 'ghcr.io/museofficial/muse:pr-${{ github.event.number }}' -t 'ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}' 'ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}-arm64' 'ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}-amd64' + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 @@ -69,7 +72,7 @@ jobs: header: "pr-release" number: ${{ steps.pull_request_number_reader.outputs.content }} message: | - #### :package: A new release has been made for this pull request. + #### :package: :robot: A new release has been made for this pull request. To play around with this PR, pull `ghcr.io/museofficial/muse:pr-${{ github.event.number }}` or `ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}`. From 7f72a74ff808516c6269bf87c80facba14820901 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 20:49:48 -0700 Subject: [PATCH 15/47] Update workflow --- .github/workflows/pr-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 35e12aa..b0a74fc 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -44,7 +44,7 @@ jobs: id: pull_request_number_reader uses: juliangruber/read-file-action@v1.0.0 with: - path: ./pull_request_number/pull_request_number.txt + path: /tmp/pull_request_number/pull_request_number - name: Login to GitHub Container Registry uses: docker/login-action@v3 From 76236005c6ce636e257e9dc862131e72b11f9f56 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 20:54:02 -0700 Subject: [PATCH 16/47] Update workflow --- .github/workflows/pr-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index b0a74fc..91699e2 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -44,7 +44,7 @@ jobs: id: pull_request_number_reader uses: juliangruber/read-file-action@v1.0.0 with: - path: /tmp/pull_request_number/pull_request_number + path: /tmp/pull_request_number/pull_request_number/pull_request_number.txt - name: Login to GitHub Container Registry uses: docker/login-action@v3 From 22be075c8161441b8a7249e3f97e00054f79c1e9 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 20:59:09 -0700 Subject: [PATCH 17/47] Update workflow --- .github/workflows/pr-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 91699e2..8a12083 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -59,6 +59,8 @@ jobs: path: /tmp/digests pattern: digests-* merge-multiple: true + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GH_PAT }} - name: Create manifest list and push working-directory: /tmp/digests From 20e589f3bd20b8d1131b3c57a871c74651457dff Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 21:05:17 -0700 Subject: [PATCH 18/47] Update workflow --- .github/workflows/pr-release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 8a12083..d2f38fd 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -5,6 +5,9 @@ on: types: - completed +env: + REGISTRY_IMAGE: ghcr.io/museofficial/muse + jobs: release-and-comment: name: Release snapshot and comment in PR @@ -76,7 +79,7 @@ jobs: message: | #### :package: :robot: A new release has been made for this pull request. - To play around with this PR, pull `ghcr.io/museofficial/muse:pr-${{ github.event.number }}` or `ghcr.io/museofficial/muse:${{ github.event.pull_request.head.sha }}`. + To play around with this PR, pull `${{ env.REGISTRY_IMAGE }}:pr-${{ github.event.number }}` or `${{ env.REGISTRY_IMAGE }}:${{ github.event.pull_request.head.sha }}`. Images are available for x86_64 and ARM64. From aa4612a45fc62369ce3c285ca765f0ddfb17a6d6 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 21:08:03 -0700 Subject: [PATCH 19/47] Update workflow --- .github/workflows/pr-release.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index d2f38fd..6bd011f 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -35,6 +35,20 @@ jobs: docker load --input /tmp/images/image-linux-amd64.tar docker load --input /tmp/images/image-linux-arm64.tar + - name: Download Docker metadata + uses: actions/download-artifact@v4 + with: + path: /tmp/metadata + pattern: metadata + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GH_PAT }} + + - name: Read the metadata.json file + id: metadata_reader + uses: juliangruber/read-file-action@v1.0.0 + with: + path: /tmp/metadata/metadata/metadata.json + - name: Download PR number uses: actions/download-artifact@v4 with: From 2d8f66f8a1e950412462c55f7803cb4aab3f4ed3 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 21:16:35 -0700 Subject: [PATCH 20/47] Update workflow --- .github/workflows/pr-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 6bd011f..38b66da 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -82,7 +82,7 @@ jobs: - name: Create manifest list and push working-directory: /tmp/digests run: | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< echo '${{ steps.metadata_reader.outputs.content }}') \ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - name: Create comment From 7e2d79f3fb7febbb5368cd14eef55274b505c66d Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 21:22:51 -0700 Subject: [PATCH 21/47] Update workflow --- .github/workflows/pr-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 38b66da..6b4de17 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -82,7 +82,7 @@ jobs: - name: Create manifest list and push working-directory: /tmp/digests run: | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< echo '${{ steps.metadata_reader.outputs.content }}') \ + docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') \ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - name: Create comment From 72667bf00eb53045a7bf4479e697246081b8294c Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 21:35:25 -0700 Subject: [PATCH 22/47] Update workflow --- .github/workflows/pr-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 6b4de17..b6fe760 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -83,7 +83,7 @@ jobs: working-directory: /tmp/digests run: | docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') \ - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + $(printf '${{ env.REGISTRY_IMAGE }}:%s ' *) - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 From fbe64036d8a60bcf6854ba988ec6bdf81e1db863 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 21:50:19 -0700 Subject: [PATCH 23/47] Update workflow --- .github/workflows/pr-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index b6fe760..7f93d59 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -32,8 +32,8 @@ jobs: - name: Load image run: | - docker load --input /tmp/images/image-linux-amd64.tar - docker load --input /tmp/images/image-linux-arm64.tar + docker image import --platform linux/amd64 /tmp/images/image-linux-amd64.tar + docker image import --platform linux/arm64 /tmp/images/image-linux-arm64.tar - name: Download Docker metadata uses: actions/download-artifact@v4 From c8fd5cf97e308085e8a32dbcee6427154ad1e0fd Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 21:59:43 -0700 Subject: [PATCH 24/47] Update workflow --- .github/workflows/pr-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 7f93d59..87fec1e 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -31,6 +31,8 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Load image + shell: bash + id: load-image run: | docker image import --platform linux/amd64 /tmp/images/image-linux-amd64.tar docker image import --platform linux/arm64 /tmp/images/image-linux-arm64.tar @@ -83,7 +85,7 @@ jobs: working-directory: /tmp/digests run: | docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') \ - $(printf '${{ env.REGISTRY_IMAGE }}:%s ' *) + $(echo ${{ steps.load-image.outputs }} | sed 's/sha256://g' | tr '\n' ' ') - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 From fdbd3cd527abab1571e9ea78926ad0e3bfbe3df0 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 22:06:01 -0700 Subject: [PATCH 25/47] Update workflow --- .github/workflows/pr-release.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 87fec1e..454a023 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -34,8 +34,8 @@ jobs: shell: bash id: load-image run: | - docker image import --platform linux/amd64 /tmp/images/image-linux-amd64.tar - docker image import --platform linux/arm64 /tmp/images/image-linux-arm64.tar + echo "AMD64_IMAGE_SHA=$(docker image import --platform linux/amd64 /tmp/images/image-linux-amd64.tar)" >> $GITHUB_ENV" + echo "ARM64_IMAGE_SHA=$(docker image import --platform linux/arm64 /tmp/images/image-linux-arm64.tar)" >> $GITHUB_ENV" - name: Download Docker metadata uses: actions/download-artifact@v4 @@ -85,7 +85,8 @@ jobs: working-directory: /tmp/digests run: | docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') \ - $(echo ${{ steps.load-image.outputs }} | sed 's/sha256://g' | tr '\n' ' ') + $(echo ${{ steps.load-image.outputs.AMD64_IMAGE_SHA }} | sed 's/sha256://g' | tr '\n' ' ') \ + $(echo ${{ steps.load-image.outputs.ARM64_IMAGE_SHA }} | sed 's/sha256://g' | tr '\n' ' ') - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 From cb5c035bbae4c3b2d2c7a8bdbffd6db409fbb9ab Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 22:09:55 -0700 Subject: [PATCH 26/47] Update workflow --- .github/workflows/pr-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 454a023..819441f 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -34,8 +34,8 @@ jobs: shell: bash id: load-image run: | - echo "AMD64_IMAGE_SHA=$(docker image import --platform linux/amd64 /tmp/images/image-linux-amd64.tar)" >> $GITHUB_ENV" - echo "ARM64_IMAGE_SHA=$(docker image import --platform linux/arm64 /tmp/images/image-linux-arm64.tar)" >> $GITHUB_ENV" + echo "AMD64_IMAGE_SHA=$(docker image import --platform linux/amd64 /tmp/images/image-linux-amd64.tar)" >> $GITHUB_ENV + echo "ARM64_IMAGE_SHA=$(docker image import --platform linux/arm64 /tmp/images/image-linux-arm64.tar)" >> $GITHUB_ENV - name: Download Docker metadata uses: actions/download-artifact@v4 From d5f03c0df7815b9de66ad0fef15c41eddc1eb6e5 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 22:20:54 -0700 Subject: [PATCH 27/47] Update workflow --- .github/workflows/pr-release.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 819441f..e4d58fd 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -32,10 +32,9 @@ jobs: - name: Load image shell: bash - id: load-image run: | - echo "AMD64_IMAGE_SHA=$(docker image import --platform linux/amd64 /tmp/images/image-linux-amd64.tar)" >> $GITHUB_ENV - echo "ARM64_IMAGE_SHA=$(docker image import --platform linux/arm64 /tmp/images/image-linux-arm64.tar)" >> $GITHUB_ENV + docker load -i /tmp/images/image-linux-amd64.tar + docker load -i /tmp/images/image-linux-arm64.tar - name: Download Docker metadata uses: actions/download-artifact@v4 @@ -85,8 +84,7 @@ jobs: working-directory: /tmp/digests run: | docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') \ - $(echo ${{ steps.load-image.outputs.AMD64_IMAGE_SHA }} | sed 's/sha256://g' | tr '\n' ' ') \ - $(echo ${{ steps.load-image.outputs.ARM64_IMAGE_SHA }} | sed 's/sha256://g' | tr '\n' ' ') + $(printf '%s ' *) - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 @@ -96,7 +94,7 @@ jobs: message: | #### :package: :robot: A new release has been made for this pull request. - To play around with this PR, pull `${{ env.REGISTRY_IMAGE }}:pr-${{ github.event.number }}` or `${{ env.REGISTRY_IMAGE }}:${{ github.event.pull_request.head.sha }}`. + To play around with this PR, pull `${{ env.REGISTRY_IMAGE }}:pr-${{ steps.pull_request_number_reader.outputs.content }}` or `${{ env.REGISTRY_IMAGE }}:${{ github.event.pull_request.head.sha }}`. Images are available for x86_64 and ARM64. From de56180036b99076893d9882519d82938de26335 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 22:30:37 -0700 Subject: [PATCH 28/47] Update workflow --- .github/workflows/pr-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index e4d58fd..c21de15 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -84,7 +84,7 @@ jobs: working-directory: /tmp/digests run: | docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') \ - $(printf '%s ' *) + $(printf 'sha256:%s ' *) - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 From 7f274980b51001a84041d80149a0da9952c3c286 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 22:51:33 -0700 Subject: [PATCH 29/47] Update workflow --- .github/workflows/pr-release.yml | 47 +++++++++++++++++++------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index c21de15..ca56b6c 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -18,6 +18,16 @@ jobs: attestations: write id-token: write steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Buildx + uses: docker/setup-buildx-action@v1 + - name: Download images uses: actions/download-artifact@v4 with: @@ -27,15 +37,30 @@ jobs: run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GH_PAT }} - - name: Set up Buildx - uses: docker/setup-buildx-action@v1 - - name: Load image shell: bash run: | docker load -i /tmp/images/image-linux-amd64.tar docker load -i /tmp/images/image-linux-arm64.tar + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GH_PAT }} + + - name: Push images + working-directory: /tmp/digests + run: | + for file in ./*; do + hash=$(basename "$file") + + docker push "sha256:$hash" + done + - name: Download Docker metadata uses: actions/download-artifact@v4 with: @@ -64,22 +89,6 @@ jobs: with: path: /tmp/pull_request_number/pull_request_number/pull_request_number.txt - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Download digests - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-* - merge-multiple: true - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.GH_PAT }} - - name: Create manifest list and push working-directory: /tmp/digests run: | From 62b569d26b4b13708f4d3a2b38b857d4bcad63af Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 17 Aug 2024 23:09:29 -0700 Subject: [PATCH 30/47] Update workflow --- .github/workflows/pr-release.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index ca56b6c..007a270 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -43,23 +43,24 @@ jobs: docker load -i /tmp/images/image-linux-amd64.tar docker load -i /tmp/images/image-linux-arm64.tar - - name: Download digests + - name: Download SHA uses: actions/download-artifact@v4 with: - path: /tmp/digests - pattern: digests-* - merge-multiple: true + path: /tmp/SHA + pattern: sha run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GH_PAT }} - - name: Push images - working-directory: /tmp/digests - run: | - for file in ./*; do - hash=$(basename "$file") + - name: Read the sha.txt file + id: sha_reader + uses: juliangruber/read-file-action@v1.0.0 + with: + path: /tmp/SHA/sha/sha.txt - docker push "sha256:$hash" - done + - name: Push images + run: | + docker push ${{ env.REGISTRY_IMAGE }}:${{ steps.sha_reader.outputs.content }}-amd64 + docker push ${{ env.REGISTRY_IMAGE }}:${{ steps.sha_reader.outputs.content }}-arm64 - name: Download Docker metadata uses: actions/download-artifact@v4 @@ -92,8 +93,7 @@ jobs: - name: Create manifest list and push working-directory: /tmp/digests run: | - docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') \ - $(printf 'sha256:%s ' *) + docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') ${{ env.REGISTRY_IMAGE }}:${{ steps.sha_reader.outputs.content }}-amd64 ${{ env.REGISTRY_IMAGE }}:${{ steps.sha_reader.outputs.content }}-arm64 - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 @@ -103,8 +103,8 @@ jobs: message: | #### :package: :robot: A new release has been made for this pull request. - To play around with this PR, pull `${{ env.REGISTRY_IMAGE }}:pr-${{ steps.pull_request_number_reader.outputs.content }}` or `${{ env.REGISTRY_IMAGE }}:${{ github.event.pull_request.head.sha }}`. + To play around with this PR, pull `${{ env.REGISTRY_IMAGE }}:pr-${{ steps.pull_request_number_reader.outputs.content }}`. Images are available for x86_64 and ARM64. - > Latest commit: ${{ github.event.pull_request.head.sha }} + > Latest commit: ${{ steps.sha_reader.outputs.content }} From 0978d40e9517e633555d619b003c3119d7a0042c Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 15:43:55 -0700 Subject: [PATCH 31/47] Update workflow --- .github/workflows/pr-release.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 007a270..cfc492d 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -51,16 +51,15 @@ jobs: run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GH_PAT }} - - name: Read the sha.txt file - id: sha_reader - uses: juliangruber/read-file-action@v1.0.0 - with: - path: /tmp/SHA/sha/sha.txt + - name: Read SHA + shell: bash + run: | + echo "SHA=$(cat /tmp/SHA/sha/sha.txt | tr -d '\n')" >> $GITHUB_ENV - name: Push images run: | - docker push ${{ env.REGISTRY_IMAGE }}:${{ steps.sha_reader.outputs.content }}-amd64 - docker push ${{ env.REGISTRY_IMAGE }}:${{ steps.sha_reader.outputs.content }}-arm64 + docker push ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-amd64 + docker push ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-arm64 - name: Download Docker metadata uses: actions/download-artifact@v4 @@ -93,7 +92,7 @@ jobs: - name: Create manifest list and push working-directory: /tmp/digests run: | - docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') ${{ env.REGISTRY_IMAGE }}:${{ steps.sha_reader.outputs.content }}-amd64 ${{ env.REGISTRY_IMAGE }}:${{ steps.sha_reader.outputs.content }}-arm64 + docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-amd64 ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-arm64 - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 @@ -107,4 +106,4 @@ jobs: Images are available for x86_64 and ARM64. - > Latest commit: ${{ steps.sha_reader.outputs.content }} + > Latest commit: ${{ env.SHA }} From 30c8b1310273aebef9799c943b1c27519f3ad425 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 15:48:38 -0700 Subject: [PATCH 32/47] Update workflow --- .github/workflows/pr-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index cfc492d..1b9f8ef 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -58,8 +58,8 @@ jobs: - name: Push images run: | - docker push ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-amd64 - docker push ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-arm64 + docker push ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-linux-amd64 + docker push ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-linux-arm64 - name: Download Docker metadata uses: actions/download-artifact@v4 @@ -92,7 +92,7 @@ jobs: - name: Create manifest list and push working-directory: /tmp/digests run: | - docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-amd64 ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-arm64 + docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-linux-amd64 ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-linux-arm64 - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 From 9751feb778cd3f7bf863d5e91d7c187980ce3da9 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 15:55:06 -0700 Subject: [PATCH 33/47] Update workflow --- .github/workflows/pr-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 1b9f8ef..651840c 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -90,7 +90,6 @@ jobs: path: /tmp/pull_request_number/pull_request_number/pull_request_number.txt - name: Create manifest list and push - working-directory: /tmp/digests run: | docker buildx imagetools create $(cat /tmp/metadata/metadata/metadata.json | jq -cr '.tags | map("-t " + .) | join(" ")') ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-linux-amd64 ${{ env.REGISTRY_IMAGE }}:${{ env.SHA }}-linux-arm64 @@ -99,6 +98,7 @@ jobs: with: header: "pr-release" number: ${{ steps.pull_request_number_reader.outputs.content }} + GITHUB_TOKEN: ${{ secrets.GH_PAT }} message: | #### :package: :robot: A new release has been made for this pull request. From de4a9193b6016ff15820914d9f06b6dd64649d3f Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 16:01:21 -0700 Subject: [PATCH 34/47] Update workflow --- .github/workflows/pr-release.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml index 651840c..e121edd 100644 --- a/.github/workflows/pr-release.yml +++ b/.github/workflows/pr-release.yml @@ -83,11 +83,10 @@ jobs: run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GH_PAT }} - - name: Read the pull_request_number.txt file - id: pull_request_number_reader - uses: juliangruber/read-file-action@v1.0.0 - with: - path: /tmp/pull_request_number/pull_request_number/pull_request_number.txt + - name: Read PR number + shell: bash + run: | + echo "PR_NUMBER=$(cat /tmp/pull_request_number/pull_request_number/pull_request_number.txt | tr -d '\n')" >> $GITHUB_ENV - name: Create manifest list and push run: | @@ -97,12 +96,12 @@ jobs: uses: marocchino/sticky-pull-request-comment@v2 with: header: "pr-release" - number: ${{ steps.pull_request_number_reader.outputs.content }} + number: ${{ env.PR_NUMBER }} GITHUB_TOKEN: ${{ secrets.GH_PAT }} message: | #### :package: :robot: A new release has been made for this pull request. - To play around with this PR, pull `${{ env.REGISTRY_IMAGE }}:pr-${{ steps.pull_request_number_reader.outputs.content }}`. + To play around with this PR, pull `${{ env.REGISTRY_IMAGE }}:pr-${{ env.PR_NUMBER }}`. Images are available for x86_64 and ARM64. From 4c2f65ff2d8a49fb18dc7d5ff40e71534a1a8817 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 16:12:08 -0700 Subject: [PATCH 35/47] Fix PR publishing (#1068) --- .github/workflows/pr-snapshot.yml | 33 ++++++++++++++++++++++--------- Dockerfile | 8 ++++---- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr-snapshot.yml b/.github/workflows/pr-snapshot.yml index 882a5ad..88182cb 100644 --- a/.github/workflows/pr-snapshot.yml +++ b/.github/workflows/pr-snapshot.yml @@ -16,10 +16,8 @@ jobs: include: - runner-platform: ubuntu-latest build-arch: linux/amd64 - tagged-platform: amd64 - runner-platform: namespace-profile-default-arm64 build-arch: linux/arm64 - tagged-platform: arm64 runs-on: ${{ matrix.runner-platform }} steps: - name: Prepare @@ -52,24 +50,41 @@ jobs: id: build uses: docker/build-push-action@v6 with: - outputs: type=docker,dest=/tmp/image.tar - tags: ${{ steps.meta.outputs.tags }} + outputs: type=docker,dest=/tmp/image-${{ env.PLATFORM_PAIR }}.tar platforms: ${{ matrix.build-arch }} + tags: | + ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-${{ env.PLATFORM_PAIR }} build-args: | COMMIT_HASH=${{ github.sha }} BUILD_DATE=${{ steps.current-time.outputs.time }} - - name: Export digest + - name: Export Docker meta output + shell: bash + run: echo $DOCKER_METADATA_OUTPUT_JSON > /tmp/metadata.json + + - name: Upload metadata + uses: actions/upload-artifact@v4 + with: + name: metadata + path: /tmp/metadata.json + overwrite: true + + - name: Export SHA run: | - mkdir -p /tmp/digests - digest="${{ steps.build.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" + echo "${{ github.sha }}" > /tmp/sha.txt + + - name: Upload SHA + uses: actions/upload-artifact@v4 + with: + name: sha + path: /tmp/sha.txt + overwrite: true - name: Upload image uses: actions/upload-artifact@v4 with: name: image-${{ env.PLATFORM_PAIR }} - path: /tmp/image.tar + path: /tmp/image-${{ env.PLATFORM_PAIR }}.tar if-no-files-found: error retention-days: 1 diff --git a/Dockerfile b/Dockerfile index 6541a2d..328c7d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,9 +48,9 @@ COPY . . ARG COMMIT_HASH=unknown ARG BUILD_DATE=unknown -ENV DATA_DIR /data -ENV NODE_ENV production -ENV COMMIT_HASH $COMMIT_HASH -ENV BUILD_DATE $BUILD_DATE +ENV DATA_DIR=/data +ENV NODE_ENV=production +ENV COMMIT_HASH=$COMMIT_HASH +ENV BUILD_DATE=$BUILD_DATE CMD ["tini", "--", "node", "--enable-source-maps", "dist/scripts/migrate-and-start.js"] From 52df7d42f1e9f46a669ca918ff7dec699cedf087 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 16:14:31 -0700 Subject: [PATCH 36/47] Update readme, changelog, release workflow --- .github/workflows/publish.yml | 9 ++++++--- CHANGELOG.md | 6 ++++++ README.md | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7e7a4f6..0a7b5c3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,6 +5,9 @@ on: tags: - 'v*' +env: + REGISTRY_IMAGE: ghcr.io/museofficial/muse + jobs: publish: strategy: @@ -53,7 +56,7 @@ jobs: push: true tags: | codetheweb/muse:${{ github.sha }}-${{ matrix.tagged-platform }} - ghcr.io/museofficial/muse:${{ github.sha }}-${{ matrix.tagged-platform }} + ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-${{ matrix.tagged-platform }} platforms: ${{ matrix.build-arch }} build-args: | COMMIT_HASH=${{ github.sha }} @@ -92,13 +95,13 @@ jobs: id: get-tags-ghcr uses: Surgo/docker-smart-tag-action@v1 with: - docker_image: codetheweb/muse + docker_image: ${{ env.REGISTRY_IMAGE }} - name: Combine tags (Docker Hub) run: docker buildx imagetools create $(echo '${{ steps.get-tags-dockerhub.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') 'codetheweb/muse:${{ github.sha }}-arm64' 'codetheweb/muse:${{ github.sha }}-amd64' - name: Combine tags (GitHub Container Registry) - run: docker buildx imagetools create $(echo '${{ steps.get-tags-ghcr.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') 'ghcr.io/museofficial/muse:${{ github.sha }}-arm64' 'ghcr.io/museofficial/muse:${{ github.sha }}-amd64' + run: docker buildx imagetools create $(echo '${{ steps.get-tags-ghcr.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') '${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-arm64' '${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-amd64' - name: Update Docker Hub description uses: peter-evans/dockerhub-description@v2.4.3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 783217a..a4fc8ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Muse has new maintainers! I ([@codetheweb](https://github.com/codetheweb)) am stepping aside as I haven't used Muse myself for a few years and haven't been able to spend as much time on Muse as I'd like. See [this issue](https://github.com/museofficial/muse/issues/1063) for details. Welcome @museofficial/maintainers! +- This repository has been moved to museofficial/muse. +- Docker images are now published to `ghcr.io/museofficial/muse`. **Please update your image source if you use Docker**. + ## [2.9.1] - 2024-08-04 ### Fixed diff --git a/README.md b/README.md index ced7722..7fec19f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

> [!WARNING] -> [@codetheweb](https://github.com/codetheweb) (me) is no longer the primary maintainer of Muse. **If you use the Docker image, update your image source to `ghcr.io/museofficial/muse`.** We are currently publishing new releases to both `ghcr.io/museofficial/muse` and `codetheweb/muse`, but this may change in the future. +> I ([@codetheweb](https://github.com/codetheweb)) am no longer the primary maintainer of Muse. **If you use the Docker image, update your image source to `ghcr.io/museofficial/muse`.** We are currently publishing new releases to both `ghcr.io/museofficial/muse` and `codetheweb/muse`, but this may change in the future. > Thank you to all the people who stepped up to help maintain Muse! ------ From 069774e7094a7f40ba230cad8a190e0fb34dce0d Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 16:15:00 -0700 Subject: [PATCH 37/47] Release 2.9.2 --- .github/workflows/publish.yml | 5 +++++ CHANGELOG.md | 5 ++++- package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0a7b5c3..a279abe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -66,6 +66,11 @@ jobs: name: Combine platform tags runs-on: ubuntu-latest needs: publish + permissions: + contents: read + packages: write + attestations: write + id-token: write steps: - uses: actions/checkout@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index a4fc8ac..65892bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.9.2] - 2024-08-18 + ### Changed - Muse has new maintainers! I ([@codetheweb](https://github.com/codetheweb)) am stepping aside as I haven't used Muse myself for a few years and haven't been able to spend as much time on Muse as I'd like. See [this issue](https://github.com/museofficial/muse/issues/1063) for details. Welcome @museofficial/maintainers! @@ -329,7 +331,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.1...HEAD +[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.2...HEAD +[2.9.2]: https://github.com/codetheweb/muse/compare/v2.9.1...v2.9.2 [2.9.1]: https://github.com/codetheweb/muse/compare/v2.9.0...v2.9.1 [2.9.0]: https://github.com/codetheweb/muse/compare/v2.8.1...v2.9.0 [2.8.1]: https://github.com/codetheweb/muse/compare/v2.8.0...v2.8.1 diff --git a/package.json b/package.json index 0d8631e..d4de505 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muse", - "version": "2.9.1", + "version": "2.9.2", "description": "🎧 a self-hosted Discord music bot that doesn't suck ", "repository": "git@github.com:museofficial/muse.git", "author": "Max Isom ", From fb4d7885f71f5e4fbbf0a4d34d0e844bf4eeff32 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 16:27:20 -0700 Subject: [PATCH 38/47] Fix PAT for release comments --- .github/workflows/release-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-comment.yml b/.github/workflows/release-comment.yml index ab042ac..af122e7 100644 --- a/.github/workflows/release-comment.yml +++ b/.github/workflows/release-comment.yml @@ -8,6 +8,6 @@ jobs: steps: - uses: apexskier/github-release-commenter@v1 with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_PAT }} comment-template: | 🚀 Released in {release_link}. From e1dfd192e898525eba0fc46020a6ccd0036437f1 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 18 Aug 2024 16:27:39 -0700 Subject: [PATCH 39/47] Add release docs --- RELEASING.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 RELEASING.md diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..34d3b81 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,5 @@ +# Releasing + +1. Confirm that CHANGELOG.md is updated (any new changes should go under "Unreleased" at the top). +2. On the master branch, run `yarn release` and follow the prompts. +3. After a new tag is pushed from the above step, the [publish workflow](./.github/workflows/publish.yml) will automatically build & push Docker images and create a GitHub release for the tag. From 6c26138c238fe62b74d81cb4a42fa2728a20e69e Mon Sep 17 00:00:00 2001 From: Harry Jenkins Date: Mon, 19 Aug 2024 11:03:45 +1000 Subject: [PATCH 40/47] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65892bd..3808d1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- bumped @discordjs/voice +- bumped @distube/ytdl-core + ## [2.9.2] - 2024-08-18 ### Changed From 1e17b94321744ffbe4a6176a900286a834c952d1 Mon Sep 17 00:00:00 2001 From: Harry Jenkins Date: Mon, 19 Aug 2024 12:43:37 +1000 Subject: [PATCH 41/47] Release 2.9.3 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3808d1d..27c084e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.9.3] - 2024-08-19 + ### Fixed - bumped @discordjs/voice @@ -336,7 +338,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.2...HEAD +[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.3...HEAD +[2.9.3]: https://github.com/codetheweb/muse/compare/v2.9.2...v2.9.3 [2.9.2]: https://github.com/codetheweb/muse/compare/v2.9.1...v2.9.2 [2.9.1]: https://github.com/codetheweb/muse/compare/v2.9.0...v2.9.1 [2.9.0]: https://github.com/codetheweb/muse/compare/v2.8.1...v2.9.0 diff --git a/package.json b/package.json index 30db626..5cbb1d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muse", - "version": "2.9.2", + "version": "2.9.3", "description": "🎧 a self-hosted Discord music bot that doesn't suck ", "repository": "git@github.com:museofficial/muse.git", "author": "Max Isom ", From 6e39c8d09ed8f7460f54fb766efddd507f368523 Mon Sep 17 00:00:00 2001 From: Tiago Grosso Date: Fri, 23 Aug 2024 21:18:08 +0100 Subject: [PATCH 42/47] feat: add optional pageSize to /queue command --- CHANGELOG.md | 3 +++ src/commands/queue.ts | 10 +++++++++- src/utils/build-embed.ts | 10 ++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c084e..466f229 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- An optional `pageSize` to `/queue` command + ## [2.9.3] - 2024-08-19 ### Fixed diff --git a/src/commands/queue.ts b/src/commands/queue.ts index 5196ca9..dcc674a 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -14,6 +14,10 @@ export default class implements Command { .addIntegerOption(option => option .setName('page') .setDescription('page of queue to show [default: 1]') + .setRequired(false)) + .addIntegerOption(option => option + .setName('pageSize') + .setDescription('how many items to display per page [default: 10]') .setRequired(false)); private readonly playerManager: PlayerManager; @@ -25,7 +29,11 @@ export default class implements Command { public async execute(interaction: ChatInputCommandInteraction) { const player = this.playerManager.get(interaction.guild!.id); - const embed = buildQueueEmbed(player, interaction.options.getInteger('page') ?? 1); + const embed = buildQueueEmbed( + player, + interaction.options.getInteger('page') ?? 1, + interaction.options.getInteger('pageSize') ?? 10, + ); await interaction.reply({embeds: [embed]}); } diff --git a/src/utils/build-embed.ts b/src/utils/build-embed.ts index b8e725c..23db0b9 100644 --- a/src/utils/build-embed.ts +++ b/src/utils/build-embed.ts @@ -5,8 +5,6 @@ import getProgressBar from './get-progress-bar.js'; import {prettyTime} from './time.js'; import {truncate} from './string.js'; -const PAGE_SIZE = 10; - const getMaxSongTitleLength = (title: string) => { // eslint-disable-next-line no-control-regex const nonASCII = /[^\x00-\x7F]+/; @@ -77,7 +75,7 @@ export const buildPlayingMessageEmbed = (player: Player): EmbedBuilder => { return message; }; -export const buildQueueEmbed = (player: Player, page: number): EmbedBuilder => { +export const buildQueueEmbed = (player: Player, page: number, pageSize: number): EmbedBuilder => { const currentlyPlaying = player.getCurrent(); if (!currentlyPlaying) { @@ -85,14 +83,14 @@ export const buildQueueEmbed = (player: Player, page: number): EmbedBuilder => { } const queueSize = player.queueSize(); - const maxQueuePage = Math.ceil((queueSize + 1) / PAGE_SIZE); + const maxQueuePage = Math.ceil((queueSize + 1) / pageSize); if (page > maxQueuePage) { throw new Error('the queue isn\'t that big'); } - const queuePageBegin = (page - 1) * PAGE_SIZE; - const queuePageEnd = queuePageBegin + PAGE_SIZE; + const queuePageBegin = (page - 1) * pageSize; + const queuePageEnd = queuePageBegin + pageSize; const queuedSongs = player .getQueue() .slice(queuePageBegin, queuePageEnd) From c46153f62086a06fe6aedf240bfec9f264295565 Mon Sep 17 00:00:00 2001 From: Tiago Grosso Date: Fri, 23 Aug 2024 21:38:50 +0100 Subject: [PATCH 43/47] fix: fix page-size option name --- CHANGELOG.md | 2 +- src/commands/queue.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 466f229..7630ee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- An optional `pageSize` to `/queue` command +- An optional `page-size` to `/queue` command ## [2.9.3] - 2024-08-19 diff --git a/src/commands/queue.ts b/src/commands/queue.ts index dcc674a..d627c7f 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -16,7 +16,7 @@ export default class implements Command { .setDescription('page of queue to show [default: 1]') .setRequired(false)) .addIntegerOption(option => option - .setName('pageSize') + .setName('page-size') .setDescription('how many items to display per page [default: 10]') .setRequired(false)); @@ -32,7 +32,7 @@ export default class implements Command { const embed = buildQueueEmbed( player, interaction.options.getInteger('page') ?? 1, - interaction.options.getInteger('pageSize') ?? 10, + interaction.options.getInteger('page-size') ?? 10, ); await interaction.reply({embeds: [embed]}); From 0912d957918cb93b0d0607d305fd9d92c1f1cce5 Mon Sep 17 00:00:00 2001 From: Tiago Grosso Date: Sat, 24 Aug 2024 23:08:05 +0100 Subject: [PATCH 44/47] feat: add setting for default queue page size --- CHANGELOG.md | 1 + .../migration.sql | 19 +++++++++++++ schema.prisma | 1 + src/commands/config.ts | 27 +++++++++++++++++++ src/commands/queue.ts | 13 ++++++--- 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 migrations/20240824215313_add_default_queue_page_size/migration.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 7630ee4..5b3b5e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - An optional `page-size` to `/queue` command +- Add `default-queue-page-size` setting ## [2.9.3] - 2024-08-19 diff --git a/migrations/20240824215313_add_default_queue_page_size/migration.sql b/migrations/20240824215313_add_default_queue_page_size/migration.sql new file mode 100644 index 0000000..ff3866a --- /dev/null +++ b/migrations/20240824215313_add_default_queue_page_size/migration.sql @@ -0,0 +1,19 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Setting" ( + "guildId" TEXT NOT NULL PRIMARY KEY, + "playlistLimit" INTEGER NOT NULL DEFAULT 50, + "secondsToWaitAfterQueueEmpties" INTEGER NOT NULL DEFAULT 30, + "leaveIfNoListeners" BOOLEAN NOT NULL DEFAULT true, + "queueAddResponseEphemeral" BOOLEAN NOT NULL DEFAULT false, + "autoAnnounceNextSong" BOOLEAN NOT NULL DEFAULT false, + "defaultVolume" INTEGER NOT NULL DEFAULT 100, + "defaultQueuePageSize" INTEGER NOT NULL DEFAULT 10, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Setting" ("autoAnnounceNextSong", "createdAt", "defaultVolume", "guildId", "leaveIfNoListeners", "playlistLimit", "queueAddResponseEphemeral", "secondsToWaitAfterQueueEmpties", "updatedAt") SELECT "autoAnnounceNextSong", "createdAt", "defaultVolume", "guildId", "leaveIfNoListeners", "playlistLimit", "queueAddResponseEphemeral", "secondsToWaitAfterQueueEmpties", "updatedAt" FROM "Setting"; +DROP TABLE "Setting"; +ALTER TABLE "new_Setting" RENAME TO "Setting"; +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/schema.prisma b/schema.prisma index d7b9de8..65c3aee 100644 --- a/schema.prisma +++ b/schema.prisma @@ -31,6 +31,7 @@ model Setting { queueAddResponseEphemeral Boolean @default(false) autoAnnounceNextSong Boolean @default(false) defaultVolume Int @default(100) + defaultQueuePageSize Int @default(10) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } diff --git a/src/commands/config.ts b/src/commands/config.ts index f866e82..c9aa0e3 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -56,6 +56,15 @@ export default class implements Command { .setMinValue(0) .setMaxValue(100) .setRequired(true))) + .addSubcommand(subcommand => subcommand + .setName('set-default-queue-page-size') + .setDescription('set the default page size of the /queue command') + .addIntegerOption(option => option + .setName('page-size') + .setDescription('page size of the /queue command') + .setMinValue(1) + .setMaxValue(50) + .setRequired(true))) .addSubcommand(subcommand => subcommand .setName('get') .setDescription('show all settings')); @@ -171,6 +180,23 @@ export default class implements Command { break; } + case 'set-default-queue-page-size': { + const value = interaction.options.getInteger('page-size')!; + + await prisma.setting.update({ + where: { + guildId: interaction.guild!.id, + }, + data: { + defaultQueuePageSize: value, + }, + }); + + await interaction.reply('👍 default queue page size updated'); + + break; + } + case 'get': { const embed = new EmbedBuilder().setTitle('Config'); @@ -185,6 +211,7 @@ export default class implements Command { 'Auto announce next song in queue': config.autoAnnounceNextSong ? 'yes' : 'no', 'Add to queue reponses show for requester only': config.autoAnnounceNextSong ? 'yes' : 'no', 'Default Volume': config.defaultVolume, + 'Default queue page size': config.defaultQueuePageSize, }; let description = ''; diff --git a/src/commands/queue.ts b/src/commands/queue.ts index d627c7f..60472b0 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -5,6 +5,7 @@ import {TYPES} from '../types.js'; import PlayerManager from '../managers/player.js'; import Command from './index.js'; import {buildQueueEmbed} from '../utils/build-embed.js'; +import {getGuildSettings} from '../utils/get-guild-settings.js'; @injectable() export default class implements Command { @@ -17,7 +18,9 @@ export default class implements Command { .setRequired(false)) .addIntegerOption(option => option .setName('page-size') - .setDescription('how many items to display per page [default: 10]') + .setDescription('how many items to display per page [default: 10, max: 50]') + .setMinValue(1) + .setMaxValue(50) .setRequired(false)); private readonly playerManager: PlayerManager; @@ -27,12 +30,16 @@ export default class implements Command { } public async execute(interaction: ChatInputCommandInteraction) { - const player = this.playerManager.get(interaction.guild!.id); + const guildId = interaction.guild!.id; + const player = this.playerManager.get(guildId); + + const pageSizeFromOptions = interaction.options.getInteger('page-size'); + const pageSize = pageSizeFromOptions ?? (await getGuildSettings(guildId)).defaultQueuePageSize; const embed = buildQueueEmbed( player, interaction.options.getInteger('page') ?? 1, - interaction.options.getInteger('page-size') ?? 10, + pageSize, ); await interaction.reply({embeds: [embed]}); From 8e7e12c8dfa39d4ce779b8fdcbdfd0cfe7425269 Mon Sep 17 00:00:00 2001 From: Tiago Grosso Date: Tue, 27 Aug 2024 11:11:43 +0100 Subject: [PATCH 45/47] fix: limit queue size to 30 --- src/commands/config.ts | 2 +- src/commands/queue.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/config.ts b/src/commands/config.ts index c9aa0e3..91b2578 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -63,7 +63,7 @@ export default class implements Command { .setName('page-size') .setDescription('page size of the /queue command') .setMinValue(1) - .setMaxValue(50) + .setMaxValue(30) .setRequired(true))) .addSubcommand(subcommand => subcommand .setName('get') diff --git a/src/commands/queue.ts b/src/commands/queue.ts index 60472b0..fd3674a 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -20,7 +20,7 @@ export default class implements Command { .setName('page-size') .setDescription('how many items to display per page [default: 10, max: 50]') .setMinValue(1) - .setMaxValue(50) + .setMaxValue(30) .setRequired(false)); private readonly playerManager: PlayerManager; From a87078c2ada84adabc8d9bb5b527feec6490e513 Mon Sep 17 00:00:00 2001 From: Harry Jenkins Date: Wed, 28 Aug 2024 16:41:12 +1000 Subject: [PATCH 46/47] update page-size option description to reflect maximum value of 30 --- src/commands/queue.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/queue.ts b/src/commands/queue.ts index fd3674a..fd36e43 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.ts @@ -18,7 +18,7 @@ export default class implements Command { .setRequired(false)) .addIntegerOption(option => option .setName('page-size') - .setDescription('how many items to display per page [default: 10, max: 50]') + .setDescription('how many items to display per page [default: 10, max: 30]') .setMinValue(1) .setMaxValue(30) .setRequired(false)); From 534d8fafaa7f09f7ba940d044b08e6c48f800c7a Mon Sep 17 00:00:00 2001 From: Harry Jenkins Date: Wed, 28 Aug 2024 16:56:27 +1000 Subject: [PATCH 47/47] Release 2.9.4 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b3b5e4..4fd8113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.9.4] - 2024-08-28 + ### Added - An optional `page-size` to `/queue` command - Add `default-queue-page-size` setting @@ -342,7 +344,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.3...HEAD +[unreleased]: https://github.com/codetheweb/muse/compare/v2.9.4...HEAD +[2.9.4]: https://github.com/codetheweb/muse/compare/v2.9.3...v2.9.4 [2.9.3]: https://github.com/codetheweb/muse/compare/v2.9.2...v2.9.3 [2.9.2]: https://github.com/codetheweb/muse/compare/v2.9.1...v2.9.2 [2.9.1]: https://github.com/codetheweb/muse/compare/v2.9.0...v2.9.1 diff --git a/package.json b/package.json index 5cbb1d8..2a2b89a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muse", - "version": "2.9.3", + "version": "2.9.4", "description": "🎧 a self-hosted Discord music bot that doesn't suck ", "repository": "git@github.com:museofficial/muse.git", "author": "Max Isom ",