From bf68ce14c4e75dd8af49cbcc99c6912ff19cbef7 Mon Sep 17 00:00:00 2001 From: mini-bomba <55105495+mini-bomba@users.noreply.github.com> Date: Fri, 29 Aug 2025 00:16:56 +0200 Subject: [PATCH] deploy firefox beta releases to github pages, enable updates --- .github/workflows/release.yml | 63 ++++++++++++++++++++++++++++++++--- webpack/webpack.common.js | 5 +-- webpack/webpack.manifest.js | 14 ++++++-- 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 916dbc6a..83d8c09b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index 3db98d13..512bb7df 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -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 => { } }; -}; \ No newline at end of file +}; diff --git a/webpack/webpack.manifest.js b/webpack/webpack.manifest.js index 1666c8a1..b89bcce5 100644 --- a/webpack/webpack.manifest.js +++ b/webpack/webpack.manifest.js @@ -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; \ No newline at end of file +module.exports = BuildManifest;