mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Improve publish scripts
This commit is contained in:
parent
69fa0c2e09
commit
30266e5107
4 changed files with 62 additions and 21 deletions
9
Makefile
9
Makefile
|
|
@ -3,7 +3,8 @@ run_options := $(filter-out $@,$(MAKECMDGOALS))
|
|||
|
||||
.PHONY: all clean cleanassets test lint chromium opera firefox npm dig \
|
||||
mv3-chromium mv3-firefox mv3-edge mv3-safari ubol-codemirror \
|
||||
compare maxcost medcost mincost modifiers record wasm
|
||||
compare maxcost medcost mincost modifiers record wasm \
|
||||
publish-chromium publish-edge
|
||||
|
||||
sources := ./dist/version $(shell find ./assets -type f) $(shell find ./src -type f)
|
||||
platform := $(wildcard platform/*/*)
|
||||
|
|
@ -105,6 +106,12 @@ clean:
|
|||
cleanassets:
|
||||
rm -rf dist/build/mv3-data dist/build/uAssets
|
||||
|
||||
publish-chromium:
|
||||
node dist/chromium/publish-chromium.js ghowner=gorhill ghrepo=uBlock ghtag=$(version) cwsid=cjpalhdlnbpafiamejdnhcphjbkeiagm
|
||||
|
||||
publish-edge:
|
||||
node dist/edge/publish-edge.js ghowner=gorhill ghrepo=uBlock ghtag=$(version) edgeid=$(UBO_EDGE_ID)
|
||||
|
||||
# Not real targets, just convenient for auto-completion at shell prompt
|
||||
compare:
|
||||
@echo
|
||||
|
|
|
|||
17
dist/chromium/publish-chromium.js
vendored
17
dist/chromium/publish-chromium.js
vendored
|
|
@ -119,15 +119,24 @@ async function publishToCWS(filePath) {
|
|||
async function main() {
|
||||
if ( githubOwner === '' ) { return 'Need GitHub owner'; }
|
||||
if ( githubRepo === '' ) { return 'Need GitHub repo'; }
|
||||
if ( githubTag === '' ) { return 'Need GitHub tag'; }
|
||||
|
||||
ghapi.setGithubContext(githubOwner, githubRepo, githubTag, githubAuth);
|
||||
|
||||
const assetInfo = await ghapi.getAssetInfo('chromium');
|
||||
if ( assetInfo === undefined ) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`GitHub owner: "${githubOwner}"`);
|
||||
console.log(`GitHub repo: "${githubRepo}"`);
|
||||
console.log(`Release tag: "${githubTag}"`);
|
||||
console.log(`Release asset: "${assetInfo.name}"`);
|
||||
await ghapi.prompt([
|
||||
'Publish to Chrome store:',
|
||||
` GitHub owner: "${githubOwner}"`,
|
||||
` GitHub repo: "${githubRepo}"`,
|
||||
` Release tag: "${githubTag}"`,
|
||||
` Asset name: "${assetInfo.name}"`,
|
||||
` Extension id: ${cwsId}`,
|
||||
` Publish? (enter "yes"): `,
|
||||
].join('\n'));
|
||||
|
||||
// Fetch asset from GitHub repo
|
||||
const filePath = await ghapi.downloadAssetFromRelease(assetInfo);
|
||||
|
|
|
|||
33
dist/edge/publish-edge.js
vendored
33
dist/edge/publish-edge.js
vendored
|
|
@ -35,17 +35,9 @@ const edgeId = commandLineArgs.edgeid;
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
async function sleep(seconds) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, seconds * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
async function publishToEdgeStore(filePath) {
|
||||
const edgeApiKey = process.env.EDGE_APIKEY;
|
||||
const edgeClientId = process.env.EDGE_CLIENTID;
|
||||
const edgeApiKey = process.env.EDGE_API_KEY;
|
||||
const edgeClientId = process.env.EDGE_CLIENT_ID;
|
||||
const uploadURL = `https://api.addons.microsoftedge.microsoft.com/v1/products/${edgeId}/submissions/draft/package`;
|
||||
|
||||
// Read package
|
||||
|
|
@ -79,7 +71,7 @@ async function publishToEdgeStore(filePath) {
|
|||
const interval = 60; // check every 60 seconds
|
||||
let countdown = 60 * 60 / interval; // for at most 60 minutes
|
||||
for (;;) {
|
||||
await sleep(interval);
|
||||
await ghapi.sleep(interval);
|
||||
countdown -= 1
|
||||
if ( countdown <= 0 ) {
|
||||
console.log('Error: Microsoft store timed out')
|
||||
|
|
@ -139,15 +131,24 @@ async function publishToEdgeStore(filePath) {
|
|||
async function main() {
|
||||
if ( githubOwner === '' ) { return 'Need GitHub owner'; }
|
||||
if ( githubRepo === '' ) { return 'Need GitHub repo'; }
|
||||
if ( githubTag === '' ) { return 'Need GitHub tag'; }
|
||||
|
||||
ghapi.setGithubContext(githubOwner, githubRepo, githubTag, githubAuth);
|
||||
|
||||
const assetInfo = await ghapi.getAssetInfo('edge');
|
||||
const assetInfo = await ghapi.getAssetInfo('chromium');
|
||||
if ( assetInfo === undefined ) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`GitHub owner: "${githubOwner}"`);
|
||||
console.log(`GitHub repo: "${githubRepo}"`);
|
||||
console.log(`Release tag: "${githubTag}"`);
|
||||
console.log(`Release asset: "${assetInfo.name}"`);
|
||||
await ghapi.prompt([
|
||||
'Publish to Edge store:',
|
||||
`GitHub owner: "${githubOwner}"`,
|
||||
`GitHub repo: "${githubRepo}"`,
|
||||
`Release tag: "${githubTag}"`,
|
||||
`Asset name: "${assetInfo.name}"`,
|
||||
`Product id: ${edgeId}`,
|
||||
`Publish? (enter "yes"): `,
|
||||
].join('\n'));
|
||||
|
||||
// Fetch asset from GitHub repo
|
||||
const filePath = await ghapi.downloadAssetFromRelease(assetInfo);
|
||||
|
|
|
|||
24
dist/github-api.js
vendored
24
dist/github-api.js
vendored
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
import * as fs from 'node:fs/promises';
|
||||
import * as readline from 'node:readline/promises';
|
||||
import { execSync } from 'node:child_process';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
|
@ -32,6 +33,29 @@ function voidFunc() {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
export async function sleep(seconds) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, seconds * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
export async function prompt(message) {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
const answer = await rl.question(message);
|
||||
if ( answer !== 'yes' ) {
|
||||
console.log('Aborted');
|
||||
process.exit(1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
function reportFetchError(response) {
|
||||
console.log(response.statusText);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue