mirror of
https://codeberg.org/JasterV/docker.git
synced 2026-04-26 18:10:02 +00:00
[rust-magic-release] fix: publish crates in topological order
This commit is contained in:
parent
b437c5c87e
commit
1b54f8fa48
1 changed files with 16 additions and 4 deletions
|
|
@ -7,17 +7,29 @@ CRATES_TOKEN="${PLUGIN_CRATES_IO_TOKEN}"
|
||||||
REPO_FULL_NAME="${CI_REPO}"
|
REPO_FULL_NAME="${CI_REPO}"
|
||||||
API_URL="https://codeberg.org/api/v1/repos/${REPO_FULL_NAME}"
|
API_URL="https://codeberg.org/api/v1/repos/${REPO_FULL_NAME}"
|
||||||
|
|
||||||
# --- Get Workspace Packages in Topological Order ---
|
# Get workspace members in topological order (dependencies first)
|
||||||
PACKAGES=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | .[] | select(.publish != []) | "\(.name) \(.version) \(.manifest_path)"')
|
# We use 'tac' because 'cargo tree' puts the "roots" at the top.
|
||||||
|
# Reversing it ensures "leaves" (dependencies) are published first.
|
||||||
|
ORDERED_CRATES=$(cargo tree --workspace --depth 0 --prefix none --format "{p}" | awk '{print $1}' | tac)
|
||||||
|
|
||||||
|
# Get all package metadata in one go
|
||||||
|
# Use jq to re-sort the metadata to match the ORDERED_NAMES
|
||||||
|
PACKAGES=$(cargo metadata --format-version 1 --no-deps | jq -r --arg names "$ORDERED_CRATES" '
|
||||||
|
($names | split("\n")) as $order
|
||||||
|
| [.packages[] | select(.publish != [])] as $pkgs
|
||||||
|
| $order[] as $name
|
||||||
|
| $pkgs[] | select(.name == $name)
|
||||||
|
| "\(.name) \(.version) \(.manifest_path)"
|
||||||
|
')
|
||||||
|
|
||||||
if [ -z "$PACKAGES" ]; then
|
if [ -z "$PACKAGES" ]; then
|
||||||
echo "No publishable packages found in workspace."
|
echo "No publishable packages found."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting release process..."
|
echo "Starting release process..."
|
||||||
|
|
||||||
# --- 3. Process each package ---
|
# --- Process each package ---
|
||||||
echo "$PACKAGES" | while read -r PKG_NAME PKG_VERSION MANIFEST_PATH; do
|
echo "$PACKAGES" | while read -r PKG_NAME PKG_VERSION MANIFEST_PATH; do
|
||||||
|
|
||||||
TAG_NAME="${PKG_NAME}-v${PKG_VERSION}"
|
TAG_NAME="${PKG_NAME}-v${PKG_VERSION}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue