Skip to content

Commit

Permalink
build: Sync quil-rs version with quil-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Apr 15, 2024
1 parent 3085b0a commit c172d88
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scripts/sync_versions.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
#! /bin/bash
# This script gets the current version of quil-rs from its manifest, and uses it to update the dependency specification
# of quil-rs in quil-py's manifset.

#
# Get current version of quil-rs
PACKAGE_VERSION=$(cargo metadata --format-version 1 --no-deps | grep -o '"name":"quil-rs","version":"[^"]*' | cut -d '"' -f 8)

patch_cargo_toml() {
# `awk -i inplace` would work on linux, but not on macos. This command is compatible with both.
awk -v ver="$PACKAGE_VERSION" '/^quil-rs = /{$0="quil-rs = { path = \"../quil-rs\", version = \"" ver "\" }"}1' "$1"
}

# Write it to `quil-py`s Cargo.toml
# `awk -i inplace` would work on linux, but not on macos. This command is compatible with both.
awk -v ver="$PACKAGE_VERSION" '/^quil-rs = /{$0="quil-rs = { path = \"../quil-rs\", version = \"" ver "\" }"}1' quil-py/Cargo.toml > quil-py/Cargo.toml.tmp
patch_cargo_toml quil-py/Cargo.toml > quil-py/Cargo.toml.tmp
mv quil-py/Cargo.toml.tmp quil-py/Cargo.toml

# Validate that the new version of Cargo.toml is valid
cargo check --manifest-path=quil-py/Cargo.toml

# Write it to `quil-cli`s Cargo.toml
patch_cargo_toml quil-cli/Cargo.toml > quil-cli/Cargo.toml.tmp
mv quil-cli/Cargo.toml.tmp quil-cli/Cargo.toml

# Validate that the new version of Cargo.toml is valid
cargo check --manifest-path=quil-py/Cargo.toml

0 comments on commit c172d88

Please sign in to comment.