Skip to content

Commit 37ba7e7

Browse files
committed
chore: reorganize release gh actions
1 parent 579a296 commit 37ba7e7

7 files changed

Lines changed: 1932 additions & 458 deletions

File tree

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Create Version Tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Specific version (e.g., 1.2.3) - leave empty to auto-detect from commits'
8+
required: false
9+
type: string
10+
version_type:
11+
description: 'If auto-detecting: type of version bump'
12+
required: false
13+
type: choice
14+
default: 'auto'
15+
options:
16+
- auto
17+
- patch
18+
- minor
19+
- major
20+
21+
jobs:
22+
create_tag:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Configure Git
33+
run: |
34+
git config --local user.email "action@github.com"
35+
git config --local user.name "GitHub Action"
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 'lts/*'
41+
42+
- name: Get current version
43+
id: current_version
44+
run: |
45+
CURRENT_VERSION=$(node -p "require('./package.json').version")
46+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
47+
echo "📦 Current version: $CURRENT_VERSION"
48+
49+
- name: Determine new version
50+
id: new_version
51+
run: |
52+
if [ -n "${{ inputs.version }}" ]; then
53+
# User specified exact version
54+
NEW_VERSION="${{ inputs.version }}"
55+
echo "✨ Using specified version: $NEW_VERSION"
56+
else
57+
# Auto-detect from commits
58+
CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}"
59+
60+
# Get commits since last tag
61+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
62+
if [ -z "$LAST_TAG" ]; then
63+
COMMITS=$(git log --pretty=format:"%s" --reverse)
64+
else
65+
COMMITS=$(git log $LAST_TAG..HEAD --pretty=format:"%s" --reverse)
66+
fi
67+
68+
# Auto-detect version type if needed
69+
if [ "${{ inputs.version_type }}" == "auto" ]; then
70+
if echo "$COMMITS" | grep -qiE "(breaking|!|BREAKING)"; then
71+
VERSION_TYPE="major"
72+
echo "🔴 Breaking changes detected - major version bump"
73+
elif echo "$COMMITS" | grep -qiE "^(feat|feature)"; then
74+
VERSION_TYPE="minor"
75+
echo "🟡 New features detected - minor version bump"
76+
else
77+
VERSION_TYPE="patch"
78+
echo "🟢 Bug fixes and maintenance - patch version bump"
79+
fi
80+
else
81+
VERSION_TYPE="${{ inputs.version_type }}"
82+
fi
83+
84+
# Calculate new version
85+
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"
86+
87+
case "$VERSION_TYPE" in
88+
"major")
89+
NEW_VERSION="$((major + 1)).0.0"
90+
;;
91+
"minor")
92+
NEW_VERSION="$major.$((minor + 1)).0"
93+
;;
94+
"patch")
95+
NEW_VERSION="$major.$minor.$((patch + 1))"
96+
;;
97+
esac
98+
99+
echo "📈 Auto-detected version: $NEW_VERSION (type: $VERSION_TYPE)"
100+
fi
101+
102+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
103+
104+
- name: Update version files
105+
run: |
106+
NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
107+
108+
echo "📝 Updating version files to $NEW_VERSION"
109+
110+
# Update package.json
111+
node -e "
112+
const fs = require('fs');
113+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
114+
pkg.version = '$NEW_VERSION';
115+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
116+
"
117+
118+
# Update Cargo.toml
119+
sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" src-tauri/Cargo.toml
120+
121+
# Update tauri.conf.json
122+
node -e "
123+
const fs = require('fs');
124+
const config = JSON.parse(fs.readFileSync('src-tauri/tauri.conf.json', 'utf8'));
125+
config.version = '$NEW_VERSION';
126+
fs.writeFileSync('src-tauri/tauri.conf.json', JSON.stringify(config, null, 2) + '\n');
127+
"
128+
129+
# Update iOS project.yml (if it exists)
130+
# Note: This file is in gen/ folder which may be regenerated by Tauri CLI.
131+
# We update it here for consistency, but it might be overwritten by tauri ios build.
132+
# The tauri.conf.json version is the source of truth for mobile builds.
133+
if [ -f "src-tauri/gen/apple/project.yml" ]; then
134+
sed -i "s/CFBundleShortVersionString: .*/CFBundleShortVersionString: $NEW_VERSION/" src-tauri/gen/apple/project.yml
135+
sed -i "s/CFBundleVersion: .*/CFBundleVersion: \"$NEW_VERSION\"/" src-tauri/gen/apple/project.yml
136+
fi
137+
138+
# Note: Android versions (gen/android/app/tauri.properties) are auto-generated
139+
# from tauri.conf.json by Tauri CLI, so we don't update them manually.
140+
141+
# Commit changes
142+
git add package.json src-tauri/Cargo.toml src-tauri/tauri.conf.json
143+
git add src-tauri/gen/apple/project.yml 2>/dev/null || true
144+
git commit -m "chore: bump version to $NEW_VERSION"
145+
146+
# Push to the current branch, not hardcoded 'main'
147+
CURRENT_BRANCH=${GITHUB_REF#refs/heads/}
148+
git push origin "$CURRENT_BRANCH"
149+
150+
- name: Create and push tag
151+
run: |
152+
NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
153+
TAG_NAME="v$NEW_VERSION"
154+
155+
# Check if tag already exists
156+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
157+
echo "❌ Tag $TAG_NAME already exists!"
158+
exit 1
159+
fi
160+
161+
echo "🏷️ Creating tag: $TAG_NAME"
162+
git tag "$TAG_NAME"
163+
git push origin "$TAG_NAME"
164+
165+
echo "✅ Tag $TAG_NAME created and pushed"
166+
echo "🚀 This will trigger the release workflow to build all platforms"

0 commit comments

Comments
 (0)