From cce0dffccda1dba10279ed2e814129661d3c49d0 Mon Sep 17 00:00:00 2001 From: Winter Date: Fri, 19 Jun 2026 02:04:43 -0500 Subject: [PATCH] release v1.0.0: README, --help formatting, flake version bump --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++ flake.nix | 23 ++++++++++---- internal/wisp/deploy.go | 30 +++++++++++++++++++ 3 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e7dc502 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# wisp-deploy + +minimal go version of [wispcli](https://tangled.org/did:plc:f5yyql4gsffx7jjplezhttle/tree/main/cli) for CI. + +for interactive usage, i recommend using wispcli as it provides a nicer visual experience and importantly, oauth login. + +```bash +Usage: wisp-deploy [options] + +Deploy a static site to wisp.place + +Options: + -p, --path Directory to deploy + -s, --site Site name (defaults to directory name) + --directory Enable directory listing + --spa Enable SPA mode (serve index.html for all routes) + -c, --concurrency Number of concurrent uploads (backs off to 2 on rate limit) (default: 3) + --force-gzip Force gzip compression for all files regardless of type + --password App password for headless authentication + -h, --help display help for command +``` + +## use in tangled ci + +remember to set `WISP_APP_PASSWORD` in your spindle secrets + +```yaml +when: + - event: ["push"] + branch: ["main"] + +engine: "nixery" + +environment: + SITE_PATH: "." + SITE_NAME: "madoka" + WISP_HANDLE: "madoka.systems" + +steps: + - name: deploy to wisp + command: | + nix \ + --extra-experimental-features nix-command \ + --extra-experimental-features flakes \ + --accept-flake-config \ + profile add 'git+https://tangled.org/madoka.systems/wisp-deploy' + + wisp-deploy \ + "$WISP_HANDLE" \ + --path "$SITE_PATH" \ + --site "$SITE_NAME" \ + --password "$WISP_APP_PASSWORD" +``` + +tags are also provided, you can use them by changing the url to `git+https://tangled.org/madoka.systems/wisp-deploy?ref=refs/tags/v1.0.0` for example. +for the sake of reproducibility, you can also use the url `git+https://tangled.org/did:plc:ne3mufdifemv72zui4bqlp32` instead if you desire. + +note: you can use this as a dependency in the normal way like below, but this won't cache (at least in my testing). the method above uses [cachix](https://www.cachix.org/) to keep downloads small. + +```yaml +# ... +dependencies: + git+https://tangled.org/madoka.systems/wisp-deploy: + - wisp-deploy +# ... +``` diff --git a/flake.nix b/flake.nix index 85a224b..be8ebd6 100644 --- a/flake.nix +++ b/flake.nix @@ -12,23 +12,32 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - outputs = { self, nixpkgs }: + outputs = + { self, nixpkgs }: let - systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); in { packages = forAllSystems (pkgs: rec { wisp-deploy = pkgs.buildGoModule { pname = "wisp-deploy"; - version = "0.1.0"; + version = "1.0.0"; src = self; vendorHash = "sha256-WT7V95m8YjB2GdDoH11WIzBeh4YMUzIBLHaKbvXuxDg="; subPackages = [ "cmd/wisp-deploy" ]; # Static, pure-Go build: no cgo, smaller binary, friendlier in containers. env.CGO_ENABLED = 0; - ldflags = [ "-s" "-w" ]; + ldflags = [ + "-s" + "-w" + ]; # Non-sandboxed nix builds (e.g. tangled spindles) use /homeless-shelter # as $HOME and abort a derivation if a previous one left it behind. The @@ -49,7 +58,11 @@ devShells = forAllSystems (pkgs: { default = pkgs.mkShell { - packages = [ pkgs.go pkgs.gopls pkgs.gotools ]; + packages = [ + pkgs.go + pkgs.gopls + pkgs.gotools + ]; }; }); diff --git a/internal/wisp/deploy.go b/internal/wisp/deploy.go index a17adf4..9cd5f99 100644 --- a/internal/wisp/deploy.go +++ b/internal/wisp/deploy.go @@ -3,6 +3,7 @@ package wisp import ( "flag" "fmt" + "io" "path/filepath" "regexp" "strings" @@ -17,6 +18,27 @@ const ( var siteNameRe = regexp.MustCompile(`^[a-zA-Z0-9._~:-]{1,512}$`) +func printHelp() { + fmt.Println("Usage: wisp-deploy [options] ") + fmt.Println() + fmt.Println("Deploy a static site to wisp.place") + fmt.Println() + fmt.Println("Options:") + rows := [][2]string{ + {"-p, --path ", "Directory to deploy"}, + {"-s, --site ", "Site name (defaults to directory name)"}, + {"--directory", "Enable directory listing"}, + {"--spa", "Enable SPA mode (serve index.html for all routes)"}, + {"-c, --concurrency ", "Number of concurrent uploads (backs off to 2 on rate limit) (default: 3)"}, + {"--force-gzip", "Force gzip compression for all files regardless of type"}, + {"--password ", "App password for headless authentication"}, + {"-h, --help", "display help for command"}, + } + for _, r := range rows { + fmt.Printf(" %-21s %s\n", r[0], r[1]) + } +} + // Run executes the deploy CLI for the given args (excluding argv[0]). func Run(argv []string) error { // The CI syntax puts the handle first (`wisp-deploy --path ...`), @@ -30,6 +52,10 @@ func Run(argv []string) error { } fs := flag.NewFlagSet("wisp-deploy", flag.ContinueOnError) + // Render our own help (stdlib usage shows single-dash flags and splits long/ + // short into separate entries); suppress flag's built-in output. + fs.SetOutput(io.Discard) + fs.Usage = func() {} path := fs.String("path", "", "directory to deploy") fs.StringVar(path, "p", "", "directory to deploy (shorthand)") site := fs.String("site", "", "site name (defaults to directory name)") @@ -41,6 +67,10 @@ func Run(argv []string) error { spa := fs.Bool("spa", false, "enable SPA mode") forceGzip := fs.Bool("force-gzip", false, "force gzip for all files") if err := fs.Parse(argv); err != nil { + if err == flag.ErrHelp { + printHelp() + return nil + } return err } if handle == "" && fs.NArg() > 0 { -- 2.51.2