diff --git a/.github/workflows/insider-spearhead.yml b/.github/workflows/insider-spearhead.yml index dc1a7f4..077668c 100644 --- a/.github/workflows/insider-spearhead.yml +++ b/.github/workflows/insider-spearhead.yml @@ -28,6 +28,7 @@ jobs: GH_REPO_PATH: ${{ github.repository }} ORG_NAME: ${{ github.repository_owner }} OS_NAME: osx + SOURCEMAPS_REPOSITORY: ${{ github.repository_owner }}/sourcemaps VERSIONS_REPOSITORY: ${{ github.repository_owner }}/versions VSCODE_ARCH: arm64 VSCODE_LATEST: ${{ github.event.inputs.dont_update == 'true' && 'no' || 'yes' }} @@ -76,6 +77,10 @@ jobs: run: ./prepare_src.sh if: env.SHOULD_BUILD == 'yes' + - name: Upload sourcemaps + run: ./upload_sourcemaps.sh + if: env.SHOULD_BUILD == 'yes' + - name: Release source env: GITHUB_TOKEN: ${{ secrets.STRONGER_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 55ba937..9bc350f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,6 @@ build/linux/appimage/VSCodium build/windows/msi/releasedir build/windows/msi/Files*.wxs build/windows/msi/Files*.wixobj +sourcemaps/ stores/snapcraft/insider/*.snap stores/snapcraft/stable/*.snap diff --git a/patches/sourcemaps.patch b/patches/sourcemaps.patch new file mode 100644 index 0000000..01b7b5a --- /dev/null +++ b/patches/sourcemaps.patch @@ -0,0 +1,104 @@ +diff --git a/build/gulpfile.extensions.js b/build/gulpfile.extensions.js +index 7826f48..ff0e2f0 100644 +--- a/build/gulpfile.extensions.js ++++ b/build/gulpfile.extensions.js +@@ -74,3 +74,3 @@ const compilations = [ + +-const getBaseUrl = out => `https://main.vscode-cdn.net/sourcemaps/${commit}/${out}`; ++const getBaseUrl = out => `https://github.com/VSCodium/sourcemaps/releases/download/${commit}/${out.replaceAll('/', '-')}`; + +diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js +index 10b7b44..895b25b 100644 +--- a/build/gulpfile.reh.js ++++ b/build/gulpfile.reh.js +@@ -454,3 +454,3 @@ function tweakProductForServerWeb(product) { + util.rimraf(`out-vscode-${type}-min`), +- optimize.minifyTask(`out-vscode-${type}`, `https://main.vscode-cdn.net/sourcemaps/${commit}/core`) ++ optimize.minifyTask(`out-vscode-${type}`, `https://github.com/VSCodium/sourcemaps/releases/download/${commit}/core`) + )); +diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js +index ed06b6a..ebedfc4 100644 +--- a/build/gulpfile.vscode.js ++++ b/build/gulpfile.vscode.js +@@ -147,3 +147,3 @@ gulp.task(bundleVSCodeTask); + +-const sourceMappingURLBase = `https://main.vscode-cdn.net/sourcemaps/${commit}`; ++const sourceMappingURLBase = `https://github.com/VSCodium/sourcemaps/releases/download/${commit}`; + const minifyVSCodeTask = task.define('minify-vscode', task.series( +diff --git a/build/gulpfile.vscode.web.js b/build/gulpfile.vscode.web.js +index 295a977..ba0a598 100644 +--- a/build/gulpfile.vscode.web.js ++++ b/build/gulpfile.vscode.web.js +@@ -140,3 +140,3 @@ const minifyVSCodeWebTask = task.define('minify-vscode-web', task.series( + util.rimraf('out-vscode-web-min'), +- optimize.minifyTask('out-vscode-web', `https://main.vscode-cdn.net/sourcemaps/${commit}/core`) ++ optimize.minifyTask('out-vscode-web', `https://github.com/VSCodium/sourcemaps/releases/download/${commit}/core`) + )); +diff --git a/build/lib/extensions.js b/build/lib/extensions.js +index c80a1be..000cf9f 100644 +--- a/build/lib/extensions.js ++++ b/build/lib/extensions.js +@@ -76,3 +76,3 @@ const root = path_1.default.dirname(path_1.default.dirname(__dirname)); + const commit = (0, getVersion_1.getVersion)(root); +-const sourceMappingURLBase = `https://main.vscode-cdn.net/sourcemaps/${commit}`; ++const sourceMappingURLBase = `https://github.com/VSCodium/sourcemaps/releases/download/${commit}`; + function minifyExtensionResources(input) { +@@ -205,3 +205,3 @@ function fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle) { + data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) { +- return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path_1.default.basename(extensionPath)}/${relativeOutputPath}/${g1}`; ++ return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions-${path_1.default.basename(extensionPath).replaceAll('/', '-')}-${relativeOutputPath.replaceAll('/', '-')}-${g1.replaceAll('/', '-')}`; + }), 'utf8'); +diff --git a/build/lib/extensions.ts b/build/lib/extensions.ts +index 9e7cf9f..e5f7c24 100644 +--- a/build/lib/extensions.ts ++++ b/build/lib/extensions.ts +@@ -31,3 +31,3 @@ const root = path.dirname(path.dirname(__dirname)); + const commit = getVersion(root); +-const sourceMappingURLBase = `https://main.vscode-cdn.net/sourcemaps/${commit}`; ++const sourceMappingURLBase = `https://github.com/VSCodium/sourcemaps/releases/download/${commit}`; + +@@ -179,3 +179,3 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string, + data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) { +- return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/${relativeOutputPath}/${g1}`; ++ return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions-${path.basename(extensionPath).replaceAll('/', '-')}-${relativeOutputPath.replaceAll('/', '-')}-${g1.replaceAll('/', '-')}`; + }), 'utf8'); +diff --git a/build/lib/optimize.js b/build/lib/optimize.js +index fbc455b..4e7fe85 100644 +--- a/build/lib/optimize.js ++++ b/build/lib/optimize.js +@@ -186,3 +186,3 @@ function bundleTask(opts) { + function minifyTask(src, sourceMapBaseUrl) { +- const sourceMappingURL = sourceMapBaseUrl ? ((f) => `${sourceMapBaseUrl}/${f.relative}.map`) : undefined; ++ const sourceMappingURL = sourceMapBaseUrl ? ((f) => `${sourceMapBaseUrl}-${f.relative.replaceAll('/', '-')}.map`) : undefined; + return cb => { +diff --git a/build/lib/optimize.ts b/build/lib/optimize.ts +index d89d0d6..fca30cf 100644 +--- a/build/lib/optimize.ts ++++ b/build/lib/optimize.ts +@@ -211,3 +211,3 @@ export function bundleTask(opts: IBundleESMTaskOpts): () => NodeJS.ReadWriteStre + export function minifyTask(src: string, sourceMapBaseUrl?: string): (cb: any) => void { +- const sourceMappingURL = sourceMapBaseUrl ? ((f: any) => `${sourceMapBaseUrl}/${f.relative}.map`) : undefined; ++ const sourceMappingURL = sourceMapBaseUrl ? ((f: any) => `${sourceMapBaseUrl}-${f.relative.replaceAll('/', '-')}.map`) : undefined; + +diff --git a/build/lib/util.js b/build/lib/util.js +index 389b9e0..9abdb3c 100644 +--- a/build/lib/util.js ++++ b/build/lib/util.js +@@ -235,4 +235,4 @@ function rewriteSourceMappingURL(sourceMappingURLBase) { + const contents = f.contents.toString('utf8'); +- const str = `//# sourceMappingURL=${sourceMappingURLBase}/${path_1.default.dirname(f.relative).replace(/\\/g, '/')}/$1`; +- f.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, str)); ++ const fp = path_1.default.dirname(f.relative).replace(/\\/g, '/').replaceAll('/', '-'); ++ f.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, (_m, p) => `//# sourceMappingURL=${sourceMappingURLBase}/${fp}-${p.replaceAll('/', '-')}`)); + return f; +diff --git a/build/lib/util.ts b/build/lib/util.ts +index 4931342..833091c 100644 +--- a/build/lib/util.ts ++++ b/build/lib/util.ts +@@ -285,4 +285,4 @@ export function rewriteSourceMappingURL(sourceMappingURLBase: string): NodeJS.Re + const contents = (f.contents).toString('utf8'); +- const str = `//# sourceMappingURL=${sourceMappingURLBase}/${path.dirname(f.relative).replace(/\\/g, '/')}/$1`; +- f.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, str)); ++ const fp = path.dirname(f.relative).replace(/\\/g, '/').replaceAll('/', '-'); ++ f.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, (_m, p) => `//# sourceMappingURL=${sourceMappingURLBase}/${fp}-${p.replaceAll('/', '-')}`)); + return f; diff --git a/upload_sourcemaps.sh b/upload_sourcemaps.sh new file mode 100755 index 0000000..8d66ee6 --- /dev/null +++ b/upload_sourcemaps.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +set -e + +npm install -g checksum github-release-cli + +mkdir -p sourcemaps +cd sourcemaps + +SOURCE_DIR="../vscode/.build/extensions" +DESTINATION_DIR="extensions" + +find "${SOURCE_DIR}" -type f -name "*.js.map" | while read -r SOURCE_FILE_PATH; do + RELATIVE_PATH="${SOURCE_FILE_PATH#$SOURCE_DIR/}" + FLATTENED_FILENAME="${RELATIVE_PATH//\//-}" + + cp "${SOURCE_FILE_PATH}" "$DESTINATION_DIR-${FLATTENED_FILENAME}" +done + +SOURCE_DIR="../vscode/out-vscode-min" +DESTINATION_DIR="core" + +find "${SOURCE_DIR}" -type f -name "*.js.map" | while read -r SOURCE_FILE_PATH; do + RELATIVE_PATH="${SOURCE_FILE_PATH#$SOURCE_DIR/}" + FLATTENED_FILENAME="${RELATIVE_PATH//\//-}" + + cp "${SOURCE_FILE_PATH}" "$DESTINATION_DIR-${FLATTENED_FILENAME}" +done + +find . -type f -exec checksum -a sha256 {} \; > checksum.txt + +checksum -a sha256 checksum.txt > checksum.txt.sha256 + +REPOSITORY_OWNER="${SOURCEMAPS_REPOSITORY/\/*/}" +REPOSITORY_NAME="${SOURCEMAPS_REPOSITORY/*\//}" + +gh release create "${BUILD_SOURCEVERSION}" --repo "${SOURCEMAPS_REPOSITORY}" --title "${RELEASE_VERSION}" + +set +e + +for FILE in *; do + if [[ -f "${FILE}" ]]; then + echo "::group::Uploading '${FILE}' at $( date "+%T" )" + gh release upload --repo "${SOURCEMAPS_REPOSITORY}" "${RELEASE_VERSION}" "${FILE}" + + EXIT_STATUS=$? + echo "exit: ${EXIT_STATUS}" + + if (( "${EXIT_STATUS}" )); then + for (( i=0; i<10; i++ )); do + github-release delete --owner "${REPOSITORY_OWNER}" --repo "${REPOSITORY_NAME}" --tag "${BUILD_SOURCEVERSION}" "${FILE}" + + sleep $(( 15 * (i + 1))) + + echo "RE-Uploading '${FILE}' at $( date "+%T" )" + gh release upload --repo "${SOURCEMAPS_REPOSITORY}" "${BUILD_SOURCEVERSION}" "${FILE}" + + EXIT_STATUS=$? + echo "exit: ${EXIT_STATUS}" + + if ! (( "${EXIT_STATUS}" )); then + break + fi + done + echo "exit: ${EXIT_STATUS}" + + if (( "${EXIT_STATUS}" )); then + echo "'${FILE}' hasn't been uploaded!" + + github-release delete --owner "${REPOSITORY_OWNER}" --repo "${REPOSITORY_NAME}" --tag "${BUILD_SOURCEVERSION}" "${FILE}" + + exit 1 + fi + fi + + echo "::endgroup::" + fi +done + +cd ..