Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extension: Sign the Firefox add-on #4021

Merged
merged 6 commits into from
Apr 16, 2021

Conversation

Herschel
Copy link
Member

@Herschel Herschel commented Apr 16, 2021

Sign the Firefox add-on so that it can be more easily installed.

  • Fix the 128x128 icon (caught by the Mozilla add-on linter)
  • After downloading the signed add-on xpi, copy it instead of moving (in case destination is on another drive).
  • Append build date to the version number, because Firefox/Chrome marketplaces require each upload to have a unique and monotonically increasing version number. (0.1.0.20120415)
  • Add version_name to the manifest for a more readable version (0.1 nightly 2012-04-15 for nightly builds)

After signing, the add-on will still remain unlisted on the MAO site, but we download the signed package and upload that to GitHub releases. The Mozilla API keys will be added to the Ruffle GitHub org.

@Herschel Herschel marked this pull request as draft April 16, 2021 03:45
@Herschel Herschel force-pushed the ff-extension-sign branch from ea2d137 to cf988a7 Compare April 16, 2021 03:49
@Herschel Herschel requested a review from relrelb April 16, 2021 04:07
.substr(0, 10);
// The extension marketplaces require the version to monotonically increase,
// so append the build date onto the end of the manifest version.
const version = `${packageVersion}.${buildDate.replace(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildDate.replaceAll("-", "") can be used, though replaceAll is available only since Node.js 15.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is running node 14 currently, so let's keep this for now.

@@ -220,7 +220,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
asset_path: ./web/packages/extension/dist/firefox_unsigned.xpi
asset_path: ./web/packages/extension/dist/firefox.xpi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see mentions to firefox_unsigned.xpi in package.json. Should they be changed to firefox.xpi?

Copy link
Member Author

@Herschel Herschel Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first steps still create firefox_unsigned.xpi:
node tools/zip.js dist/firefox_unsigned.xpi

firefox_unsigned.xpi is uploaded to the Mozilla server where it is signed, and then the signed copy is downloaded into firefox.xpi:
node tools/sign_xpi.js dist/firefox_unsigned.xpi dist/firefox.xpi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So don't you need to provide the MOZILLA_API_KEY, MOZILLA_API_SECRET and FIREFOX_EXTENSION_ID environment variables, so that sign_xpi.js actually signs the extension?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I'll set those as secrets in the GitHub settings for the Ruffle org. They'll be passed along to the CI environment.

@relrelb
Copy link
Contributor

relrelb commented Apr 16, 2021

It's really cool that Mozilla's add-on linter caught something. Maybe we should add it as part of the CI (not necessarily in this PR).

@Herschel Herschel force-pushed the ff-extension-sign branch from cf988a7 to fefe5b0 Compare April 16, 2021 06:39
Copy link
Contributor

@relrelb relrelb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

A rename will fail if the destination is on a different mount
(happened to me!). Instead, copy the file to the destination, then
delete the old file.
@Herschel Herschel force-pushed the ff-extension-sign branch from fefe5b0 to 15c78e0 Compare April 16, 2021 06:46
@relrelb relrelb added the extension Related to the Ruffle WebExtension label Apr 16, 2021
@Herschel Herschel marked this pull request as ready for review April 16, 2021 06:48
@relrelb
Copy link
Contributor

relrelb commented Apr 16, 2021

I believe this fixes #1274, #1876, #3493.

@@ -54,4 +57,8 @@ async function sign(
"Skipping signing of Firefox extension. To enable this, please provide MOZILLA_API_KEY, MOZILLA_API_SECRET and FIREFOX_EXTENSION_ID environment variables"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to comment few lines above but GitHub doesn't allow.

const { version } = require("../assets/manifest.json");

Can be rewritten to:

const version = process.env.npm_package_version;

Copy link
Member Author

@Herschel Herschel Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we need the version from the manifest, because it has the build date appended (0.1.0.20120415), and this is necessary for the Mozilla add-on service to accept it (version # must be unique). There may be a better way to pass this into the signing code, though.

@Herschel Herschel force-pushed the ff-extension-sign branch from 15c78e0 to 3349f63 Compare April 16, 2021 17:54
Properly catch errors from the `sign-addon` package and bail out
immediately. This will display better output from the Mozilla
validation service.
The Chrome/Firefox marketplaces require the version number of an
extension to increase with each upload, so append the build date
to the version in `manifest.json`. Add `versionName` with the more
readable version (`0.1 nightly 2010-15-04` for nightly builds).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension Related to the Ruffle WebExtension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants