yeetfile.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. $`npm run assets`;
  2. [
  3. "amd64",
  4. "arm64",
  5. "ppc64le",
  6. "riscv64",
  7. ].forEach(goarch => {
  8. [deb, rpm, tarball].forEach(method => method.build({
  9. name: "anubis",
  10. description: "Anubis weighs the souls of incoming HTTP requests and uses a sha256 proof-of-work challenge in order to protect upstream resources from scraper bots.",
  11. homepage: "https://anubis.techaro.lol",
  12. license: "MIT",
  13. goarch,
  14. documentation: {
  15. "./README.md": "README.md",
  16. "./LICENSE": "LICENSE",
  17. "./data/botPolicies.json": "botPolicies.json",
  18. "./data/botPolicies.yaml": "botPolicies.yaml",
  19. },
  20. build: ({ bin, etc, systemd, doc }) => {
  21. $`go build -o ${bin}/anubis -ldflags '-s -w -extldflags "-static" -X "github.com/TecharoHQ/anubis.Version=${git.tag()}"' ./cmd/anubis`;
  22. $`go build -o ${bin}/anubis-robots2policy -ldflags '-s -w -extldflags "-static" -X "github.com/TecharoHQ/anubis.Version=${git.tag()}"' ./cmd/robots2policy`;
  23. file.install("./run/anubis@.service", `${systemd}/anubis@.service`);
  24. file.install("./run/default.env", `${etc}/default.env`);
  25. $`mkdir -p ${doc}/docs`
  26. $`cp -a docs/docs ${doc}`;
  27. $`find ${doc} -name _category_.json -delete`;
  28. $`mkdir -p ${doc}/data`;
  29. $`cp -a data/apps ${doc}/data/apps`;
  30. $`cp -a data/bots ${doc}/data/bots`;
  31. $`cp -a data/clients ${doc}/data/clients`;
  32. $`cp -a data/common ${doc}/data/common`;
  33. $`cp -a data/crawlers ${doc}/data/crawlers`;
  34. $`cp -a data/meta ${doc}/data/meta`;
  35. },
  36. }));
  37. });
  38. // NOTE(Xe): Fixes #217. This is a "half baked" tarball that includes the harder
  39. // parts for deterministic distros already done. Distributions like NixOS, Gentoo
  40. // and *BSD ports have a difficult time fitting the square peg of their dependency
  41. // model into the bazaar of round holes that various modern languages use. Needless
  42. // to say, this makes adoption easier.
  43. tarball.build({
  44. name: "anubis-src-vendor",
  45. license: "MIT",
  46. // XXX(Xe): This is needed otherwise go will be very sad.
  47. platform: yeet.goos,
  48. goarch: yeet.goarch,
  49. build: ({ out }) => {
  50. // prepare clean checkout in $out
  51. $`git archive --format=tar HEAD | tar xC ${out}`;
  52. // vendor Go dependencies
  53. $`cd ${out} && go mod vendor`;
  54. // write VERSION file
  55. $`echo ${git.tag()} > ${out}/VERSION`;
  56. },
  57. mkFilename: ({ name, version }) => `${name}-${version}`,
  58. });
  59. tarball.build({
  60. name: "anubis-src-vendor-npm",
  61. license: "MIT",
  62. // XXX(Xe): This is needed otherwise go will be very sad.
  63. platform: yeet.goos,
  64. goarch: yeet.goarch,
  65. build: ({ out }) => {
  66. // prepare clean checkout in $out
  67. $`git archive --format=tar HEAD | tar xC ${out}`;
  68. // vendor Go dependencies
  69. $`cd ${out} && go mod vendor`;
  70. // build NPM-bound dependencies
  71. $`cd ${out} && npm ci && npm run assets && rm -rf node_modules`
  72. // write VERSION file
  73. $`echo ${git.tag()} > ${out}/VERSION`;
  74. },
  75. mkFilename: ({ name, version }) => `${name}-${version}`,
  76. });