-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake-release.sh
More file actions
executable file
·34 lines (27 loc) · 1.09 KB
/
Copy pathmake-release.sh
File metadata and controls
executable file
·34 lines (27 loc) · 1.09 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
#!/usr/bin/env bash
# make-release.sh
# Prepares a release by updating the version number and sha1 in the PCB file.
# Usage: ./make-release.sh major|minor|patch
anchor="cjshearer/cweep\\\n"
current_version=$(grep -oP "$anchor\K[0-9]+\.[0-9]+\.[0-9]+" cweep.kicad_pcb | head -1)
current_hash=$(grep -oP "$anchor$current_version - \K[0-9a-f]+" cweep.kicad_pcb | head -1)
echo "Current version: $current_version ($current_hash)"
if ! [[ "$1" =~ ^(major|minor|patch)$ ]]; then
echo "Invalid argument: $1. Use major, minor, or patch."
exit 1
fi
new_version=$(
IFS='.' read -r major minor patch <<< "$current_version"
case $1 in
major) ((major++)); minor=0; patch=0 ;;
minor) ((minor++)); patch=0 ;;
patch) ((patch++)) ;;
*) echo "Invalid argument: $1. Use major, minor, or patch." ; exit 1 ;;
esac
echo "$major.$minor.$patch"
)
new_hash=$(git rev-parse --short HEAD)
echo "Updating to $new_version ($new_hash)"
sed -i "s#$anchor$current_version - $current_hash#$anchor$new_version - $new_hash#" cweep.kicad_pcb
git add cweep.kicad_pcb
git commit -m "build: $current_version -> $new_version"