Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
wip: exit successfully when submitting a listed add-on (#90)
Browse files Browse the repository at this point in the history
Save an unsigned file as targetXpi.
  • Loading branch information
iorate authored Mar 16, 2020
1 parent 236eecf commit 16fe6ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ This plugin requires some parameters to be set, so be sure to check below and fi

### `publish`

Creates an unsigned XPI file out of the source directory and uploads it to the Mozilla Add On, using the web-ext sign command. The output from the sign command will be passed through to the console. If the package is validated and signed, it will downloaded the signed XPI file and store it in the artifacts directory under the specified file name.
Creates an unsigned XPI file out of the source directory and uploads it to the Mozilla Add On, using the web-ext sign command. The output from the sign command will be passed through to the console. If the package is validated and signed, it will download the signed XPI file and store it in the artifacts directory under the specified file name. If the package is validated but not signed (including the case where manual review is required), it will store the unsigned XPI file in the artifacts directory.

#### `publish` parameters

Expand Down
34 changes: 25 additions & 9 deletions src/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs')
const path = require('path')

const webExt = require('web-ext').default
const defaultAddonSigner = require('sign-addon')

const { verifyOptions } = require('./utils')

Expand All @@ -22,22 +23,37 @@ const publish = async options => {
} = verifyOptions(options, ['extensionId', 'targetXpi'])

const { FIREFOX_API_KEY, FIREFOX_SECRET_KEY } = process.env
const { success, downloadedFiles } = await webExt.cmd.sign({
apiKey: FIREFOX_API_KEY,
apiSecret: FIREFOX_SECRET_KEY,
artifactsDir,
channel,
id: extensionId,
sourceDir,
})

let unsignedXpiPath
const signAddon = async params => {
unsignedXpiPath = params.xpiPath
const result = await defaultAddonSigner(params)
if (!result.success && result.errorCode === 'ADDON_NOT_AUTO_SIGNED') {
result.success = true
result.downloadedFiles = result.downloadedFiles || []
}
return result
}

const { success, downloadedFiles } = await webExt.cmd.sign(
{
apiKey: FIREFOX_API_KEY,
apiSecret: FIREFOX_SECRET_KEY,
artifactsDir,
channel,
id: extensionId,
sourceDir,
},
{ signAddon },
)
if (!success) {
throw new Error(
'Signing the extension failed. See the console output from web-ext sign for the validation link',
)
}
const [xpiFile] = downloadedFiles
fs.renameSync(
path.join(artifactsDir, xpiFile),
xpiFile ? path.join(artifactsDir, xpiFile) : unsignedXpiPath,
path.join(artifactsDir, targetXpi),
)
}
Expand Down

0 comments on commit 16fe6ab

Please sign in to comment.