1+ #! /bin/bash
2+
3+ if [ -z " $1 " ]; then
4+ echo " ❌ Error: you need to provide a version."
5+ echo " Usage: ./release.sh v1.0.0"
6+ exit 1
7+ fi
8+
9+ VERSION=$1
10+ JSON_FILE=" custom_components/edilkamin/manifest.json"
11+ BRANCH=" main"
12+
13+ CURRENT_BRANCH=$( git rev-parse --abbrev-ref HEAD)
14+ if [ " $CURRENT_BRANCH " != " $BRANCH " ]; then
15+ echo " ❌ Error: You must be on the main branch ($BRANCH ) to create a release."
16+ exit 1
17+ fi
18+
19+ # Check that git status is clean
20+ if [[ $( git status --porcelain) ]]; then
21+ echo " ❌ Error: You have uncommitted changes."
22+ echo " Please commit or stash your changes before starting a release."
23+ exit 1
24+ fi
25+
26+ echo " 🚀 Starting release: $VERSION "
27+
28+ # Check if jq is installed
29+ if ! command -v jq > /dev/null 2>&1 ; then
30+ echo " ❌ Error: jq is not installed. Please install jq to continue."
31+ exit 1
32+ fi
33+
34+ # Check if JSON file exists
35+ if [ ! -f " $JSON_FILE " ]; then
36+ echo " ❌ Error: JSON file '$JSON_FILE ' does not exist."
37+ exit 1
38+ fi
39+
40+ tmp=$( mktemp)
41+ jq --arg v " $VERSION " ' .version = $v' " $JSON_FILE " > " $tmp " && mv " $tmp " " $JSON_FILE "
42+ echo " ✅ File $JSON_FILE updated."
43+
44+ # 3. Commit changes
45+ git add " $JSON_FILE "
46+ git commit -m " chore(release): bump version to $VERSION "
47+ echo " ✅ Commit created."
48+
49+ # 4. Create Tag
50+ git tag " $VERSION "
51+ echo " ✅ Tag $VERSION created."
52+
53+ # 5. Push to GitHub (Commits + Tags)
54+ echo " ✅ Pushing changes to GitHub..."
55+ git push origin " $BRANCH "
56+ git push origin " $VERSION "
57+
58+ echo " 🎉 Release finished! GitHub will now see the new tag and trigger your actions (if you have any)."
0 commit comments