Skip to content

Commit 0893e2f

Browse files
authored
feat(release): add release script and update GitHub Actions workflow for versioning (#68)
1 parent fdbcd92 commit 0893e2f

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Create Release Page
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v6
14+
- name: Create Release
15+
uses: softprops/action-gh-release@v2
16+
with:
17+
generate_release_notes: true # Generate the changelog

release.sh

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

Comments
 (0)