# Releasing

Pushing a tag `vX.Y.Z` runs `.github/workflows/release.yml`, which does four
things in order:

1. Checks that the tag matches `@version` in `mix.exs`.
2. Builds the NIF for six targets, with `cross` for the Linux arm64 and musl
   targets.
3. Attaches the six archives to a GitHub release.
4. Writes `checksum-Elixir.ExOxvif.Native.exs`, runs the tests, and runs
   `mix hex.publish`.

## One-time setup

1. Generate a Hex API key with write access:

   ```sh
   mix hex.user auth
   mix hex.user key generate --key-name ex_oxvif-ci --permission api:write
   ```

2. Store it as the repository secret `HEX_API_KEY`:

   ```sh
   gh secret set HEX_API_KEY --repo cortfritz/ex_oxvif
   ```

## Cutting a release

```sh
mix git_ops.release          # bumps @version and updates CHANGELOG.md from commits
git push origin main
git push origin vX.Y.Z       # git_ops creates the tag
```

You can also do it by hand: edit `@version` and `CHANGELOG.md`, commit, then
run `git tag vX.Y.Z && git push origin main vX.Y.Z`.

## If the Hex step fails

If the NIFs built and the GitHub release exists, run the **Publish to Hex.pm
(manual)** workflow from the Actions tab. It downloads the released
archives, regenerates the checksums, and publishes.

## Upgrading oxvif

Bump `oxvif` in `native/ex_oxvif_nif/Cargo.toml` and run `cargo update -p
oxvif`. Then run `mix test`, which exercises the bindings against oxvif's
mock camera. oxvif is pre-1.0 and its minor versions can change the API.
