Skip to content

Commit bf68ce1

Browse files
committed
deploy firefox beta releases to github pages, enable updates
1 parent 9bf892c commit bf68ce1

File tree

3 files changed

+73
-9
lines changed

3 files changed

+73
-9
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106

107107
# Firefox Beta
108108
- name: Create Firefox Beta artifacts
109-
run: npm run build:firefox -- --env stream=beta
109+
run: npm run build:firefox -- --env stream=beta --env autoupdate
110110
- uses: actions/upload-artifact@v4
111111
with:
112112
name: FirefoxExtensionBeta
@@ -120,10 +120,8 @@ jobs:
120120
env:
121121
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
122122
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}
123-
- name: Install rename
124-
run: sudo apt-get install rename
125123
- name: Rename signed file
126-
run: cd ./web-ext-artifacts ; rename 's/.*/FirefoxSignedInstaller.xpi/' *
124+
run: mv ./web-ext-artifacts/* ./web-ext-artifacts/FirefoxSignedInstaller.xpi
127125
- uses: actions/upload-artifact@v4
128126
with:
129127
name: FirefoxExtensionSigned.xpi
@@ -137,3 +135,60 @@ jobs:
137135
path: ./web-ext-artifacts/FirefoxSignedInstaller.xpi
138136
repo-token: ${{ secrets.GITHUB_TOKEN }}
139137

138+
- name: Prepare new github pages deployment
139+
shell: python
140+
run: |
141+
from pathlib import Path
142+
import json
143+
import os
144+
145+
# config stuff
146+
installer_name = "FirefoxSignedInstaller.xpi"
147+
owner, repo_name = os.environ["GITHUB_REPOSITORY"].split("/")
148+
owner = owner.lower()
149+
150+
# create the github paged dir
151+
ghp_dir = Path("./github-pages")
152+
ghp_dir.mkdir(parents=True, exist_ok=True)
153+
154+
# move in the installer
155+
Path("./web-ext-artifacts", installer_name).rename(ghp_dir / installer_name)
156+
157+
# read manifest.json and extract parameters
158+
with open("./dist/manifest.json") as f:
159+
manifest = json.load(f)
160+
current_version = manifest["version"]
161+
ext_id = manifest["browser_specific_settings"]["gecko"]["id"]
162+
163+
# generate updates file
164+
updates = {
165+
"addons": {
166+
ext_id: {
167+
"updates": [
168+
{
169+
"version": current_version,
170+
# param doesn't actually matter, it's just a cachebuster
171+
"update_link": f"https://{owner}.github.io/{repo_name}/{installer_name}?v={current_version}",
172+
},
173+
],
174+
},
175+
},
176+
}
177+
(ghp_dir / "updates.json").write_text(json.dumps(updates))
178+
179+
- name: Upload new github pages deployment
180+
uses: actions/upload-pages-artifact@v3
181+
with:
182+
path: ./github-pages
183+
184+
deploy-ghp:
185+
name: Deploy to github pages
186+
needs: build
187+
environment:
188+
name: github-pages
189+
url: ${{ steps.deployment.outputs.page_url }}
190+
runs-on: ubuntu-latest
191+
steps:
192+
- name: Deploy
193+
id: deployment
194+
uses: actions/deploy-pages@v4

webpack/webpack.common.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ module.exports = env => {
189189
new BuildManifest({
190190
browser: env.browser,
191191
pretty: env.mode === "production",
192-
stream: env.stream
192+
stream: env.stream,
193+
autoupdate: env.autoupdate,
193194
}),
194195
new configDiffPlugin()
195196
],
@@ -200,4 +201,4 @@ module.exports = env => {
200201
}
201202

202203
};
203-
};
204+
};

webpack/webpack.manifest.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ const schema = {
2323
pretty: {
2424
type: 'boolean'
2525
},
26-
steam: {
26+
stream: {
2727
type: 'string'
28+
},
29+
autoupdate: {
30+
type: 'boolean',
2831
}
29-
}
32+
}
3033
};
3134

3235
class BuildManifest {
@@ -62,6 +65,11 @@ class BuildManifest {
6265
}
6366
}
6467

68+
if (this.options.autoupdate === true && this.options.browser.toLowerCase() === "firefox") {
69+
const [owner, repo_name] = process.env.GITHUB_REPOSITORY.split("/");
70+
manifest.browser_specific_settings.gecko.update_url = `https://${owner.toLowerCase()}.github.io/${repo_name}/updates.json`;
71+
}
72+
6573
let result = JSON.stringify(manifest);
6674
if (this.options.pretty) result = JSON.stringify(manifest, null, 2);
6775

@@ -86,4 +94,4 @@ function mergeObjects(object1, object2) {
8694
}
8795
}
8896

89-
module.exports = BuildManifest;
97+
module.exports = BuildManifest;

0 commit comments

Comments
 (0)