diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cb87f05..6f72fe9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,40 +77,54 @@ jobs: set -euo pipefail version="${RELEASE_TAG#v}" - if cargo search office2pdf --limit 1 | grep -F "office2pdf = \"${version}\"" > /dev/null; then + set +e + output="$(cargo publish -p office2pdf 2>&1)" + status=$? + set -e + printf '%s\n' "${output}" + + if [[ "${status}" -eq 0 ]]; then + exit 0 + fi + + if grep -F "already exists on crates.io index" <<<"${output}" > /dev/null; then echo "office2pdf ${version} is already published" exit 0 fi - cargo publish -p office2pdf --token "${CARGO_REGISTRY_TOKEN}" + exit "${status}" - - name: Wait for office2pdf index update + - name: Publish office2pdf-cli + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} run: | set -euo pipefail version="${RELEASE_TAG#v}" for attempt in {1..30}; do - if cargo search office2pdf --limit 1 | grep -F "office2pdf = \"${version}\"" > /dev/null; then + set +e + output="$(cargo publish -p office2pdf-cli 2>&1)" + status=$? + set -e + printf '%s\n' "${output}" + + if [[ "${status}" -eq 0 ]]; then exit 0 fi - echo "office2pdf ${version} is not visible in the crates.io index yet; retry ${attempt}/30" - sleep 10 - done - - echo "::error::office2pdf ${version} did not appear in the crates.io index" - exit 1 + if grep -F "already exists on crates.io index" <<<"${output}" > /dev/null; then + echo "office2pdf-cli ${version} is already published" + exit 0 + fi - - name: Publish office2pdf-cli - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - run: | - set -euo pipefail + if grep -E "failed to select a version for the requirement .office2pdf|no matching package named .office2pdf" <<<"${output}" > /dev/null; then + echo "office2pdf ${version} is not visible to cargo publish yet; retry ${attempt}/30" + sleep 20 + continue + fi - version="${RELEASE_TAG#v}" - if cargo search office2pdf-cli --limit 1 | grep -F "office2pdf-cli = \"${version}\"" > /dev/null; then - echo "office2pdf-cli ${version} is already published" - exit 0 - fi + exit "${status}" + done - cargo publish -p office2pdf-cli --token "${CARGO_REGISTRY_TOKEN}" + echo "::error::office2pdf-cli ${version} could not be published after waiting for office2pdf ${version}" + exit 1