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
20 changes: 17 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,33 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Verify tag matches crate version
- name: Set crate version from tag
shell: bash
run: |
set -euo pipefail
tag_version="${GITHUB_REF_NAME#v}"

if [[ ! "$tag_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then
echo "Tag $GITHUB_REF_NAME is not a valid crate version" >&2
exit 1
fi

sed -i \
"s/^version = \".*\"$/version = \"$tag_version\"/" \
Cargo.toml

# Refresh workspace package versions recorded in Cargo.lock without
# changing locked dependency versions.
cargo update -p lupus --precise "$tag_version"

crate_version="$(cargo metadata --no-deps --format-version 1 |
jq -r '.packages[] | select(.name == "lupus") | .version')"
tag_version="${GITHUB_REF_NAME#v}"
if [[ "$tag_version" != "$crate_version" ]]; then
echo "Tag $GITHUB_REF_NAME does not match lupus version $crate_version" >&2
exit 1
fi

- name: Publish to crates.io
run: cargo publish -p lupus --locked
run: cargo publish -p lupus --locked --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}