deploy firefox beta releases to github pages, enable updates

This commit is contained in:
mini-bomba
2025-08-29 00:16:56 +02:00
parent 9bf892c377
commit bf68ce14c4
3 changed files with 73 additions and 9 deletions

View File

@@ -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

View File

@@ -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 => {
}
};
};
};

View File

@@ -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;