mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
publishing: check if the current version is already there or not
This can happen when a publishing step failed
This commit is contained in:
parent
a3af2230a6
commit
6446ef294c
1 changed files with 30 additions and 2 deletions
|
@ -5,6 +5,22 @@ if test "$1" != "--do-it"; then
|
||||||
ARG="--dry-run --allow-dirty"
|
ARG="--dry-run --allow-dirty"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Function to check if the crate is already published
|
||||||
|
is_already_published() {
|
||||||
|
local crate_name=$1
|
||||||
|
local crate_version=$2
|
||||||
|
|
||||||
|
# Use the crates.io API to get the latest version of the crate
|
||||||
|
local latest_published_version
|
||||||
|
latest_published_version=$(curl -s https://crates.io/api/v1/crates/$crate_name | jq -r '.crate.max_version')
|
||||||
|
|
||||||
|
if [ "$latest_published_version" = "$crate_version" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Figure out any dependencies between the util via Cargo.toml
|
# Figure out any dependencies between the util via Cargo.toml
|
||||||
# We store this as edges in a graph with each line:
|
# We store this as edges in a graph with each line:
|
||||||
# [dependent] [dependency]
|
# [dependent] [dependency]
|
||||||
|
@ -35,12 +51,19 @@ TOTAL_ORDER=$(echo -e $PARTIAL_ORDER | tsort | tac)
|
||||||
# Remove the ROOT node from the start
|
# Remove the ROOT node from the start
|
||||||
TOTAL_ORDER=${TOTAL_ORDER#ROOT}
|
TOTAL_ORDER=${TOTAL_ORDER#ROOT}
|
||||||
|
|
||||||
|
CRATE_VERSION=$(grep '^version' Cargo.toml | head -n1 | cut -d '"' -f2)
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
for dir in src/uuhelp_parser/ src/uucore_procs/ src/uucore/ src/uu/stdbuf/src/libstdbuf/; do
|
for dir in src/uuhelp_parser/ src/uucore_procs/ src/uucore/ src/uu/stdbuf/src/libstdbuf/; do
|
||||||
(
|
(
|
||||||
cd "$dir"
|
cd "$dir"
|
||||||
|
CRATE_NAME=$(grep '^name =' "Cargo.toml" | head -n1 | cut -d '"' -f2)
|
||||||
#shellcheck disable=SC2086
|
#shellcheck disable=SC2086
|
||||||
|
if ! is_already_published "$CRATE_NAME" "$CRATE_VERSION"; then
|
||||||
cargo publish $ARG
|
cargo publish $ARG
|
||||||
|
else
|
||||||
|
echo "Skip: $CRATE_NAME $CRATE_VERSION already published"
|
||||||
|
fi
|
||||||
)
|
)
|
||||||
sleep 2s
|
sleep 2s
|
||||||
done
|
done
|
||||||
|
@ -48,8 +71,13 @@ done
|
||||||
for p in $TOTAL_ORDER; do
|
for p in $TOTAL_ORDER; do
|
||||||
(
|
(
|
||||||
cd "src/uu/$p"
|
cd "src/uu/$p"
|
||||||
|
CRATE_NAME=$(grep '^name =' "Cargo.toml" | head -n1 | cut -d '"' -f2)
|
||||||
#shellcheck disable=SC2086
|
#shellcheck disable=SC2086
|
||||||
|
if ! is_already_published "$CRATE_NAME" "$CRATE_VERSION"; then
|
||||||
cargo publish $ARG
|
cargo publish $ARG
|
||||||
|
else
|
||||||
|
echo "Skip: $CRATE_NAME $CRATE_VERSION already published"
|
||||||
|
fi
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue