From 9bf892c3776bcbf6a8067ca86369d1d8346c3bde Mon Sep 17 00:00:00 2001 From: mini-bomba <55105495+mini-bomba@users.noreply.github.com> Date: Thu, 28 Aug 2025 23:17:59 +0200 Subject: [PATCH 1/7] add source maps to releases --- webpack/webpack.prod.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index 03e1708e3a..3099c67eea 100644 --- a/webpack/webpack.prod.js +++ b/webpack/webpack.prod.js @@ -7,6 +7,7 @@ module.exports = env => { env.mode = mode; return merge(common(env), { - mode + mode, + devtool: "source-map", }); -}; \ No newline at end of file +}; From bf68ce14c4e75dd8af49cbcc99c6912ff19cbef7 Mon Sep 17 00:00:00 2001 From: mini-bomba <55105495+mini-bomba@users.noreply.github.com> Date: Fri, 29 Aug 2025 00:16:56 +0200 Subject: [PATCH 2/7] deploy firefox beta releases to github pages, enable updates --- .github/workflows/release.yml | 63 ++++++++++++++++++++++++++++++++--- webpack/webpack.common.js | 5 +-- webpack/webpack.manifest.js | 14 ++++++-- 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 916dbc6a66..83d8c09bb8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,7 +106,7 @@ jobs: # Firefox Beta - name: Create Firefox Beta artifacts - run: npm run build:firefox -- --env stream=beta + run: npm run build:firefox -- --env stream=beta --env autoupdate - uses: actions/upload-artifact@v4 with: name: FirefoxExtensionBeta @@ -120,10 +120,8 @@ jobs: env: WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }} WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }} - - name: Install rename - run: sudo apt-get install rename - name: Rename signed file - run: cd ./web-ext-artifacts ; rename 's/.*/FirefoxSignedInstaller.xpi/' * + run: mv ./web-ext-artifacts/* ./web-ext-artifacts/FirefoxSignedInstaller.xpi - uses: actions/upload-artifact@v4 with: name: FirefoxExtensionSigned.xpi @@ -137,3 +135,60 @@ jobs: path: ./web-ext-artifacts/FirefoxSignedInstaller.xpi repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare new github pages deployment + shell: python + run: | + from pathlib import Path + import json + import os + + # config stuff + installer_name = "FirefoxSignedInstaller.xpi" + owner, repo_name = os.environ["GITHUB_REPOSITORY"].split("/") + owner = owner.lower() + + # create the github paged dir + ghp_dir = Path("./github-pages") + ghp_dir.mkdir(parents=True, exist_ok=True) + + # move in the installer + Path("./web-ext-artifacts", installer_name).rename(ghp_dir / installer_name) + + # read manifest.json and extract parameters + with open("./dist/manifest.json") as f: + manifest = json.load(f) + current_version = manifest["version"] + ext_id = manifest["browser_specific_settings"]["gecko"]["id"] + + # generate updates file + updates = { + "addons": { + ext_id: { + "updates": [ + { + "version": current_version, + # param doesn't actually matter, it's just a cachebuster + "update_link": f"https://{owner}.github.io/{repo_name}/{installer_name}?v={current_version}", + }, + ], + }, + }, + } + (ghp_dir / "updates.json").write_text(json.dumps(updates)) + + - name: Upload new github pages deployment + uses: actions/upload-pages-artifact@v3 + with: + path: ./github-pages + + deploy-ghp: + name: Deploy to github pages + needs: build + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy + id: deployment + uses: actions/deploy-pages@v4 diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index 3db98d1373..512bb7df7e 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -189,7 +189,8 @@ module.exports = env => { new BuildManifest({ browser: env.browser, pretty: env.mode === "production", - stream: env.stream + stream: env.stream, + autoupdate: env.autoupdate, }), new configDiffPlugin() ], @@ -200,4 +201,4 @@ module.exports = env => { } }; -}; \ No newline at end of file +}; diff --git a/webpack/webpack.manifest.js b/webpack/webpack.manifest.js index 1666c8a1dd..b89bcce5b6 100644 --- a/webpack/webpack.manifest.js +++ b/webpack/webpack.manifest.js @@ -23,10 +23,13 @@ const schema = { pretty: { type: 'boolean' }, - steam: { + stream: { type: 'string' + }, + autoupdate: { + type: 'boolean', } - } + } }; class BuildManifest { @@ -62,6 +65,11 @@ class BuildManifest { } } + if (this.options.autoupdate === true && this.options.browser.toLowerCase() === "firefox") { + const [owner, repo_name] = process.env.GITHUB_REPOSITORY.split("/"); + manifest.browser_specific_settings.gecko.update_url = `https://${owner.toLowerCase()}.github.io/${repo_name}/updates.json`; + } + let result = JSON.stringify(manifest); if (this.options.pretty) result = JSON.stringify(manifest, null, 2); @@ -86,4 +94,4 @@ function mergeObjects(object1, object2) { } } -module.exports = BuildManifest; \ No newline at end of file +module.exports = BuildManifest; From e5bccf95ea5baf64c8959156c19ab883cdcaefb0 Mon Sep 17 00:00:00 2001 From: mini-bomba <55105495+mini-bomba@users.noreply.github.com> Date: Fri, 29 Aug 2025 13:15:32 +0200 Subject: [PATCH 3/7] Set up uploading source maps to github pages --- .github/workflows/release.yml | 77 +++++++++++++++++++++++++++++++---- webpack/webpack.manifest.js | 2 +- webpack/webpack.prod.js | 21 +++++++++- 3 files changed, 91 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83d8c09bb8..1d009c9234 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,9 +12,19 @@ jobs: steps: # Initialization - - uses: actions/checkout@v4 + - name: Checkout release branch w/submodules + uses: actions/checkout@v5 with: submodules: recursive + - name: Checkout source maps branch + uses: actions/checkout@v5 + with: + path: source-maps + ref: source-maps + - name: Set up committer info + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - uses: actions/setup-node@v4 with: node-version: '18' @@ -38,8 +48,14 @@ jobs: # Create Firefox artifacts - name: Create Firefox artifacts - run: npm run build:firefox + run: npm run build:firefox -- --env ghpSourceMaps - run: mkdir ./builds + - name: Move Firefox source maps to source map repo + run: | + VERSION=`jq -r '.version' ./dist/manifest.json` + mkdir -p "./source-maps/firefox/$VERSION/" + mv -v ./dist/**/*.js.map "./source-maps/firefox/$VERSION/" + cp -v ./dist/**/*.js.LICENSE.txt "./source-maps/firefox/$VERSION/" - name: Zip Artifacts run: cd ./dist ; zip -r ../builds/FirefoxExtension.zip * - name: Upload FirefoxExtension to release @@ -52,7 +68,13 @@ jobs: # Create Chrome artifacts - name: Create Chrome artifacts - run: npm run build:chrome + run: npm run build:chrome -- --env ghpSourceMaps + - name: Move Chrome source maps to source map repo + run: | + VERSION=`jq -r '.version' ./dist/manifest.json` + mkdir -p "./source-maps/chrome/$VERSION/" + mv -v ./dist/**/*.js.map "./source-maps/chrome/$VERSION/" + cp -v ./dist/**/*.js.LICENSE.txt "./source-maps/chrome/$VERSION/" - name: Zip Artifacts run: cd ./dist ; zip -r ../builds/ChromeExtension.zip * - name: Upload ChromeExtension to release @@ -67,7 +89,13 @@ jobs: - name: Clear dist for Edge run: rm -rf ./dist - name: Create Edge artifacts - run: npm run build:edge + run: npm run build:edge -- --env ghpSourceMaps + - name: Move Edge source maps to source map repo + run: | + VERSION=`jq -r '.version' ./dist/manifest.json` + mkdir -p "./source-maps/edge/$VERSION/" + mv -v ./dist/**/*.js.map "./source-maps/edge/$VERSION/" + cp -v ./dist/**/*.js.LICENSE.txt "./source-maps/edge/$VERSION/" - name: Zip Artifacts run: cd ./dist ; zip -r ../builds/EdgeExtension.zip * - name: Upload EdgeExtension to release @@ -80,7 +108,13 @@ jobs: # Create Safari artifacts - name: Create Safari artifacts - run: npm run build:safari + run: npm run build:safari -- --env ghpSourceMaps + - name: Move Safari source maps to source map repo + run: | + VERSION=`jq -r '.version' ./dist/manifest.json` + mkdir -p "./source-maps/safari/$VERSION/" + mv -v ./dist/**/*.js.map "./source-maps/safari/$VERSION/" + cp -v ./dist/**/*.js.LICENSE.txt "./source-maps/safari/$VERSION/" - name: Zip Artifacts run: cd ./dist ; zip -r ../builds/SafariExtension.zip * - name: Upload SafariExtension to release @@ -93,7 +127,13 @@ jobs: # Create Beta artifacts (Builds with the name changed to beta) - name: Create Chrome Beta artifacts - run: npm run build:chrome -- --env stream=beta + run: npm run build:chrome -- --env stream=beta --env ghpSourceMaps + - name: Move Chrome Beta source maps to source map repo + run: | + VERSION=`jq -r '.version' ./dist/manifest.json` + mkdir -p "./source-maps/chrome-beta/$VERSION/" + mv -v ./dist/**/*.js.map "./source-maps/chrome-beta/$VERSION/" + cp -v ./dist/**/*.js.LICENSE.txt "./source-maps/chrome-beta/$VERSION/" - name: Zip Artifacts run: cd ./dist ; zip -r ../builds/ChromeExtensionBeta.zip * - name: Upload ChromeExtensionBeta to release @@ -106,11 +146,17 @@ jobs: # Firefox Beta - name: Create Firefox Beta artifacts - run: npm run build:firefox -- --env stream=beta --env autoupdate + run: npm run build:firefox -- --env stream=beta --env autoupdate --env ghpSourceMaps - uses: actions/upload-artifact@v4 with: name: FirefoxExtensionBeta path: dist + - name: Move Firefox Beta source maps to source map repo + run: | + VERSION=`jq -r '.version' ./dist/manifest.json` + mkdir -p "./source-maps/firefox-beta/$VERSION/" + mv -v ./dist/**/*.js.map "./source-maps/firefox-beta/$VERSION/" + cp -v ./dist/**/*.js.LICENSE.txt "./source-maps/firefox-beta/$VERSION/" - name: Zip Artifacts run: cd ./dist ; zip -r ../builds/FirefoxExtensionBeta.zip * @@ -135,11 +181,21 @@ jobs: path: ./web-ext-artifacts/FirefoxSignedInstaller.xpi repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Commit & push new source maps + if: always() + run: | + VERSION=`jq -r '.version' ./dist/manifest.json` + cd ./source-maps + git add . + git commit -m "Publish source maps for version $VERSION" + git push + - name: Prepare new github pages deployment shell: python run: | from pathlib import Path import json + import shutil import os # config stuff @@ -176,6 +232,13 @@ jobs: } (ghp_dir / "updates.json").write_text(json.dumps(updates)) + # copy in source maps + def only_sourcemaps(cur, ls): + if '/' in cur: + return [] + return set(ls) - {"chrome", "chrome-beta", "edge", "firefox", "firefox-beta", "safari"} + shutil.copytree("source-maps", ghp_dir, ignore=only_sourcemaps, dirs_exist_ok=True) + - name: Upload new github pages deployment uses: actions/upload-pages-artifact@v3 with: diff --git a/webpack/webpack.manifest.js b/webpack/webpack.manifest.js index b89bcce5b6..2b8664989c 100644 --- a/webpack/webpack.manifest.js +++ b/webpack/webpack.manifest.js @@ -42,6 +42,7 @@ class BuildManifest { apply() { const distFolder = path.resolve(__dirname, "../dist/"); const distManifestFile = path.resolve(distFolder, "manifest.json"); + const [owner, repo_name] = (process.env.GITHUB_REPOSITORY ?? "ajayyy/SponsorBlock").split("/"); // Add missing manifest elements if (this.options.browser.toLowerCase() === "firefox") { @@ -66,7 +67,6 @@ class BuildManifest { } if (this.options.autoupdate === true && this.options.browser.toLowerCase() === "firefox") { - const [owner, repo_name] = process.env.GITHUB_REPOSITORY.split("/"); manifest.browser_specific_settings.gecko.update_url = `https://${owner.toLowerCase()}.github.io/${repo_name}/updates.json`; } diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index 3099c67eea..be80faf93d 100644 --- a/webpack/webpack.prod.js +++ b/webpack/webpack.prod.js @@ -1,13 +1,32 @@ /* eslint-disable @typescript-eslint/no-var-requires */ +const { SourceMapDevToolPlugin } = require('webpack'); const { merge } = require('webpack-merge'); const common = require('./webpack.common.js'); +function createGHPSourceMapURL(env) { + const manifest = require("../manifest/manifest.json"); + const version = manifest.version; + const [owner, repo_name] = (process.env.GITHUB_REPOSITORY ?? "ajayyy/SponsorBlock").split("/"); + return `https://${owner.toLowerCase()}.github.io/${repo_name}/${env.browser}${env.stream === "beta" ? "-beta" : ""}/${version}/`; +} + module.exports = env => { let mode = "production"; env.mode = mode; return merge(common(env), { mode, - devtool: "source-map", + ...(env.ghpSourceMaps + ? { + devtool: false, + plugins: [new SourceMapDevToolPlugin({ + publicPath: createGHPSourceMapURL(env), + filename: '[file].map[query]', + })], + } + : { + devtool: "source-map", + } + ), }); }; From a34e6e6d031a0ea8fcd26832feaa50a2f9c61695 Mon Sep 17 00:00:00 2001 From: mini-bomba <55105495+mini-bomba@users.noreply.github.com> Date: Fri, 29 Aug 2025 13:34:07 +0200 Subject: [PATCH 4/7] Enable TS source maps in prod --- tsconfig-production.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig-production.json b/tsconfig-production.json index c79b6f6144..6f9122e01c 100644 --- a/tsconfig-production.json +++ b/tsconfig-production.json @@ -5,7 +5,7 @@ "noImplicitAny": false, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "sourceMap": false, + "sourceMap": true, "outDir": "dist/js", "noEmitOnError": false, "typeRoots": [ "node_modules/@types" ], @@ -20,4 +20,4 @@ "include": [ "src/**/*" ] -} \ No newline at end of file +} From c30f8ec5a314357e61a5de0c272d4f8ec88892d9 Mon Sep 17 00:00:00 2001 From: Ajay Date: Tue, 16 Sep 2025 03:55:27 -0400 Subject: [PATCH 5/7] Fix missing permissions for release workflow --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d009c9234..1957dc08cf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -247,6 +247,9 @@ jobs: deploy-ghp: name: Deploy to github pages needs: build + permissions: + id-token: write + pages: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} From 1056d1ef5f20621840cc05b64c9da3624bd7efa5 Mon Sep 17 00:00:00 2001 From: mini-bomba <55105495+mini-bomba@users.noreply.github.com> Date: Tue, 16 Sep 2025 19:38:01 +0200 Subject: [PATCH 6/7] fix remote source maps for users with custom ghp domains --- webpack/webpack.prod.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index be80faf93d..eb66b24676 100644 --- a/webpack/webpack.prod.js +++ b/webpack/webpack.prod.js @@ -3,14 +3,22 @@ const { SourceMapDevToolPlugin } = require('webpack'); const { merge } = require('webpack-merge'); const common = require('./webpack.common.js'); -function createGHPSourceMapURL(env) { +async function createGHPSourceMapURL(env) { const manifest = require("../manifest/manifest.json"); const version = manifest.version; const [owner, repo_name] = (process.env.GITHUB_REPOSITORY ?? "ajayyy/SponsorBlock").split("/"); - return `https://${owner.toLowerCase()}.github.io/${repo_name}/${env.browser}${env.stream === "beta" ? "-beta" : ""}/${version}/`; + const ghpUrl = `https://${owner.toLowerCase()}.github.io/${repo_name}/${env.browser}${env.stream === "beta" ? "-beta" : ""}/${version}/`; + // make a request to the url and check if we got redirected + // firefox doesn't seem to like getting redirected on a source map request + try { + const resp = await fetch(ghpUrl); + return resp.url; + } catch { + return ghpUrl; + } } -module.exports = env => { +module.exports = async env => { let mode = "production"; env.mode = mode; @@ -20,7 +28,7 @@ module.exports = env => { ? { devtool: false, plugins: [new SourceMapDevToolPlugin({ - publicPath: createGHPSourceMapURL(env), + publicPath: await createGHPSourceMapURL(env), filename: '[file].map[query]', })], } From e63a677c81b2e32791dd2e6dd456d7376be8ca24 Mon Sep 17 00:00:00 2001 From: mini-bomba <55105495+mini-bomba@users.noreply.github.com> Date: Fri, 19 Sep 2025 22:59:28 +0200 Subject: [PATCH 7/7] Delay source-maps branch config for source code zip --- .github/workflows/release.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1957dc08cf..d4d8776804 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,15 +16,6 @@ jobs: uses: actions/checkout@v5 with: submodules: recursive - - name: Checkout source maps branch - uses: actions/checkout@v5 - with: - path: source-maps - ref: source-maps - - name: Set up committer info - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - uses: actions/setup-node@v4 with: node-version: '18' @@ -44,6 +35,15 @@ jobs: path: ../builds/SourceCodeUseThisOne.zip repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout source maps branch + uses: actions/checkout@v5 + with: + path: source-maps + ref: source-maps + - name: Set up committer info + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - run: npm ci # Create Firefox artifacts