Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions .github/workflows/publish-crates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,23 @@ jobs:
fi
fi

# Returns 0 if $1@$2 is already on the crates.io sparse index. We query the
# index (what cargo itself resolves against) rather than the web API, which
# can rate-limit or reject on User-Agent policy and give a false "missing"
# that makes us try to re-publish an existing version.
is_published() {
local name="$1" ver="$2" prefix="${1:0:2}/${1:2:2}"
curl -sSf "https://index.crates.io/${prefix}/${name}" 2>/dev/null \
| grep -qF "\"vers\":\"${ver}\""
}

published=0
for crate in $publish_order; do
version=$(jq -r --arg n "$crate" '.packages[] | select(.name == $n) | .version' <<<"$metadata")
echo "::group::$crate v$version"

# Idempotent: skip versions already live on crates.io.
code=$(curl -sS -o /dev/null -w '%{http_code}' \
"https://crates.io/api/v1/crates/${crate}/${version}" || echo "000")
if [[ "$code" == "200" ]]; then
# Idempotent fast-path: skip versions already live on the index.
if is_published "$crate" "$version"; then
echo "$crate $version is already published, skipping."
echo "- \`$crate\` \`$version\` — already published (skipped)" >> "$GITHUB_STEP_SUMMARY"
echo "::endgroup::"
Expand All @@ -96,10 +104,23 @@ jobs:
[[ "$DRY_RUN" == "true" ]] && flags+=(--dry-run)

# cargo (>=1.66) blocks until the crate is queryable in the index, so the
# next dependent crate can resolve it. Retry to ride out transient hiccups.
# next dependent crate can resolve it. Retry to ride out transient hiccups,
# but treat "already published" as success: re-publishing a version is never
# retryable, and the pre-check can race a concurrent or just-finished publish.
attempt=1
max=5
until cargo publish "${flags[@]}"; do
skipped=""
while true; do
if out=$(cargo publish "${flags[@]}" 2>&1); then
printf '%s\n' "$out"
break
fi
printf '%s\n' "$out"
if grep -qiE "already (exists|uploaded)" <<<"$out"; then
echo "$crate $version is already published, skipping."
skipped=1
break
fi
if [[ $attempt -ge $max ]]; then
echo "::error::Failed to publish $crate after $max attempts."
exit 1
Expand All @@ -110,12 +131,15 @@ jobs:
attempt=$((attempt + 1))
done

if [[ "$DRY_RUN" == "true" ]]; then
if [[ -n "$skipped" ]]; then
echo "- \`$crate\` \`$version\` — already published (skipped)" >> "$GITHUB_STEP_SUMMARY"
elif [[ "$DRY_RUN" == "true" ]]; then
echo "- \`$crate\` \`$version\` — dry-run OK" >> "$GITHUB_STEP_SUMMARY"
published=$((published + 1))
else
echo "- \`$crate\` \`$version\` — published" >> "$GITHUB_STEP_SUMMARY"
published=$((published + 1))
fi
published=$((published + 1))
echo "::endgroup::"
done

Expand Down
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ members = [
]

# Crates published to crates.io under the meteroid-oss fork, in dependency order.
# Only these three carry the fork's custom features (e.g. `tagged_discriminator`);
# the remaining workspace members are kept building locally but are not published.
# The core three (`-config`, `-gen`, `meteroid-utoipa`) carry the fork's custom
# features (e.g. `tagged_discriminator`); `-axum` and `-scalar` are the framework
# bindings consumed downstream. The remaining workspace members are kept building
# locally but are not published.
[workspace.metadata.publish]
order = [
"meteroid-utoipa-config",
"meteroid-utoipa-gen",
"meteroid-utoipa",
"meteroid-utoipa-axum",
"meteroid-utoipa-scalar",
]
27 changes: 17 additions & 10 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Releasing (meteroid-oss fork)

This fork publishes three crates to crates.io, in dependency order:
This fork publishes five crates to crates.io, in dependency order:

| crates.io name | path | import as (unchanged) | version |
| ------------------------ | ---------------- | --------------------- | ------- |
| `meteroid-utoipa-config` | `utoipa-config/` | `utoipa_config` | 0.1.2 |
| `meteroid-utoipa-gen` | `utoipa-gen/` | `utoipa_gen` | 5.6.0 |
| `meteroid-utoipa` | `utoipa/` | `utoipa` | 5.6.0 |
| `meteroid-utoipa-axum` | `utoipa-axum/` | `utoipa_axum` | 0.2.0 |
| `meteroid-utoipa-scalar` | `utoipa-scalar/` | `utoipa_scalar` | 0.3.0 |

The crates.io **package** names are prefixed with `meteroid-`, but the **library**
names are kept (`utoipa`, `utoipa_gen`, `utoipa_config`). Downstream code therefore
stays a drop-in with upstream:
names are kept (`utoipa`, `utoipa_gen`, `utoipa_config`, `utoipa_axum`,
`utoipa_scalar`). Downstream code therefore stays a drop-in with upstream:

```toml
[dependencies]
Expand All @@ -21,14 +23,15 @@ meteroid-utoipa = "5"
use utoipa::ToSchema; // still `utoipa::...`
```

The other workspace crates (`utoipa-swagger-ui`, `utoipa-axum`, ...) are **not**
published from this fork; they only build locally against the renamed core.
The other workspace crates (`utoipa-swagger-ui`, `utoipa-redoc`, `utoipa-rapidoc`,
`utoipa-actix-web`, ...) are **not** published from this fork; they only build
locally against the renamed core.

## One-time setup

Add a repository secret `CARGO_REGISTRY_TOKEN` (Settings → Secrets and variables →
Actions) — a crates.io API token with publish scope from
crates.io → Account Settings → API Tokens. The three crate names must be owned by
crates.io → Account Settings → API Tokens. The five crate names must be owned by
the token's account (the first publish claims them).

## Cutting a release
Expand Down Expand Up @@ -62,16 +65,17 @@ you probably forgot to bump the `Cargo.toml` version(s).

## Which tag do I pick?

The three crates have different versions, but you only pick **one** tag, and it's
The crates have different versions, but you only pick **one** tag, and it's
just a trigger — it does not decide what gets published (that comes from each
crate's `Cargo.toml`). Use the **`meteroid-utoipa` version**, e.g. `v5.6.0`. That
is the crate you and downstream depend on, so the release *is* "meteroid-utoipa
5.6.0". The other two ride along automatically:
5.6.0". The others ride along automatically:

- `meteroid-utoipa-gen` moves **in lockstep** with `meteroid-utoipa` (same number —
the derive-macro crate and its runtime are a matched pair), so it is covered.
- `meteroid-utoipa-config` is independent and rarely changes; whenever you bump its
own `Cargo.toml`, it publishes on the next release regardless of the tag.
- `meteroid-utoipa-config`, `meteroid-utoipa-axum` and `meteroid-utoipa-scalar` are
independent and rarely change; whenever you bump one's own `Cargo.toml`, it
publishes on the next release regardless of the tag.

The workflow emits a warning if the release tag's version doesn't match the
`meteroid-utoipa` version, to catch a forgotten bump.
Expand All @@ -87,6 +91,9 @@ juhaku/utoipa):
by two opt-in, backward-compatible features (`tagged_discriminator` and flatten
support in `IntoParams`), hence the minor bump to **5.6.0**.
- `meteroid-utoipa-config` is unchanged from upstream, so it stays at **0.1.2**.
- `meteroid-utoipa-axum` (**0.2.0**) and `meteroid-utoipa-scalar` (**0.3.0**) are
the framework bindings, unchanged from upstream; they only depend on the renamed
core. Bump them when their own `Cargo.toml` changes.

Keep `meteroid-utoipa` and `meteroid-utoipa-gen` on the same version. When you
rebase onto a newer upstream release, jump to match it (e.g. upstream 5.7.0 →
Expand Down
12 changes: 9 additions & 3 deletions utoipa-axum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "utoipa-axum"
description = "Utoipa's axum bindings for seamless integration for the two"
name = "meteroid-utoipa-axum"
description = "Utoipa's axum bindings for seamless integration for the two (meteroid-oss fork of utoipa-axum)"
version = "0.2.0"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
keywords = ["utoipa", "axum", "bindings"]
repository = "https://github.com/juhaku/utoipa"
repository = "https://github.com/meteroid-oss/utoipa"
categories = ["web-programming"]
authors = ["Juha Kukkonen <juha7kukkonen@gmail.com>"]
rust-version.workspace = true
Expand All @@ -18,6 +18,12 @@ include = [
"CHANGELOG.md",
"Cargo.toml",
]

# Published as `meteroid-utoipa-axum` but keeps the `utoipa_axum` lib name so
# downstream code stays `use utoipa_axum::...` as a drop-in with upstream.
[lib]
name = "utoipa_axum"

[features]
debug = []

Expand Down
13 changes: 9 additions & 4 deletions utoipa-scalar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
[package]
name = "utoipa-scalar"
description = "Scalar for utoipa"
name = "meteroid-utoipa-scalar"
description = "Scalar for utoipa (meteroid-oss fork of utoipa-scalar)"
version = "0.3.0"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
keywords = ["scalar", "openapi", "documentation"]
repository = "https://github.com/juhaku/utoipa"
repository = "https://github.com/meteroid-oss/utoipa"
categories = ["web-programming"]
authors = ["Juha Kukkonen <juha7kukkonen@gmail.com>"]
rust-version.workspace = true

# Published as `meteroid-utoipa-scalar` but keeps the `utoipa_scalar` lib name so
# downstream code stays `use utoipa_scalar::...` as a drop-in with upstream.
[lib]
name = "utoipa_scalar"

[package.metadata.docs.rs]
features = ["actix-web", "axum", "rocket"]
rustdoc-args = ["--cfg", "doc_cfg"]
Expand All @@ -26,7 +31,7 @@ rocket = { version = "0.5", features = ["json"], optional = true }
axum = { version = "0.8.4", default-features = false, optional = true }

[dev-dependencies]
utoipa-scalar = { path = ".", features = ["actix-web", "axum", "rocket"] }
utoipa-scalar = { package = "meteroid-utoipa-scalar", path = ".", features = ["actix-web", "axum", "rocket"] }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] }
Loading