Skip to content

Commit 2106a73

Browse files
Merge pull request #5 from code0-tech/fix-publishing
feat: added version overwrite to publishing
2 parents bf37d96 + bc9b8f4 commit 2106a73

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,33 @@ jobs:
6161
- name: Install Rust
6262
uses: dtolnay/rust-toolchain@stable
6363

64-
- name: Verify tag matches crate version
64+
- name: Set crate version from tag
6565
shell: bash
6666
run: |
6767
set -euo pipefail
68+
tag_version="${GITHUB_REF_NAME#v}"
69+
70+
if [[ ! "$tag_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then
71+
echo "Tag $GITHUB_REF_NAME is not a valid crate version" >&2
72+
exit 1
73+
fi
74+
75+
sed -i \
76+
"s/^version = \".*\"$/version = \"$tag_version\"/" \
77+
Cargo.toml
78+
79+
# Refresh workspace package versions recorded in Cargo.lock without
80+
# changing locked dependency versions.
81+
cargo update -p lupus --precise "$tag_version"
82+
6883
crate_version="$(cargo metadata --no-deps --format-version 1 |
6984
jq -r '.packages[] | select(.name == "lupus") | .version')"
70-
tag_version="${GITHUB_REF_NAME#v}"
7185
if [[ "$tag_version" != "$crate_version" ]]; then
7286
echo "Tag $GITHUB_REF_NAME does not match lupus version $crate_version" >&2
7387
exit 1
7488
fi
7589
7690
- name: Publish to crates.io
77-
run: cargo publish -p lupus --locked
91+
run: cargo publish -p lupus --locked --allow-dirty
7892
env:
7993
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 commit comments

Comments
 (0)