Skip to content
Merged
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
56 changes: 35 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading