mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-22 18:32:45 +01:00
[mv3] Add GitHub action to build mv3 separately form uBO
This commit is contained in:
parent
6041757c3d
commit
adb5d503d9
21
.github/workflows/main.yml
vendored
21
.github/workflows/main.yml
vendored
@ -45,18 +45,6 @@ jobs:
|
||||
tools/make-firefox.sh ${{ steps.release_info.outputs.VERSION }}
|
||||
tools/make-thunderbird.sh ${{ steps.release_info.outputs.VERSION }}
|
||||
tools/make-npm.sh ${{ steps.release_info.outputs.VERSION }}
|
||||
- name: Build MV3 packages
|
||||
run: |
|
||||
tools/make-mv3.sh full
|
||||
echo "MV3PACKAGE=$(basename $(ls dist/build/uBlock0_*.mv3.zip))" >> $GITHUB_ENV
|
||||
cp dist/build/uBlock0.mv3/log.txt dist/chromium-mv3/
|
||||
- name: Commit MV3 build log file
|
||||
# https://github.com/marketplace/actions/github-action-for-committing-changes-to-a-repository
|
||||
uses: devops-infra/action-commit-push@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit_message: Update build log file
|
||||
target_branch: master
|
||||
- name: Upload Chromium package
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
@ -93,12 +81,3 @@ jobs:
|
||||
asset_path: dist/build/uBlock0_${{ steps.release_info.outputs.VERSION }}.npm.tgz
|
||||
asset_name: uBlock0_${{ steps.release_info.outputs.VERSION }}.npm.tgz
|
||||
asset_content_type: application/octet-stream
|
||||
- name: Upload Chromium MV3 package
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: dist/build/${{ env.MV3PACKAGE }}
|
||||
asset_name: ${{ env.MV3PACKAGE }}
|
||||
asset_content_type: application/octet-stream
|
||||
|
56
.github/workflows/mv3.yml
vendored
Normal file
56
.github/workflows/mv3.yml
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
name: GitHub CI
|
||||
|
||||
on: workflow_dispatch
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# I used the following project as template to get started:
|
||||
# https://github.com/dessant/search-by-image/blob/master/.github/workflows/ci.yml
|
||||
|
||||
jobs:
|
||||
build:
|
||||
permissions:
|
||||
contents: write # for creating release
|
||||
name: Build packages
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Clone uAssets
|
||||
run: |
|
||||
git submodule update --depth 1 --init
|
||||
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
|
||||
- name: Build uBOLite MV3 packages
|
||||
run: |
|
||||
tools/make-mv3.sh full
|
||||
echo "PACKAGE=$(basename $(ls dist/build/uBOLite_*.mv3.zip))" >> $GITHUB_ENV
|
||||
echo "TAGNAME=$(basename $(ls dist/build/uBOLite_*.mv3.zip) .mv3.zip)" >> $GITHUB_ENV
|
||||
cp dist/build/uBOLite.mv3/log.txt dist/chromium-mv3/
|
||||
- name: Create GitHub release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
with:
|
||||
tag_name: ${{ env.TAGNAME }}
|
||||
release_name: ${{ env.TAGNAME }}
|
||||
prerelease: true
|
||||
- name: Commit uBOLite MV3 build log file
|
||||
# https://github.com/marketplace/actions/github-action-for-committing-changes-to-a-repository
|
||||
uses: devops-infra/action-commit-push@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit_message: Update build log file
|
||||
target_branch: master
|
||||
- name: Upload uBOLite MV3 package
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: dist/build/${{ env.PACKAGE }}
|
||||
asset_name: ${{ env.PACKAGE }}
|
||||
asset_content_type: application/octet-stream
|
@ -31,7 +31,7 @@ import { parsedURLromOrigin } from './utils.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const CSS_TYPE = '0';
|
||||
const CSS_TYPE = '0'; // jshint ignore:line
|
||||
const JS_TYPE = '1';
|
||||
|
||||
/******************************************************************************/
|
||||
@ -108,16 +108,9 @@ const toRegisterable = (fname, entry) => {
|
||||
if ( entry.excludeMatches ) {
|
||||
directive.excludeMatches = matchesFromHostnames(entry.excludeMatches);
|
||||
}
|
||||
if ( fname.at(-1) === CSS_TYPE ) {
|
||||
directive.js = [
|
||||
`/rulesets/css/${fname.slice(0,1)}/${fname.slice(1)}.js`,
|
||||
];
|
||||
directive.runAt = 'document_start';
|
||||
} else if ( fname.at(-1) === JS_TYPE ) {
|
||||
directive.js = [
|
||||
`/rulesets/js/${fname}.js`
|
||||
];
|
||||
directive.runAt = 'document_start';
|
||||
directive.js = [ `/rulesets/js/${fname.slice(0,1)}/${fname.slice(1)}.js` ];
|
||||
directive.runAt = 'document_start';
|
||||
if ( fname.at(-1) === JS_TYPE ) {
|
||||
directive.world = 'MAIN';
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,6 @@ const commandLineArgs = (( ) => {
|
||||
const outputDir = commandLineArgs.get('output') || '.';
|
||||
const cacheDir = `${outputDir}/../mv3-data`;
|
||||
const rulesetDir = `${outputDir}/rulesets`;
|
||||
const cssDir = `${rulesetDir}/css`;
|
||||
const scriptletDir = `${rulesetDir}/js`;
|
||||
const env = [ 'chromium', 'ubol' ];
|
||||
|
||||
@ -457,7 +456,7 @@ async function processCosmeticFilters(assetDetails, mapin) {
|
||||
}
|
||||
};
|
||||
|
||||
let distinctResourceCount = 0;
|
||||
const generatedFiles = [];
|
||||
|
||||
for ( let i = 0; i < cssContentArray.length; i += contentPerFile ) {
|
||||
const slice = cssContentArray.slice(i, i + contentPerFile);
|
||||
@ -481,8 +480,8 @@ async function processCosmeticFilters(assetDetails, mapin) {
|
||||
const fname = uid(patchedScriptlet) + '0';
|
||||
if ( globalPatchedScriptletsSet.has(fname) === false ) {
|
||||
globalPatchedScriptletsSet.add(fname);
|
||||
writeFile(`${cssDir}/${fname.slice(0,1)}/${fname.slice(1)}.js`, patchedScriptlet, {});
|
||||
distinctResourceCount += 1;
|
||||
writeFile(`${scriptletDir}/${fname.slice(0,1)}/${fname.slice(1)}.js`, patchedScriptlet, {});
|
||||
generatedFiles.push(fname);
|
||||
}
|
||||
for ( const entry of slice ) {
|
||||
addScriptingAPIResources(
|
||||
@ -499,9 +498,14 @@ async function processCosmeticFilters(assetDetails, mapin) {
|
||||
);
|
||||
}
|
||||
}
|
||||
log(`CSS entries: ${distinctResourceCount}`);
|
||||
|
||||
return distinctResourceCount;
|
||||
if ( generatedFiles.length !== 0 ) {
|
||||
log(`CSS-related distinct filters: ${cssContentArray.length} distinct combined selectors`);
|
||||
log(`CSS-related injectable files: ${generatedFiles.length}`);
|
||||
log(`\t${generatedFiles}`);
|
||||
}
|
||||
|
||||
return cssContentArray.length;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@ -575,8 +579,8 @@ async function processScriptletFilters(assetDetails, mapin) {
|
||||
y: new Set(),
|
||||
n: new Set(),
|
||||
};
|
||||
argsDetails.set(argsHash, hostnamesDetails);
|
||||
}
|
||||
argsDetails.set(argsHash, hostnamesDetails);
|
||||
if ( entry.matches ) {
|
||||
for ( const hn of entry.matches ) {
|
||||
hostnamesDetails.y.add(hn);
|
||||
@ -589,7 +593,7 @@ async function processScriptletFilters(assetDetails, mapin) {
|
||||
}
|
||||
}
|
||||
|
||||
let distinctResourceCount = 0;
|
||||
const generatedFiles = [];
|
||||
|
||||
const jsonReplacer = (k, v) => {
|
||||
if ( k === 'n' ) {
|
||||
@ -637,8 +641,8 @@ async function processScriptletFilters(assetDetails, mapin) {
|
||||
const fname = uid(patchedScriptlet) + '1';
|
||||
if ( globalPatchedScriptletsSet.has(fname) === false ) {
|
||||
globalPatchedScriptletsSet.add(fname);
|
||||
writeFile(`${scriptletDir}/${fname}.js`, patchedScriptlet, {});
|
||||
distinctResourceCount += 1;
|
||||
writeFile(`${scriptletDir}/${fname.slice(0,1)}/${fname.slice(1)}.js`, patchedScriptlet, {});
|
||||
generatedFiles.push(fname);
|
||||
}
|
||||
for ( const details of argsDetails.values() ) {
|
||||
addScriptingAPIResources(
|
||||
@ -655,9 +659,16 @@ async function processScriptletFilters(assetDetails, mapin) {
|
||||
);
|
||||
}
|
||||
}
|
||||
log(`Scriptlet entries: ${distinctResourceCount}`);
|
||||
|
||||
return distinctResourceCount;
|
||||
if ( generatedFiles.length !== 0 ) {
|
||||
const scriptletFilterCount = Array.from(scriptletDetails.values())
|
||||
.reduce((a, b) => a + b.size, 0);
|
||||
log(`Scriptlet-related distinct filters: ${scriptletFilterCount}`);
|
||||
log(`Scriptlet-related injectable files: ${generatedFiles.length}`);
|
||||
log(`\t${generatedFiles}`);
|
||||
}
|
||||
|
||||
return generatedFiles.length;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
echo "*** uBlock0.mv3: Creating extension"
|
||||
echo "*** uBOLite.mv3: Creating extension"
|
||||
|
||||
DES="dist/build/uBlock0.mv3"
|
||||
DES="dist/build/uBOLite.mv3"
|
||||
|
||||
if [ "$1" != "quick" ]; then
|
||||
rm -rf $DES
|
||||
@ -21,7 +21,7 @@ mkdir -p $DES/css/fonts
|
||||
mkdir -p $DES/js
|
||||
mkdir -p $DES/img
|
||||
|
||||
echo "*** uBlock0.mv3: Copying common files"
|
||||
echo "*** uBOLite.mv3: Copying common files"
|
||||
cp -R src/css/fonts/* $DES/css/fonts/
|
||||
cp src/css/themes/default.css $DES/css/
|
||||
cp src/css/common.css $DES/css/
|
||||
@ -34,7 +34,7 @@ cp src/js/i18n.js $DES/js/
|
||||
|
||||
cp LICENSE.txt $DES/
|
||||
|
||||
echo "*** uBlock0.mv3: Copying mv3-specific files"
|
||||
echo "*** uBOLite.mv3: Copying mv3-specific files"
|
||||
cp platform/mv3/extension/*.html $DES/
|
||||
cp platform/mv3/extension/css/* $DES/css/
|
||||
cp platform/mv3/extension/js/* $DES/js/
|
||||
@ -42,7 +42,7 @@ cp platform/mv3/extension/img/* $DES/img/
|
||||
cp -R platform/mv3/extension/_locales $DES/
|
||||
|
||||
if [ "$1" != "quick" ]; then
|
||||
echo "*** uBlock0.mv3: Generating rulesets"
|
||||
echo "*** uBOLite.mv3: Generating rulesets"
|
||||
TMPDIR=$(mktemp -d)
|
||||
mkdir -p $TMPDIR
|
||||
cp platform/mv3/extension/manifest.json $DES/
|
||||
@ -57,12 +57,12 @@ if [ "$1" != "quick" ]; then
|
||||
rm -rf $TMPDIR
|
||||
fi
|
||||
|
||||
echo "*** uBlock0.mv3: extension ready"
|
||||
echo "*** uBOLite.mv3: extension ready"
|
||||
echo "Extension location: $DES/"
|
||||
|
||||
if [ "$1" = "full" ]; then
|
||||
echo "*** uBlock0.mv3: Creating webstore package..."
|
||||
PACKAGENAME=uBlock0_$(jq -r .version $DES/manifest.json).mv3.zip
|
||||
echo "*** uBOLite.mv3: Creating webstore package..."
|
||||
PACKAGENAME=uBOLite_$(jq -r .version $DES/manifest.json).mv3.zip
|
||||
TMPDIR=$(mktemp -d)
|
||||
mkdir -p $TMPDIR
|
||||
cp -R $DES/* $TMPDIR/
|
||||
|
Loading…
Reference in New Issue
Block a user