irongit
jv/scripts/release.sh
35 lines1.3 KBBourne Again Shell (bash)
1#!/bin/bash
2# Author: Lane Henslee (huncho@hygo.ai)
3# Bumps the version for relevant version files, auto commits them, and prompts a tag with editor.
4
5current_version="$(git tag -l | head -n 1 | sed 's/^v//')"
6[[ -z "$current_version" ]] && current_version=0.0.0
7echo -e "\033[35mCurrently on version $current_version\033[0m"
8
9IFS='.' read -r major minor patch <<<"$current_version"
10
11case "$1" in
12same) echo -e "\033[34mKeeping the same version\033[0m" ;;
13major) major=$((major + 1)) && minor=0 && patch=0 ;;
14minor) minor=$((minor + 1)) && patch=$((patch + 1)) ;;
15*) patch=$((patch + 1)) ;;
16esac
17
18new_version="$major.$minor.$patch"
19
20echo -e "\033[32mUpdating version $new_version\033[0m"
21
22printf "\033[37m(y/n) Would you like to continue? Defaults to y: \033[0m"
23read -rp "" yn
24{ [[ "$yn" == "y" ]] || [[ -z "$yn" ]]; } || { echo -e "\033[31mAborting...\033[0m" && exit 0; }
25
26find . -name Cargo.toml -exec sed -i "s/^version.*/version = \"$new_version\"/" {} \;
27find . -name Cargo.toml -exec git add {} \;
28find . -name package.json -exec sed -i "s/\"version\".*/\"version\": \"$new_version\"/" {} \;
29find . -name package.json -exec git add {} \;
30
31echo -e "\033[37mUpdated relevant files. Create new commit\033[0m"
32git commit -m "version tag"
33
34echo -e "\033[37mCompleted commit. Create new tag\033[0m"
35git tag -f -a "v$new_version"