diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b0f97b..3d004a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -92,11 +92,26 @@ jobs: - name: Determine publish requirement id: publish_check + env: + CRATE_NAME: ipc_ring run: | set -euo pipefail - CRATE_NAME="ipc_ring" CRATE_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r ".packages[] | select(.name==\"${CRATE_NAME}\") | .version") - PUBLISHED_VERSION=$(curl -sSf "https://crates.io/api/v1/crates/${CRATE_NAME}" | jq -r '.crate.max_version') + SEARCH_OUTPUT=$(mktemp) + PUBLISHED_VERSION="not-found" + if cargo search "${CRATE_NAME}" --limit 1 > "${SEARCH_OUTPUT}"; then + FIRST_LINE=$(head -n 1 "${SEARCH_OUTPUT}") + if printf '%s\n' "${FIRST_LINE}" | grep -q "^${CRATE_NAME} "; then + PARSED=$(printf '%s\n' "${FIRST_LINE}" | awk -F'"' '{print $2}') + if [ -n "${PARSED}" ]; then + PUBLISHED_VERSION="${PARSED}" + fi + fi + fi + if [ "${PUBLISHED_VERSION}" = "not-found" ]; then + PUBLISHED_VERSION=$(curl -sSf -H "User-Agent: ipc-ring-release-workflow (+https://github.com/${{ github.repository }})" \ + "https://crates.io/api/v1/crates/${CRATE_NAME}" | jq -r '.crate.max_version' || echo "not-found") + fi SHOULD_PUBLISH="true" if [ -z "${PUBLISHED_VERSION}" ] || [ "${PUBLISHED_VERSION}" = "null" ]; then PUBLISHED_VERSION="not-found" diff --git a/Cargo.lock b/Cargo.lock index cf18fbf..9eb1585 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -140,7 +140,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "ipc_ring" -version = "0.1.0" +version = "0.2.0" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 21ce71c..f37027b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ipc_ring" -version = "0.1.0" +version = "0.2.0" edition = "2021" authors = ["Leander Kohler"] description = "High-performance memory-mapped SPSC ring buffer for Unix IPC"