Automatic extension publishing (#453)
This commit is contained in:
parent
0c030a3a27
commit
399305fd8a
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
|
@ -34,28 +34,19 @@ jobs:
|
||||||
- name: Build web
|
- name: Build web
|
||||||
run: pnpm buildWeb --standalone
|
run: pnpm buildWeb --standalone
|
||||||
|
|
||||||
- name: Sign firefox extension
|
|
||||||
run: |
|
|
||||||
pnpx web-ext sign --api-key $WEBEXT_USER --api-secret $WEBEXT_SECRET --channel=unlisted
|
|
||||||
env:
|
|
||||||
WEBEXT_USER: ${{ secrets.WEBEXT_USER }}
|
|
||||||
WEBEXT_SECRET: ${{ secrets.WEBEXT_SECRET }}
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pnpm build --standalone
|
run: pnpm build --standalone
|
||||||
|
|
||||||
- name: Rename extensions for more user friendliness
|
- name: Clean up obsolete files
|
||||||
run: |
|
run: |
|
||||||
mv dist/*.xpi dist/Vencord-for-Firefox.xpi
|
rm -rf dist/extension* Vencord.user.css
|
||||||
mv dist/extension-v3.zip dist/Vencord-for-Chrome-and-Edge.zip
|
|
||||||
rm -rf dist/extension-v2-unpacked dist/extension-v2.zip
|
|
||||||
|
|
||||||
- name: Get some values needed for the release
|
- name: Get some values needed for the release
|
||||||
id: release_values
|
id: release_values
|
||||||
run: |
|
run: |
|
||||||
echo "release_tag=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
echo "release_tag=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Upload Devbuild as release
|
- name: Upload DevBuild as release
|
||||||
run: |
|
run: |
|
||||||
gh release upload devbuild --clobber dist/*
|
gh release upload devbuild --clobber dist/*
|
||||||
gh release edit devbuild --title "DevBuild $RELEASE_TAG"
|
gh release edit devbuild --title "DevBuild $RELEASE_TAG"
|
||||||
|
@ -63,13 +54,15 @@ jobs:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
RELEASE_TAG: ${{ env.release_tag }}
|
RELEASE_TAG: ${{ env.release_tag }}
|
||||||
|
|
||||||
- name: Upload Devbuild to builds repo
|
- name: Upload DevBuild to builds repo
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "$USERNAME"
|
git config --global user.name "$USERNAME"
|
||||||
git config --global user.email actions@github.com
|
git config --global user.email actions@github.com
|
||||||
|
|
||||||
git clone https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git upload
|
git clone https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git upload
|
||||||
cd upload
|
cd upload
|
||||||
|
|
||||||
|
GLOBIGNORE: .git:.gitignore:README.md:LICENSE
|
||||||
rm -rf *
|
rm -rf *
|
||||||
cp -r ../dist/* .
|
cp -r ../dist/* .
|
||||||
|
|
||||||
|
@ -78,6 +71,5 @@ jobs:
|
||||||
git push --force https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git
|
git push --force https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git
|
||||||
env:
|
env:
|
||||||
API_TOKEN: ${{ secrets.BUILDS_TOKEN }}
|
API_TOKEN: ${{ secrets.BUILDS_TOKEN }}
|
||||||
GLOBIGNORE: .git:.gitignore:README.md:LICENSE
|
|
||||||
GH_REPO: Vencord/builds
|
GH_REPO: Vencord/builds
|
||||||
USERNAME: GitHub-Actions
|
USERNAME: GitHub-Actions
|
||||||
|
|
60
.github/workflows/publish.yml
vendored
Normal file
60
.github/workflows/publish.yml
vendored
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
name: Release Browser Extension
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: check that tag matches package.json version
|
||||||
|
run: |
|
||||||
|
pkg_version="$(jq -r .version < package.json)"
|
||||||
|
if [[ "${{ github.ref_name }}" != "$pkg_version" ]]; then
|
||||||
|
echo "Tag ${{ github.ref_name }} does not match package.json version $pkg_version" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v2 # Install pnpm using packageManager key in package.json
|
||||||
|
|
||||||
|
- name: Use Node.js 19
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 19
|
||||||
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Build web
|
||||||
|
run: pnpm buildWeb --standalone
|
||||||
|
|
||||||
|
- name: Publish extension
|
||||||
|
run: |
|
||||||
|
cd dist/extension-unpacked
|
||||||
|
|
||||||
|
# Do not fail so that even if chrome fails, firefox gets a shot. But also store exit code to fail workflow later
|
||||||
|
EXIT_CODE=0
|
||||||
|
|
||||||
|
# Chrome
|
||||||
|
pnpx chrome-webstore-upload-cli@2.1.0 upload --auto-publish || EXIT_CODE=$?
|
||||||
|
|
||||||
|
# Firefox
|
||||||
|
pnpx web-ext-submit@7.4.0
|
||||||
|
|
||||||
|
exit $EXIT_CODE
|
||||||
|
env:
|
||||||
|
# Chrome
|
||||||
|
EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
|
||||||
|
CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
|
||||||
|
CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
|
||||||
|
REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
|
||||||
|
|
||||||
|
# Firefox
|
||||||
|
WEB_EXT_API_KEY: ${{ secrets.WEBEXT_USER }}
|
||||||
|
WEB_EXT_API_SECRET: ${{ secrets.WEBEXT_SECRET }}
|
||||||
|
|
|
@ -18,11 +18,9 @@ The cutest Discord client mod
|
||||||
|
|
||||||
## Installing on Browser
|
## Installing on Browser
|
||||||
|
|
||||||
[![Get the Firefox extension](https://blog.mozilla.org/addons/files/2015/11/get-the-addon-small.png)](https://addons.mozilla.org/en-GB/firefox/addon/vencord-web/)
|
[![Get it on the Firefox Webstore](https://blog.mozilla.org/addons/files/2015/11/get-the-addon.png)](https://addons.mozilla.org/en-GB/firefox/addon/vencord-web/) [![Get it on the Chrome Webstore](https://storage.googleapis.com/web-dev-uploads/image/WlD8wC6g8khYWPJUsQceQkhXSlv1/UV4C4ybeBTsZt43U4xis.png)](https://chrome.google.com/webstore/detail/vencord-web/cbghhgpcnddeihccjmnadmkaejncjndb)
|
||||||
|
|
||||||
Or install the browser extension for
|
Or use the [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js) - Please note that QuickCSS and plugins making use of external resources will not work with the UserScript.
|
||||||
- [![Chrome](https://img.shields.io/badge/chrome-ext-brightgreen)](https://github.com/Vendicated/Vencord/releases/latest/download/Vencord-for-Chrome-and-Edge.zip)
|
|
||||||
- [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js) - Please note that QuickCSS, shiki and other plugins making use of external resources will not work with the UserScript.
|
|
||||||
|
|
||||||
## Building from Source
|
## Building from Source
|
||||||
|
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2022 Linnea Gräf
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setContentTypeOnStylesheets(details) {
|
|
||||||
if (details.type === "stylesheet") {
|
|
||||||
details.responseHeaders = details.responseHeaders.filter(it => it.name.toLowerCase() !== 'content-type');
|
|
||||||
details.responseHeaders.push({ name: "Content-Type", value: "text/css" });
|
|
||||||
}
|
|
||||||
return { responseHeaders: details.responseHeaders };
|
|
||||||
}
|
|
||||||
|
|
||||||
var cspHeaders = [
|
|
||||||
"content-security-policy",
|
|
||||||
"content-security-policy-report-only",
|
|
||||||
];
|
|
||||||
|
|
||||||
function removeCSPHeaders(details) {
|
|
||||||
return {
|
|
||||||
responseHeaders: details.responseHeaders.filter(header =>
|
|
||||||
!cspHeaders.includes(header.name.toLowerCase()))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
browser.webRequest.onHeadersReceived.addListener(
|
|
||||||
setContentTypeOnStylesheets, { urls: ["https://raw.githubusercontent.com/*"] }, ["blocking", "responseHeaders"]
|
|
||||||
);
|
|
||||||
|
|
||||||
browser.webRequest.onHeadersReceived.addListener(
|
|
||||||
removeCSPHeaders, { urls: ["https://raw.githubusercontent.com/*", "*://*.discord.com/*"] }, ["blocking", "responseHeaders"]
|
|
||||||
);
|
|
BIN
browser/icon.png
Normal file
BIN
browser/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
|
@ -1,10 +1,14 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
|
"minimum_chrome_version": "91",
|
||||||
|
|
||||||
"name": "Vencord Web",
|
"name": "Vencord Web",
|
||||||
"description": "Yeee",
|
"description": "The cutest Discord mod now in your browser",
|
||||||
"version": "1.0.0",
|
|
||||||
"author": "Vendicated",
|
"author": "Vendicated",
|
||||||
"homepage_url": "https://github.com/Vendicated/Vencord",
|
"homepage_url": "https://github.com/Vendicated/Vencord",
|
||||||
|
"icons": {
|
||||||
|
"128": "icon.png"
|
||||||
|
},
|
||||||
|
|
||||||
"host_permissions": [
|
"host_permissions": [
|
||||||
"*://*.discord.com/*",
|
"*://*.discord.com/*",
|
||||||
|
@ -36,5 +40,12 @@
|
||||||
"path": "modifyResponseHeaders.json"
|
"path": "modifyResponseHeaders.json"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"applications": {
|
||||||
|
"gecko": {
|
||||||
|
"id": "vencord-firefox@vendicated.dev",
|
||||||
|
"strict_min_version": "109.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,25 +0,0 @@
|
||||||
{
|
|
||||||
"manifest_version": 2,
|
|
||||||
"name": "Vencord Web",
|
|
||||||
"description": "The Vencord Client Mod for Discord Web.",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"author": "Vendicated",
|
|
||||||
"homepage_url": "https://github.com/Vendicated/Vencord",
|
|
||||||
"permissions": [
|
|
||||||
"webRequest",
|
|
||||||
"webRequestBlocking",
|
|
||||||
"*://*.discord.com/*",
|
|
||||||
"https://raw.githubusercontent.com/*"
|
|
||||||
],
|
|
||||||
"content_scripts": [
|
|
||||||
{
|
|
||||||
"run_at": "document_start",
|
|
||||||
"matches": ["*://*.discord.com/*"],
|
|
||||||
"js": ["content.js"]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"web_accessible_resources": ["dist/Vencord.js", "dist/Vencord.css"],
|
|
||||||
"background": {
|
|
||||||
"scripts": ["background.js"]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -82,10 +82,19 @@ async function buildPluginZip(target, files, shouldZip) {
|
||||||
const entries = {
|
const entries = {
|
||||||
"dist/Vencord.js": await readFile("dist/browser.js"),
|
"dist/Vencord.js": await readFile("dist/browser.js"),
|
||||||
"dist/Vencord.css": await readFile("dist/browser.css"),
|
"dist/Vencord.css": await readFile("dist/browser.css"),
|
||||||
...Object.fromEntries(await Promise.all(files.map(async f => [
|
...Object.fromEntries(await Promise.all(files.map(async f => {
|
||||||
(f.startsWith("manifest") ? "manifest.json" : f),
|
let content = await readFile(join("browser", f));
|
||||||
await readFile(join("browser", f))
|
if (f.startsWith("manifest")) {
|
||||||
]))),
|
const json = JSON.parse(content.toString("utf-8"));
|
||||||
|
json.version = PackageJSON.version;
|
||||||
|
content = new TextEncoder().encode(JSON.stringify(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
f.startsWith("manifest") ? "manifest.json" : f,
|
||||||
|
content
|
||||||
|
];
|
||||||
|
}))),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (shouldZip) {
|
if (shouldZip) {
|
||||||
|
@ -115,20 +124,22 @@ async function buildPluginZip(target, files, shouldZip) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cssText = "`" + readFileSync("dist/Vencord.user.css", "utf-8").replaceAll("`", "\\`") + "`";
|
const appendCssRuntime = readFile("dist/Vencord.user.css", "utf-8").then(content => {
|
||||||
const cssRuntime = `
|
const cssRuntime = `
|
||||||
;document.addEventListener("DOMContentLoaded", () => document.documentElement.appendChild(
|
;document.addEventListener("DOMContentLoaded", () => document.documentElement.appendChild(
|
||||||
Object.assign(document.createElement("style"), {
|
Object.assign(document.createElement("style"), {
|
||||||
textContent: ${cssText},
|
textContent: \`${content.replaceAll("`", "\\`")}\`,
|
||||||
id: "vencord-css-core"
|
id: "vencord-css-core"
|
||||||
})
|
})
|
||||||
), { once: true });
|
), { once: true });
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
return appendFile("dist/Vencord.user.js", cssRuntime);
|
||||||
|
});
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
appendFile("dist/Vencord.user.js", cssRuntime),
|
appendCssRuntime,
|
||||||
buildPluginZip("extension-v3.zip", ["modifyResponseHeaders.json", "content.js", "manifestv3.json"], true),
|
buildPluginZip("extension.zip", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], true),
|
||||||
buildPluginZip("extension-v2.zip", ["background.js", "content.js", "manifestv2.json"], true),
|
buildPluginZip("extension-unpacked", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], false),
|
||||||
buildPluginZip("extension-v2-unpacked", ["background.js", "content.js", "manifestv2.json"], false),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue