From df27a96f1f67b8f30b96bf8fd28e985793dfd45d Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sun, 6 Apr 2025 08:44:52 -0400 Subject: [PATCH] make a half-baked tarball (#221) * make a half-baked tarball Closes #217 Signed-off-by: Xe Iaso * make two tarballs: one with just the vendor, and one with vendor and npm Signed-off-by: Xe Iaso --------- Signed-off-by: Xe Iaso --- .github/workflows/package-builds-stable.yml | 2 +- .github/workflows/package-builds-unstable.yml | 2 +- Makefile | 6 ++- doc/VERSION | 1 + docs/docs/CHANGELOG.md | 1 + docs/docs/developer/building-anubis.md | 23 +++++++++- docs/docs/developer/local-dev.md | 2 +- yeetfile.js | 45 +++++++++++++++++++ 8 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 doc/VERSION diff --git a/.github/workflows/package-builds-stable.yml b/.github/workflows/package-builds-stable.yml index 2767583..651bbd5 100644 --- a/.github/workflows/package-builds-stable.yml +++ b/.github/workflows/package-builds-stable.yml @@ -64,7 +64,7 @@ jobs: - name: Build Packages run: | - wget https://github.com/Xe/x/releases/download/v1.13.3/yeet_1.13.3_amd64.deb -O var/yeet.deb + wget https://github.com/Xe/x/releases/download/v1.13.4/yeet_1.13.4_amd64.deb -O var/yeet.deb sudo apt -y install -f ./var/yeet.deb yeet diff --git a/.github/workflows/package-builds-unstable.yml b/.github/workflows/package-builds-unstable.yml index a14fd21..75449b3 100644 --- a/.github/workflows/package-builds-unstable.yml +++ b/.github/workflows/package-builds-unstable.yml @@ -66,7 +66,7 @@ jobs: - name: Build Packages run: | - wget https://github.com/Xe/x/releases/download/v1.13.3/yeet_1.13.3_amd64.deb -O var/yeet.deb + wget https://github.com/Xe/x/releases/download/v1.13.4/yeet_1.13.4_amd64.deb -O var/yeet.deb sudo apt -y install -f ./var/yeet.deb yeet diff --git a/Makefile b/Makefile index c16fa57..9b8b61c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ NODE_MODULES = node_modules +VERSION := $(shell cat ./VERSION) -.PHONY: build assets deps lint test +.PHONY: build assets deps lint prebaked-build test assets: npm run assets @@ -19,5 +20,8 @@ lint: go vet ./... go tool staticcheck ./... +prebaked-build: + go build -o ./var/anubis -ldflags "-X 'github.com/TecharoHQ/anubis.Version=$(VERSION)'" ./cmd/anubis + test: npm run test \ No newline at end of file diff --git a/doc/VERSION b/doc/VERSION new file mode 100644 index 0000000..ace4423 --- /dev/null +++ b/doc/VERSION @@ -0,0 +1 @@ +1.15.1 diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index d4aac89..0937cc3 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Added support for native Debian, Red Hat, and tarball packaging strategies including installation and use directions. +- A prebaked tarball has been added, allowing distros to build Anubis like they could in v1.15.x. - The placeholder Anubis mascot has been replaced with a design by [CELPHASE](https://bsky.app/profile/celphase.bsky.social). - Allow iMessage's link preview fetcher through Anubis by default. - Added a periodic cleanup routine for the decaymap that removes expired entries, ensuring stale data is properly pruned. diff --git a/docs/docs/developer/building-anubis.md b/docs/docs/developer/building-anubis.md index ebc8e21..c826cf6 100644 --- a/docs/docs/developer/building-anubis.md +++ b/docs/docs/developer/building-anubis.md @@ -8,7 +8,11 @@ These instructions may work, but for right now they are informative for downstre ::: -## Tools needed +## Entirely from source + +If you are doing a build entirely from source, here's what you need to do: + +### Tools needed In order to build a production-ready binary of Anubis, you need the following packages in your environment: @@ -50,6 +54,23 @@ make build From this point it is up to you to make sure that `./var/anubis` ends up in the right place. You may want to consult the `./run` folder for useful files such as a systemd unit and `anubis.env.default` file. +## "Pre-baked" tarball + +The `anubis-src-with-vendor` tarball has many pre-build steps already done, including: + +- Go module dependencies are present in `./vendor` +- Static assets (JS, CSS, etc.) are already built in CI + +This means you do not have to manage Go, NPM, or other ecosystem dependencies. + +When using this tarball, all you need to do is build `./cmd/anubis`: + +```text +make prebaked-build +``` + +Anubis will be built to `./var/anubis`. + ## Development dependencies Optionally, you can install the following dependencies for development: diff --git a/docs/docs/developer/local-dev.md b/docs/docs/developer/local-dev.md index 11a170b..0919d5f 100644 --- a/docs/docs/developer/local-dev.md +++ b/docs/docs/developer/local-dev.md @@ -69,7 +69,7 @@ Install `yeet`: ::: ```text -go install within.website/x/cmd/yeet@v1.13.3 +go install within.website/x/cmd/yeet@v1.13.4 ``` Install the dependencies for Anubis: diff --git a/yeetfile.js b/yeetfile.js index 94388be..871153d 100644 --- a/yeetfile.js +++ b/yeetfile.js @@ -24,4 +24,49 @@ $`npm run assets`; file.install("./run/default.env", `${etc}/default.env`); }, })); +}); + +// NOTE(Xe): Fixes #217. This is a "half baked" tarball that includes the harder +// parts for deterministic distros already done. Distributions like NixOS, Gentoo +// and *BSD ports have a difficult time fitting the square peg of their dependency +// model into the bazarr of round holes that various modern languages use. Needless +// to say, this makes adoption easier. +tarball.build({ + name: "anubis-src-vendor", + license: "MIT", + // XXX(Xe): This is needed otherwise go will be very sad. + platform: yeet.goos, + goarch: yeet.goarch, + + build: ({ out }) => { + // prepare clean checkout in $out + $`git archive --format=tar HEAD | tar xC ${out}`; + // vendor Go dependencies + $`cd ${out} && go mod vendor`; + // write VERSION file + $`echo ${git.tag()} > ${out}/VERSION`; + }, + + mkFilename: ({ name, version }) => `${name}-${version}`, +}); + +tarball.build({ + name: "anubis-src-vendor-npm", + license: "MIT", + // XXX(Xe): This is needed otherwise go will be very sad. + platform: yeet.goos, + goarch: yeet.goarch, + + build: ({ out }) => { + // prepare clean checkout in $out + $`git archive --format=tar HEAD | tar xC ${out}`; + // vendor Go dependencies + $`cd ${out} && go mod vendor`; + // build NPM-bound dependencies + $`cd ${out} && npm ci && npm run assets && rm -rf node_modules` + // write VERSION file + $`echo ${git.tag()} > ${out}/VERSION`; + }, + + mkFilename: ({ name, version }) => `${name}-${version}`, }); \ No newline at end of file