Skip to content

Commit ad36b5f

Browse files
authored
add make release bash script (#1475)
* add make release bash script * read me details * uncomment git uncommited changes * typo * tweaks * use package.json as source of truth, not git tags
1 parent b798cf1 commit ad36b5f

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ Before you submit a contribution PR to this repo, please ensure that:
136136
VERSION=x.y.z yarn run bump-jsons
137137
```
138138

139+
Alternatively you can try the experimental `make-release.sh` bash script that will create the branch with the updated json files for you.
140+
run `./make-release.sh` for a patch update
141+
run `./make-release.sh "minor"` for minor
142+
run `./make-release.sh "major"` for major
143+
139144
The PR may serve as a place to discuss the human-readable changelog and extra QA. A quick way of getting PR's merged since the last bump is to [use this PR filter](https://github.com/KittyCAD/modeling-app/pulls?q=is%3Apr+sort%3Aupdated-desc+is%3Amerged+), open up the browser console and past in the following
140145

141146
```typescript

make-release.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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

Comments
 (0)