ci: publish optimizer-derive before optimizer to fix crates.io dependency
This commit is contained in:
@@ -385,8 +385,10 @@ jobs:
|
|||||||
- name: Check if version already published
|
- name: Check if version already published
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
|
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "optimizer") | .version')
|
||||||
|
DERIVE_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "optimizer-derive") | .version')
|
||||||
echo "version=$CARGO_VERSION" >> "$GITHUB_OUTPUT"
|
echo "version=$CARGO_VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "derive_version=$DERIVE_VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://crates.io/api/v1/crates/optimizer/$CARGO_VERSION")
|
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://crates.io/api/v1/crates/optimizer/$CARGO_VERSION")
|
||||||
if [ "$HTTP_STATUS" = "200" ]; then
|
if [ "$HTTP_STATUS" = "200" ]; then
|
||||||
@@ -397,7 +399,33 @@ jobs:
|
|||||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Publish
|
DERIVE_HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://crates.io/api/v1/crates/optimizer-derive/$DERIVE_VERSION")
|
||||||
|
if [ "$DERIVE_HTTP_STATUS" = "200" ]; then
|
||||||
|
echo "optimizer-derive $DERIVE_VERSION already exists on crates.io"
|
||||||
|
echo "skip_derive=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "optimizer-derive $DERIVE_VERSION not found on crates.io, will publish"
|
||||||
|
echo "skip_derive=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Publish optimizer-derive
|
||||||
|
if: steps.check.outputs.skip == 'false' && steps.check.outputs.skip_derive == 'false'
|
||||||
|
run: |
|
||||||
|
cargo publish -p optimizer-derive --allow-dirty 2>&1 | tee publish_output.txt || {
|
||||||
|
if grep -q "already uploaded" publish_output.txt; then
|
||||||
|
echo "optimizer-derive already published, skipping"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
env:
|
||||||
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Wait for crates.io index update
|
||||||
|
if: steps.check.outputs.skip == 'false' && steps.check.outputs.skip_derive == 'false'
|
||||||
|
run: sleep 30
|
||||||
|
|
||||||
|
- name: Publish optimizer
|
||||||
if: steps.check.outputs.skip == 'false'
|
if: steps.check.outputs.skip == 'false'
|
||||||
run: |
|
run: |
|
||||||
cargo publish --allow-dirty 2>&1 | tee publish_output.txt || {
|
cargo publish --allow-dirty 2>&1 | tee publish_output.txt || {
|
||||||
|
|||||||
Reference in New Issue
Block a user