about summary refs log tree commit diff stats
path: root/justfile
diff options
context:
space:
mode:
Diffstat (limited to 'justfile')
-rwxr-xr-xjustfile83
1 files changed, 83 insertions, 0 deletions
diff --git a/justfile b/justfile
new file mode 100755
index 0000000..9dc57b8
--- /dev/null
+++ b/justfile
@@ -0,0 +1,83 @@
+#! /usr/bin/env -S nix develop . --command just --justfile
+
+fly-system := "x86_64-linux"
+fly-registry := "registry.fly.io/alanpearce-eu"
+docker-tag := env_var_or_default("DOCKER_TAG", `git rev-parse HEAD`)
+version := `sentry-cli releases propose-version`
+environment := "production"
+started-at := `date +%s`
+
+default:
+    @just --list --justfile {{ justfile() }} --unsorted
+
+check:
+    nix flake check . --print-build-logs
+
+check-licenses:
+    nix run nixpkgs#go-licenses check ./...
+
+update-all:
+    go get -u all
+    gomod2nix --outdir nix
+    nix flake update
+
+watch-flake command:
+    watchexec --restart -w flake.nix -w flake.lock direnv exec . {{ command }}
+
+watch-builder: (watch-flake "watchexec -w cmd/build -w content -w templates -r go run ./cmd/build --base-url http://localhost:3000")
+
+generate:
+    go run ./cmd/build --base-url http://localhost:3000
+
+nix-build what:
+    nix build .#{{ what }}
+
+watch-server: (watch-flake "watchexec -r -i content -i templates go run ./cmd/server")
+
+dev:
+    #!/usr/bin/env bash
+    set -euxo pipefail
+    tmp="$(mktemp -d -t website-XXXXXX)" || exit 1
+    echo using temp directory $tmp
+    trap "{ echo cleaning up $tmp; rm -rf \"$tmp\"; }" EXIT
+    go build -o $tmp ./cmd/dev ./cmd/build ./cmd/server
+    "${tmp}/dev" --temp-dir "${tmp}"
+
+watch-dev: (watch-flake "watchexec -r -e go just dev")
+
+docker-stream system=(arch() + "-linux"):
+    @nix build --print-out-paths .#docker-stream-{{ system }} | sh
+
+docker-image system=(arch() + "-linux"):
+    nix build .#docker-image-{{ system }}
+
+docker-stream-fly:
+    just docker-stream {{ fly-system }}
+
+docker-image-fly: (docker-image fly-system)
+
+docker-inspect image-path="result" *skopeo-flags="":
+    skopeo {{ skopeo-flags }} inspect docker-archive:{{ image-path }}
+
+print-docker-tag:
+    @echo {{ fly-registry }}:{{ docker-tag }}
+
+stream-to-registry *skopeo-flags="": sentry-create-release && sentry-finalise-release
+    just docker-stream-fly | gzip --fast | skopeo {{ skopeo-flags }} copy --dest-precompute-digests docker-archive:/dev/stdin docker://{{ fly-registry }}:{{ docker-tag }}
+
+result := `readlink -f result`
+push-to-registry *skopeo-flags="":
+    skopeo {{ skopeo-flags }} copy --dest-precompute-digests docker-archive://{{ result }}  docker://{{ fly-registry }}:{{ docker-tag }}
+
+sentry-create-release:
+    sentry-cli releases new {{ version }}
+
+sentry-finalise-release:
+    sentry-cli releases set-commits {{ version }} --ignore-missing --auto # will not work in CI
+    sentry-cli releases finalize {{ version }}
+
+sentry-create-deploy:
+    sentry-cli releases deploys {{ version }} new --started {{ started-at }} --finished `date +%s` --env {{ environment }}
+
+deploy registry-and-tag=(fly-registry + ":" + docker-tag): && sentry-create-deploy
+    fly deploy --image {{ registry-and-tag }}