|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +if ! git diff-index --quiet HEAD --; then |
| 4 | + echo "Please stash uncommitted changes before running release script" |
| 5 | + exit 1 |
| 6 | +fi |
| 7 | + |
| 8 | +git checkout main |
| 9 | +git pull |
| 10 | +git fetch --all |
| 11 | + |
| 12 | +# Get the latest semver tag from git |
| 13 | +latest_tag=$(jq -r '.version' package.json) |
| 14 | +latest_tag="v$latest_tag" |
| 15 | + |
| 16 | +# Print the latest semver tag |
| 17 | +echo "Latest semver tag: $latest_tag" |
| 18 | + |
| 19 | +# Function to bump version numbers |
| 20 | +bump_version() { |
| 21 | + local version=$1 |
| 22 | + local bump_type=$2 |
| 23 | + local major=$(echo $version | cut -d '.' -f 1 | sed 's/v//') |
| 24 | + local minor=$(echo $version | cut -d '.' -f 2) |
| 25 | + local patch=$(echo $version | cut -d '.' -f 3) |
| 26 | + |
| 27 | + case "$bump_type" in |
| 28 | + major) |
| 29 | + major=$((major + 1)) |
| 30 | + minor=0 |
| 31 | + patch=0 |
| 32 | + ;; |
| 33 | + minor) |
| 34 | + minor=$((minor + 1)) |
| 35 | + patch=0 |
| 36 | + ;; |
| 37 | + *) |
| 38 | + patch=$((patch + 1)) |
| 39 | + ;; |
| 40 | + esac |
| 41 | + |
| 42 | + echo "v${major}.${minor}.${patch}" |
| 43 | +} |
| 44 | + |
| 45 | +# Determine the type of bump based on the argument |
| 46 | +bump_type=${1:-patch} |
| 47 | + |
| 48 | +# Bump the version |
| 49 | +new_version=$(bump_version $latest_tag $bump_type) |
| 50 | + |
| 51 | +# Print the new semver tag |
| 52 | +echo "New semver tag: $new_version" |
| 53 | +new_version_number=${new_version:1} |
| 54 | +echo "New version number without 'v': $new_version_number" |
| 55 | + |
| 56 | + |
| 57 | +git checkout -b "cut-release-$new_version" |
| 58 | + |
| 59 | +echo "$(jq --arg v "$new_version_number" '.version=$v' package.json --indent 2)" > package.json |
| 60 | +echo "$(jq --arg v "$new_version_number" '.package.version=$v' src-tauri/tauri.conf.json --indent 2)" > src-tauri/tauri.conf.json |
| 61 | + |
| 62 | +git add package.json src-tauri/tauri.conf.json |
| 63 | +git commit -m "Cut release $new_version" |
| 64 | + |
| 65 | +echo "" |
| 66 | +echo "Versions has been bumped in relevant json files, a branch has been created and committed to." |
| 67 | +echo "" |
| 68 | +echo "What's left for you to do is, push the branch and make the release PR." |
| 69 | +echo "" |
0 commit comments