You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

7 months ago
  1. "use strict"
  2. let version = process.argv[2]
  3. let auth = process.argv[3]
  4. let url = require("url")
  5. if (!auth) {
  6. console.log("Usage: upload-release.js [TAG] [github-user:password]")
  7. process.exit(1)
  8. }
  9. function post(host, path, body) {
  10. let req = require("https").request({
  11. host,
  12. auth: auth,
  13. headers: {"user-agent": "Release uploader"},
  14. path,
  15. method: "POST"
  16. }, res => {
  17. if (res.statusCode >= 300 && res.statusCode < 400) {
  18. console.log(res.headers.location)
  19. let parsed = url.parse(res.headers.location)
  20. post(parsed.host, parsed.path, body)
  21. } else if (res.statusCode >= 400) {
  22. console.error(res.statusCode, res.statusMessage)
  23. res.on("data", d => console.log(d.toString()))
  24. res.on("end", () => process.exit(1))
  25. }
  26. })
  27. req.write(body)
  28. req.end()
  29. }
  30. require('child_process').exec("git --no-pager show -s --format='%s' " + version, (error, stdout) => {
  31. if (error) throw error
  32. let message = stdout.split("\n").slice(2)
  33. message = message.slice(0, message.indexOf("-----BEGIN PGP SIGNATURE-----")).join("\n")
  34. post("api.github.com", "/repos/codemirror/codemirror5/releases", JSON.stringify({
  35. tag_name: version,
  36. name: version,
  37. body: message
  38. }))
  39. })