#!/usr/bin/env fish
# Orchestrator for the local tracing-subscriber-init release pipeline.
# Invoked via `cargo rake release` (see the [target.release] entry in
# Rakefile.toml).
#
# Usage: create and push a vX.Y.Z (or vX.Y.Z-rc.N) tag first, then run this
# from the repo root (or let Rakefile.toml run it for you):
#
# git tag v0.3.0 && git push origin v0.3.0
# cargo rake release
#
# -rc tags are a full dry run: dispatch-remote-builds.fish still runs in
# full (proving the repomon linux-rake/macos-rake/windows-rake/audit jobs
# actually succeed for this tag), but publish-crates.fish is skipped.
#
# There is no int-test stage here -- tracing-subscriber-init has no
# live-service dependency, so `cargo rake test` (run by both
# .repomon/test.toml and .repomon/release.toml's per-platform jobs) is
# already the full test suite; there's nothing extra to gate on locally.
#
# Unlike GitHub Actions, this pipeline needs no `gh release create` step,
# and no CI secret for crates.io: `cargo publish` runs locally, where
# `cargo login` is already configured.
source (path dirname (status --current-filename))/lib.fish
cd (rel_repo_root)
or rel_die "not inside the tracing-subscriber-init git repo"
rel_resolve_tag
# Export so dispatch-remote-builds.fish/publish-crates.fish (each a
# separate `fish` process) inherit the same tag rather than re-deriving it
# from HEAD.
set -gx RELEASE_TAG $RELEASE_TAG
rel_log "releasing $RELEASE_TAG"
set -l here (path dirname (status --current-filename))
fish $here/dispatch-remote-builds.fish
or rel_die "dispatch-remote-builds stage failed"
if rel_is_rc
rel_log "$RELEASE_TAG is a pre-release (-rc) tag -- all three platforms plus audit verified via repomon; skipping crates.io publish"
else
fish $here/publish-crates.fish
or rel_die "publish-crates stage failed"
rel_log "release $RELEASE_TAG complete."
end