# Releasing Worker CLI

How to build and release the worker CLI binary.

## Prerequisites

- Nim 2.2+ (via `nix-shell -p nim`)
- Git with push access to this repo

## Build

```bash
# Enter nix shell with nim
nix-shell -p nim

# Build release binary
cd src
nim c -d:release --mm:orc worker.nim

# Output: src/worker.out (~1MB)
```

## Create Release Tarball

```bash
VERSION="0.1.0"  # Update version
mkdir -p releases
tar -czvf "releases/worker_${VERSION}_linux_amd64.tar.gz" \
    -C src worker.out \
    --transform "s/worker.out/worker/"
```

## Release to GitHub

1. Tag the release:
   ```bash
   git tag -a "worker-v${VERSION}" -m "Worker CLI v${VERSION}"
   git push origin "worker-v${VERSION}"
   ```

2. Create GitHub release:
   ```bash
   gh release create "worker-v${VERSION}" \
       --title "Worker CLI v${VERSION}" \
       --notes "Multi-agent worker coordination CLI" \
       "releases/worker_${VERSION}_linux_amd64.tar.gz"
   ```

3. Get the SHA256 for nix packaging:
   ```bash
   nix-prefetch-url --unpack \
       "https://github.com/USERNAME/skills/releases/download/worker-v${VERSION}/worker_${VERSION}_linux_amd64.tar.gz"
   ```

## Nix Package

After releasing, update the nix package in `dotfiles/pkgs/worker/default.nix`:

```nix
{ lib, stdenvNoCC, fetchzip, autoPatchelfHook, stdenv }:

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "worker";
  version = "0.1.0";  # Update version

  src = fetchzip {
    url = "https://github.com/USERNAME/skills/releases/download/worker-v${finalAttrs.version}/worker_${finalAttrs.version}_linux_amd64.tar.gz";
    sha256 = "sha256-XXXX";  # Update hash from nix-prefetch-url
    stripRoot = false;
  };

  nativeBuildInputs = [ autoPatchelfHook ];
  buildInputs = [ stdenv.cc.cc.lib ];

  dontConfigure = true;
  dontBuild = true;
  dontStrip = true;

  installPhase = ''
    runHook preInstall
    install -Dm755 worker $out/bin/worker
    runHook postInstall
  '';

  meta = with lib; {
    description = "Multi-agent worker coordination CLI";
    homepage = "https://github.com/USERNAME/skills";
    license = licenses.mit;
    platforms = [ "x86_64-linux" ];
    mainProgram = "worker";
  };
})
```

## Version Bumping

1. Update `src/worker.nimble`:
   ```nim
   version = "X.Y.Z"
   ```

2. Update `docs/releasing-worker.md` examples

3. Rebuild and release

## Testing the Release

```bash
# Extract and test
tar -xzf releases/worker_${VERSION}_linux_amd64.tar.gz
./worker --help
./worker status
```
