mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 11:37:02 +03:00
Set up uploading source maps to github pages
This commit is contained in:
77
.github/workflows/release.yml
vendored
77
.github/workflows/release.yml
vendored
@@ -12,9 +12,19 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Initialization
|
# Initialization
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout release branch w/submodules
|
||||||
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
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
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '18'
|
node-version: '18'
|
||||||
@@ -38,8 +48,14 @@ jobs:
|
|||||||
|
|
||||||
# Create Firefox artifacts
|
# Create Firefox artifacts
|
||||||
- name: Create Firefox artifacts
|
- name: Create Firefox artifacts
|
||||||
run: npm run build:firefox
|
run: npm run build:firefox -- --env ghpSourceMaps
|
||||||
- run: mkdir ./builds
|
- 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
|
- name: Zip Artifacts
|
||||||
run: cd ./dist ; zip -r ../builds/FirefoxExtension.zip *
|
run: cd ./dist ; zip -r ../builds/FirefoxExtension.zip *
|
||||||
- name: Upload FirefoxExtension to release
|
- name: Upload FirefoxExtension to release
|
||||||
@@ -52,7 +68,13 @@ jobs:
|
|||||||
|
|
||||||
# Create Chrome artifacts
|
# Create Chrome artifacts
|
||||||
- name: 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
|
- name: Zip Artifacts
|
||||||
run: cd ./dist ; zip -r ../builds/ChromeExtension.zip *
|
run: cd ./dist ; zip -r ../builds/ChromeExtension.zip *
|
||||||
- name: Upload ChromeExtension to release
|
- name: Upload ChromeExtension to release
|
||||||
@@ -67,7 +89,13 @@ jobs:
|
|||||||
- name: Clear dist for Edge
|
- name: Clear dist for Edge
|
||||||
run: rm -rf ./dist
|
run: rm -rf ./dist
|
||||||
- name: Create Edge artifacts
|
- 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
|
- name: Zip Artifacts
|
||||||
run: cd ./dist ; zip -r ../builds/EdgeExtension.zip *
|
run: cd ./dist ; zip -r ../builds/EdgeExtension.zip *
|
||||||
- name: Upload EdgeExtension to release
|
- name: Upload EdgeExtension to release
|
||||||
@@ -80,7 +108,13 @@ jobs:
|
|||||||
|
|
||||||
# Create Safari artifacts
|
# Create Safari artifacts
|
||||||
- name: 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
|
- name: Zip Artifacts
|
||||||
run: cd ./dist ; zip -r ../builds/SafariExtension.zip *
|
run: cd ./dist ; zip -r ../builds/SafariExtension.zip *
|
||||||
- name: Upload SafariExtension to release
|
- name: Upload SafariExtension to release
|
||||||
@@ -93,7 +127,13 @@ jobs:
|
|||||||
|
|
||||||
# Create Beta artifacts (Builds with the name changed to beta)
|
# Create Beta artifacts (Builds with the name changed to beta)
|
||||||
- name: Create Chrome Beta artifacts
|
- 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
|
- name: Zip Artifacts
|
||||||
run: cd ./dist ; zip -r ../builds/ChromeExtensionBeta.zip *
|
run: cd ./dist ; zip -r ../builds/ChromeExtensionBeta.zip *
|
||||||
- name: Upload ChromeExtensionBeta to release
|
- name: Upload ChromeExtensionBeta to release
|
||||||
@@ -106,11 +146,17 @@ jobs:
|
|||||||
|
|
||||||
# Firefox Beta
|
# Firefox Beta
|
||||||
- name: Create Firefox Beta artifacts
|
- 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
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: FirefoxExtensionBeta
|
name: FirefoxExtensionBeta
|
||||||
path: dist
|
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
|
- name: Zip Artifacts
|
||||||
run: cd ./dist ; zip -r ../builds/FirefoxExtensionBeta.zip *
|
run: cd ./dist ; zip -r ../builds/FirefoxExtensionBeta.zip *
|
||||||
|
|
||||||
@@ -135,11 +181,21 @@ jobs:
|
|||||||
path: ./web-ext-artifacts/FirefoxSignedInstaller.xpi
|
path: ./web-ext-artifacts/FirefoxSignedInstaller.xpi
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
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
|
- name: Prepare new github pages deployment
|
||||||
shell: python
|
shell: python
|
||||||
run: |
|
run: |
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import json
|
import json
|
||||||
|
import shutil
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# config stuff
|
# config stuff
|
||||||
@@ -176,6 +232,13 @@ jobs:
|
|||||||
}
|
}
|
||||||
(ghp_dir / "updates.json").write_text(json.dumps(updates))
|
(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
|
- name: Upload new github pages deployment
|
||||||
uses: actions/upload-pages-artifact@v3
|
uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class BuildManifest {
|
|||||||
apply() {
|
apply() {
|
||||||
const distFolder = path.resolve(__dirname, "../dist/");
|
const distFolder = path.resolve(__dirname, "../dist/");
|
||||||
const distManifestFile = path.resolve(distFolder, "manifest.json");
|
const distManifestFile = path.resolve(distFolder, "manifest.json");
|
||||||
|
const [owner, repo_name] = (process.env.GITHUB_REPOSITORY ?? "ajayyy/SponsorBlock").split("/");
|
||||||
|
|
||||||
// Add missing manifest elements
|
// Add missing manifest elements
|
||||||
if (this.options.browser.toLowerCase() === "firefox") {
|
if (this.options.browser.toLowerCase() === "firefox") {
|
||||||
@@ -66,7 +67,6 @@ class BuildManifest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.autoupdate === true && this.options.browser.toLowerCase() === "firefox") {
|
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`;
|
manifest.browser_specific_settings.gecko.update_url = `https://${owner.toLowerCase()}.github.io/${repo_name}/updates.json`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,32 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
|
const { SourceMapDevToolPlugin } = require('webpack');
|
||||||
const { merge } = require('webpack-merge');
|
const { merge } = require('webpack-merge');
|
||||||
const common = require('./webpack.common.js');
|
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 => {
|
module.exports = env => {
|
||||||
let mode = "production";
|
let mode = "production";
|
||||||
env.mode = mode;
|
env.mode = mode;
|
||||||
|
|
||||||
return merge(common(env), {
|
return merge(common(env), {
|
||||||
mode,
|
mode,
|
||||||
devtool: "source-map",
|
...(env.ghpSourceMaps
|
||||||
|
? {
|
||||||
|
devtool: false,
|
||||||
|
plugins: [new SourceMapDevToolPlugin({
|
||||||
|
publicPath: createGHPSourceMapURL(env),
|
||||||
|
filename: '[file].map[query]',
|
||||||
|
})],
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
devtool: "source-map",
|
||||||
|
}
|
||||||
|
),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user