upload-release.js 938 B

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