Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
HarlemSquirrel committed May 17, 2024
1 parent efb8213 commit 7e0dd53
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 21 deletions.
60 changes: 48 additions & 12 deletions .github/publish-firefox-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const options = {

async function main() {
const manifest = require('../manifest.json');
const manifestFirefox = require('../manifest.firefox.json');
const addonUUID = manifestFirefox.browser_specific_settings.gecko.id;
const fileName = `keeweb_connect-${manifest.version}.zip`
const filePath = `web-ext-artifacts/${fileName}`
const fileBuffer = fs.createReadStream(filePath);
Expand Down Expand Up @@ -58,19 +60,53 @@ async function main() {

console.log('response.status:', res.status);
console.log('response.body:', resData);
const uuid = resData.uuid;

// TODO: send patch to add-ons edit endpoint OR version edit endpoint
// https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#edit
// https://mozilla.github.io/addons-server/topics/api/addons.html#version-edit
const addonPatchURL = `https://addons.mozilla.org/api/v5/addons/addon/${uuid}/`;
const addonPatchPayload = {
slug: "new-slug", // what?
tags: [] // what tags?
const uploadUUID = resData.uuid;

// Poll the upload detail endpoint until we are validated
// https://mozilla.github.io/addons-server/topics/api/addons.html#upload-detail
var validationRes;
var validationData;
var validationTries = 0;
const validationReq = new Request(`https://addons.mozilla.org/api/v5/addons/upload/${uploadUUID}/`, {
method: 'GET'
})
validationReq.headers.append('Authorization', `JWT ${token}`);
validationReq.headers.append('Accept', 'application/json');

while (validationTries < 3 && !validationData?.valid) {
// Increasingly wait before checking the validation status
await new Promise(resolve => setTimeout(resolve, 60_000 * (validationTries + 1)));

validationTries += 1;
var validationRes = await fetch(validationReq);
validationData = await validationRes.json();

console.log('validationData', validationData);
console.log('validationData.validation.messages', validationData.validation?.messages);
}
const req = new Request(addonPatchURL, {
method: 'PATCH',
body: addonPatchPayload,

if (!validationData?.valid)
throw new Error('Extension did not validate in time.');

// Send POST to add-on version create endpoint
// https://mozilla.github.io/addons-server/topics/api/addons.html#version-create
const addonVersionCreateURL = `https://addons.mozilla.org/api/v5/addons/addon/${addonUUID}/versions/`;
const addonVersionCreatePayload = {
license: 'MIT',
upload: uploadUUID
}
const addonVersionCreateReq = new Request(addonVersionCreateURL, {
method: 'POST',
body: addonVersionCreatePayload,
})
addonVersionCreateReq.headers.append('Authorization', `JWT ${token}`);
addonVersionCreateReq.headers.append('Accept', 'application/json');
fetch(addonVersionCreateReq).then(async (res) => {
if (!res.ok)
throw new Error(`HTTP error! status: ${res.status}, body: `, resData);

console.log('response.status:', res.status);
console.log('response.body:', resData);
})

//TODO do we need to submit source code?
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/publish-firefox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
run: |
npm run build-firefox
npx web-ext build -s dist/firefox
- name: Sign
id: sign
env:
WEB_EXT_API_KEY: ${{ vars.FIREFOX_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.FIREFOX_API_SECRET }}
run: |
npx web-ext sign --source-dir=./dist/firefox
echo "xpi_filepath=$(ls web-ext-artifacts/*.xpi)" >> "$GITHUB_OUTPUT"
# - name: Sign
# id: sign
# env:
# WEB_EXT_API_KEY: ${{ vars.FIREFOX_API_KEY }}
# WEB_EXT_API_SECRET: ${{ secrets.FIREFOX_API_SECRET }}
# run: |
# npx web-ext sign --source-dir=./dist/firefox
# echo "xpi_filepath=$(ls web-ext-artifacts/*.xpi)" >> "$GITHUB_OUTPUT"
- name: Publish
env:
WEB_EXT_API_KEY: ${{ vars.FIREFOX_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "KeeWeb Connect",
"version": "0.3.7.11",
"version": "0.3.7.13",
"manifest_version": 2,
"description": "__MSG_description__",
"icons": {
Expand Down

0 comments on commit 7e0dd53

Please sign in to comment.