mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 03:27:03 +03:00
deploy firefox beta releases to github pages, enable updates
This commit is contained in:
63
.github/workflows/release.yml
vendored
63
.github/workflows/release.yml
vendored
@@ -106,7 +106,7 @@ jobs:
|
||||
|
||||
# Firefox Beta
|
||||
- name: Create Firefox Beta artifacts
|
||||
run: npm run build:firefox -- --env stream=beta
|
||||
run: npm run build:firefox -- --env stream=beta --env autoupdate
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: FirefoxExtensionBeta
|
||||
@@ -120,10 +120,8 @@ jobs:
|
||||
env:
|
||||
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
|
||||
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
|
||||
- name: Install rename
|
||||
run: sudo apt-get install rename
|
||||
- name: Rename signed file
|
||||
run: cd ./web-ext-artifacts ; rename 's/.*/FirefoxSignedInstaller.xpi/' *
|
||||
run: mv ./web-ext-artifacts/* ./web-ext-artifacts/FirefoxSignedInstaller.xpi
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: FirefoxExtensionSigned.xpi
|
||||
@@ -137,3 +135,60 @@ jobs:
|
||||
path: ./web-ext-artifacts/FirefoxSignedInstaller.xpi
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Prepare new github pages deployment
|
||||
shell: python
|
||||
run: |
|
||||
from pathlib import Path
|
||||
import json
|
||||
import os
|
||||
|
||||
# config stuff
|
||||
installer_name = "FirefoxSignedInstaller.xpi"
|
||||
owner, repo_name = os.environ["GITHUB_REPOSITORY"].split("/")
|
||||
owner = owner.lower()
|
||||
|
||||
# create the github paged dir
|
||||
ghp_dir = Path("./github-pages")
|
||||
ghp_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# move in the installer
|
||||
Path("./web-ext-artifacts", installer_name).rename(ghp_dir / installer_name)
|
||||
|
||||
# read manifest.json and extract parameters
|
||||
with open("./dist/manifest.json") as f:
|
||||
manifest = json.load(f)
|
||||
current_version = manifest["version"]
|
||||
ext_id = manifest["browser_specific_settings"]["gecko"]["id"]
|
||||
|
||||
# generate updates file
|
||||
updates = {
|
||||
"addons": {
|
||||
ext_id: {
|
||||
"updates": [
|
||||
{
|
||||
"version": current_version,
|
||||
# param doesn't actually matter, it's just a cachebuster
|
||||
"update_link": f"https://{owner}.github.io/{repo_name}/{installer_name}?v={current_version}",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
(ghp_dir / "updates.json").write_text(json.dumps(updates))
|
||||
|
||||
- name: Upload new github pages deployment
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: ./github-pages
|
||||
|
||||
deploy-ghp:
|
||||
name: Deploy to github pages
|
||||
needs: build
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
@@ -189,7 +189,8 @@ module.exports = env => {
|
||||
new BuildManifest({
|
||||
browser: env.browser,
|
||||
pretty: env.mode === "production",
|
||||
stream: env.stream
|
||||
stream: env.stream,
|
||||
autoupdate: env.autoupdate,
|
||||
}),
|
||||
new configDiffPlugin()
|
||||
],
|
||||
@@ -200,4 +201,4 @@ module.exports = env => {
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -23,10 +23,13 @@ const schema = {
|
||||
pretty: {
|
||||
type: 'boolean'
|
||||
},
|
||||
steam: {
|
||||
stream: {
|
||||
type: 'string'
|
||||
},
|
||||
autoupdate: {
|
||||
type: 'boolean',
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class BuildManifest {
|
||||
@@ -62,6 +65,11 @@ class BuildManifest {
|
||||
}
|
||||
}
|
||||
|
||||
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`;
|
||||
}
|
||||
|
||||
let result = JSON.stringify(manifest);
|
||||
if (this.options.pretty) result = JSON.stringify(manifest, null, 2);
|
||||
|
||||
@@ -86,4 +94,4 @@ function mergeObjects(object1, object2) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BuildManifest;
|
||||
module.exports = BuildManifest;
|
||||
|
||||
Reference in New Issue
Block a user