amo-sign.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  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. timeout: 30 * 60e3, // 30 minutes
  20. });
  21. if (!result.success) {
  22. console.error(result);
  23. if (!result.errorDetails?.startsWith('Version already exists.')) {
  24. process.exitCode = 1;
  25. return;
  26. }
  27. }
  28. // const fileName = path.basename(result.downloadedFiles[0]);
  29. const fileName = `violentmonkey-${version}-an+fx.xpi`;
  30. const url = `https://github.com/violentmonkey/violentmonkey/releases/download/v${rawVersion}/${fileName}`;
  31. const updates = await buildUpdatesList(version, url);
  32. await fs.writeFile(path.join(process.env.TEMP_DIR, 'updates/updates.json'), JSON.stringify(updates, null, 2), 'utf8');
  33. }
  34. main();