yeetfile.js 2.9 KB

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