Skip to content

Commit 60c58e9

Browse files
committed
Add scripts and bump version
1 parent 008e95f commit 60c58e9

File tree

4 files changed

+75
-22
lines changed

4 files changed

+75
-22
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stitch-sync"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
edition = "2021"
55
authors = ["Oliver Steele <steele@osteele.com>"]
66
description = "Automatically convert embroidery files and optionally copy them to a USB drive"

scripts/bump-version

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# Strict error handling
4+
set -euo pipefail
5+
IFS=$'\n\t'
6+
7+
# Parse command line arguments
8+
BUMP_TYPE="patch"
9+
10+
while [[ $# -gt 0 ]]; do
11+
case $1 in
12+
--major)
13+
BUMP_TYPE="major"
14+
shift
15+
;;
16+
--minor)
17+
BUMP_TYPE="minor"
18+
shift
19+
;;
20+
--patch)
21+
BUMP_TYPE="patch"
22+
shift
23+
;;
24+
*)
25+
echo "Unknown option: $1"
26+
echo "Usage: $0 [--major|--minor|--patch]"
27+
exit 1
28+
;;
29+
esac
30+
done
31+
32+
# Read current version from Cargo.toml
33+
CURRENT_VERSION=$(grep '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
34+
if [ -z "$CURRENT_VERSION" ]; then
35+
echo "Failed to determine current version from Cargo.toml"
36+
exit 1
37+
fi
38+
39+
# Split version into components
40+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
41+
42+
# Bump version according to type
43+
case $BUMP_TYPE in
44+
major)
45+
NEW_VERSION="$((MAJOR + 1)).0.0"
46+
;;
47+
minor)
48+
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
49+
;;
50+
patch)
51+
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
52+
;;
53+
esac
54+
55+
# Update version in Cargo.toml using perl
56+
perl -i -pe "s/^version = \".*\"/version = \"$NEW_VERSION\"/" Cargo.toml
57+
58+
# Verify the update was successful
59+
NEW_VERSION_CHECK=$(grep '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
60+
if [ "$NEW_VERSION_CHECK" != "$NEW_VERSION" ]; then
61+
echo "Failed to update version in Cargo.toml"
62+
exit 1
63+
fi
64+
65+
echo "Version bumped from $CURRENT_VERSION to $NEW_VERSION"

scripts/release.sh

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
# Strict error handling
4+
set -euo pipefail
5+
IFS=$'\n\t'
6+
37
# Parse command line arguments
48
ALLOW_DIRTY=false
59
FORCE=false
@@ -39,30 +43,14 @@ if ! cargo test; then
3943
exit 1
4044
fi
4145

42-
# Get latest release info from GitHub API
43-
echo "Fetching latest release information..."
44-
RELEASE_INFO=$(curl -s "https://api.github.com/repos/${REPO_WITH_OWNER}/releases/latest")
45-
if [ $? -ne 0 ]; then
46-
echo "Failed to fetch release information"
47-
exit 1
48-
fi
49-
50-
# Extract current version tag
51-
CURRENT_VERSION=$(echo "$RELEASE_INFO" | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)
46+
# Read version from Cargo.toml
47+
CURRENT_VERSION=$(grep '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
5248
if [ -z "$CURRENT_VERSION" ]; then
53-
echo "Failed to determine latest version"
49+
echo "Failed to determine current version from Cargo.toml"
5450
exit 1
5551
fi
5652

57-
# Remove 'v' prefix if present
58-
CURRENT_VERSION=${CURRENT_VERSION#v}
59-
60-
# Split version into components
61-
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
62-
63-
# Increment patch version
64-
NEW_PATCH=$((PATCH + 1))
65-
NEW_VERSION="v${MAJOR}.${MINOR}.${NEW_PATCH}"
53+
NEW_VERSION="v${CURRENT_VERSION}"
6654

6755
# Prepare tag command
6856
TAG_CMD="git tag"

0 commit comments

Comments
 (0)