amo-sign.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. const fs = require('fs').promises;
  2. const path = require('path');
  3. const { signAddon } = require('sign-addon');
  4. const { readManifest, buildUpdatesList } = require('./manifest-helper');
  5. const { getVersion } = require('./version-helper');
  6. async function main() {
  7. const manifest = await readManifest();
  8. const rawVersion = process.env.VERSION;
  9. // version may be suffixed for unlisted version
  10. const version = getVersion();
  11. const result = await signAddon({
  12. xpiPath: path.join(process.env.TEMP_DIR, process.env.ASSET_SELF_HOSTED_ZIP),
  13. version,
  14. apiKey: process.env.AMO_KEY,
  15. apiSecret: process.env.AMO_SECRET,
  16. channel: 'unlisted',
  17. downloadDir: process.env.ASSETS_DIR,
  18. id: manifest.browser_specific_settings.gecko.id,
  19. });
  20. if (!result.success) {
  21. console.error(result);
  22. if (!result.errorDetails?.startsWith('Version already exists.')) {
  23. process.exitCode = 1;
  24. return;
  25. }
  26. }
  27. // const fileName = path.basename(result.downloadedFiles[0]);
  28. const fileName = `violentmonkey-${version}-an+fx.xpi`;
  29. const url = `https://github.com/violentmonkey/violentmonkey/releases/download/v${rawVersion}/${fileName}`;
  30. const updates = await buildUpdatesList(version, url);
  31. await fs.writeFile(path.join(process.env.TEMP_DIR, 'updates/updates.json'), JSON.stringify(updates, null, 2), 'utf8');
  32. }
  33. main();