-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·39 lines (29 loc) · 1.01 KB
/
Copy pathpublish.sh
File metadata and controls
executable file
·39 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
set -euo pipefail
VERSION="$(grep '^version' Cargo.toml | head -1 | sed -E 's/.*"([^"]+)".*/\1/')"
TAG="v${VERSION}"
if ! git diff --exit-code --quiet || [[ -n "$(git status --porcelain)" ]]; then
echo "error: working tree is dirty; commit or stash changes before packaging" >&2
exit 1
fi
echo "Preparing to publish fp_rust ${VERSION} (tag: ${TAG})"
echo "==> cargo package --list"
cargo package --list
echo "==> cargo package (dry-run)"
cargo package --no-verify
if ! git rev-parse "${TAG}" >/dev/null 2>&1; then
echo "error: git tag ${TAG} does not exist; create it before publishing" >&2
echo " git tag -a ${TAG} -m \"Release ${VERSION}\"" >&2
exit 1
fi
echo "==> cargo publish --dry-run"
cargo publish --dry-run
read -r -p "Publish ${VERSION} to crates.io? [y/N] " confirm
if [[ ! "${confirm}" =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 1
fi
cargo publish
echo "Published ${VERSION}."
echo "Push commits and the release tag manually when ready:"
echo " git push && git push origin ${TAG}"