Skip to content

Commit f3176bd

Browse files
committed
fix: strip prerelease suffix to base semver for Tauri v2 compatibility
Tauri v2 requires strict semver (X.Y.Z) — both prerelease suffixes (0.13.2-beta.1) and 4-segment versions (0.13.2.1) are rejected. - prepare-release.js: write base version into tauri.conf.json and Cargo.toml, keeping full prerelease in package.json files - release.yml: all 4 build jobs now strip to base version consistently; added missing patch step for both Linux builds
1 parent 6f49c4d commit f3176bd

2 files changed

Lines changed: 51 additions & 23 deletions

File tree

.github/workflows/release.yml

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,17 @@ jobs:
108108
echo "$NOTES" >> $GITHUB_OUTPUT
109109
echo "EOF" >> $GITHUB_OUTPUT
110110
111-
- name: Patch version for bundle compatibility
111+
- name: Patch version for Tauri semver compatibility
112112
run: |
113-
# Tauri/macOS/MSI require numeric-only version identifiers
114-
# Convert 0.13.2-beta.1 → 0.13.2.1 (extract numeric suffix as 4th segment)
113+
# Tauri v2 requires strict semver (X.Y.Z) — prerelease suffixes are rejected
114+
# Strip prerelease suffix: 0.13.2-beta.1 → 0.13.2
115115
# For stable versions (no hyphen), this is a no-op
116116
VERSION="${RELEASE_TAG#v}"
117117
if [[ "$VERSION" == *-* ]]; then
118118
BASE_VERSION="${VERSION%%-*}"
119-
PRERELEASE="${VERSION#*-}"
120-
NUMERIC_SUFFIX=$(echo "$PRERELEASE" | grep -oE '[0-9]+$')
121-
BUNDLE_VERSION="${BASE_VERSION}.${NUMERIC_SUFFIX:-0}"
122-
echo "Patching version for Tauri build: $VERSION → $BUNDLE_VERSION"
123-
sed -i '' "s/\"version\": \".*\"/\"version\": \"$BUNDLE_VERSION\"/" apps/fluux/src-tauri/tauri.conf.json
124-
sed -i '' "s/^version = \".*\"/version = \"$BUNDLE_VERSION\"/" apps/fluux/src-tauri/Cargo.toml
119+
echo "Patching version for Tauri build: $VERSION → $BASE_VERSION"
120+
sed -i '' "s|\"version\": \".*\"|\"version\": \"$BASE_VERSION\"|" apps/fluux/src-tauri/tauri.conf.json
121+
sed -i '' "s|^version = \".*\"|version = \"$BASE_VERSION\"|" apps/fluux/src-tauri/Cargo.toml
125122
else
126123
echo "Stable version $VERSION — no patching needed"
127124
fi
@@ -194,21 +191,18 @@ jobs:
194191
echo "$NOTES" >> $GITHUB_OUTPUT
195192
echo "EOF" >> $GITHUB_OUTPUT
196193
197-
- name: Patch version for MSI compatibility
194+
- name: Patch version for Tauri semver compatibility
198195
shell: bash
199196
run: |
200-
# Tauri/MSI require numeric-only version identifiers (no "beta", "rc", etc.)
201-
# Convert 0.13.2-beta.1 → 0.13.2.1 (extract numeric suffix as 4th segment)
197+
# Tauri v2 requires strict semver (X.Y.Z) — prerelease suffixes are rejected
198+
# Strip prerelease suffix: 0.13.2-beta.1 → 0.13.2
202199
# For stable versions (no hyphen), this is a no-op
203200
VERSION="${RELEASE_TAG#v}"
204201
if [[ "$VERSION" == *-* ]]; then
205202
BASE_VERSION="${VERSION%%-*}"
206-
PRERELEASE="${VERSION#*-}"
207-
NUMERIC_SUFFIX=$(echo "$PRERELEASE" | grep -oE '[0-9]+$')
208-
BUNDLE_VERSION="${BASE_VERSION}.${NUMERIC_SUFFIX:-0}"
209-
echo "Patching version for Tauri build: $VERSION → $BUNDLE_VERSION"
210-
sed -i "s/\"version\": \".*\"/\"version\": \"$BUNDLE_VERSION\"/" apps/fluux/src-tauri/tauri.conf.json
211-
sed -i "s/^version = \".*\"/version = \"$BUNDLE_VERSION\"/" apps/fluux/src-tauri/Cargo.toml
203+
echo "Patching version for Tauri build: $VERSION → $BASE_VERSION"
204+
sed -i "s|\"version\": \".*\"|\"version\": \"$BASE_VERSION\"|" apps/fluux/src-tauri/tauri.conf.json
205+
sed -i "s|^version = \".*\"|version = \"$BASE_VERSION\"|" apps/fluux/src-tauri/Cargo.toml
212206
else
213207
echo "Stable version $VERSION — no patching needed"
214208
fi
@@ -340,6 +334,21 @@ jobs:
340334
echo "$NOTES" >> $GITHUB_OUTPUT
341335
echo "EOF" >> $GITHUB_OUTPUT
342336
337+
- name: Patch version for Tauri semver compatibility
338+
run: |
339+
# Tauri v2 requires strict semver (X.Y.Z) — prerelease suffixes are rejected
340+
# Strip prerelease suffix: 0.13.2-beta.1 → 0.13.2
341+
# For stable versions (no hyphen), this is a no-op
342+
VERSION="${RELEASE_TAG#v}"
343+
if [[ "$VERSION" == *-* ]]; then
344+
BASE_VERSION="${VERSION%%-*}"
345+
echo "Patching version for Tauri build: $VERSION → $BASE_VERSION"
346+
sed -i "s|\"version\": \".*\"|\"version\": \"$BASE_VERSION\"|" apps/fluux/src-tauri/tauri.conf.json
347+
sed -i "s|^version = \".*\"|version = \"$BASE_VERSION\"|" apps/fluux/src-tauri/Cargo.toml
348+
else
349+
echo "Stable version $VERSION — no patching needed"
350+
fi
351+
343352
- name: Build Tauri binary
344353
run: |
345354
cd apps/fluux
@@ -504,6 +513,21 @@ jobs:
504513
- name: Build SDK
505514
run: npm run build:sdk
506515

516+
- name: Patch version for Tauri semver compatibility
517+
run: |
518+
# Tauri v2 requires strict semver (X.Y.Z) — prerelease suffixes are rejected
519+
# Strip prerelease suffix: 0.13.2-beta.1 → 0.13.2
520+
# For stable versions (no hyphen), this is a no-op
521+
VERSION="${RELEASE_TAG#v}"
522+
if [[ "$VERSION" == *-* ]]; then
523+
BASE_VERSION="${VERSION%%-*}"
524+
echo "Patching version for Tauri build: $VERSION → $BASE_VERSION"
525+
sed -i "s|\"version\": \".*\"|\"version\": \"$BASE_VERSION\"|" apps/fluux/src-tauri/tauri.conf.json
526+
sed -i "s|^version = \".*\"|version = \"$BASE_VERSION\"|" apps/fluux/src-tauri/Cargo.toml
527+
else
528+
echo "Stable version $VERSION — no patching needed"
529+
fi
530+
507531
- name: Build Tauri binary
508532
run: |
509533
cd apps/fluux

scripts/prepare-release.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,25 @@ for (const file of VERSION_FILES) {
6767
console.log(` ${file}: ${oldVersion} -> ${version}`)
6868
}
6969

70+
// Tauri v2 requires strict semver (X.Y.Z) — prerelease suffixes are rejected.
71+
// Strip the prerelease suffix for tauri.conf.json and Cargo.toml.
72+
const tauriVersion = version.replace(/-.*$/, '')
73+
7074
// 2. Update tauri.conf.json
7175
console.log('\nUpdating tauri.conf.json...')
7276
const tauriPath = path.join(ROOT, TAURI_CONF)
7377
const tauriConf = JSON.parse(fs.readFileSync(tauriPath, 'utf-8'))
7478
const oldTauriVersion = tauriConf.version
75-
tauriConf.version = version
79+
tauriConf.version = tauriVersion
7680

7781
// Update bundleVersion with short git hash
7882
try {
7983
const gitHash = execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim()
8084
tauriConf.bundle.macOS.bundleVersion = gitHash
81-
console.log(` version: ${oldTauriVersion} -> ${version}`)
85+
console.log(` version: ${oldTauriVersion} -> ${tauriVersion}${tauriVersion !== version ? ` (stripped from ${version})` : ''}`)
8286
console.log(` bundleVersion: ${gitHash}`)
8387
} catch (e) {
84-
console.log(` version: ${oldTauriVersion} -> ${version}`)
88+
console.log(` version: ${oldTauriVersion} -> ${tauriVersion}${tauriVersion !== version ? ` (stripped from ${version})` : ''}`)
8589
console.log(` bundleVersion: (unchanged, git not available)`)
8690
}
8791
fs.writeFileSync(tauriPath, JSON.stringify(tauriConf, null, 2) + '\n')
@@ -92,9 +96,9 @@ const cargoPath = path.join(ROOT, TAURI_CARGO)
9296
let cargoContent = fs.readFileSync(cargoPath, 'utf-8')
9397
const cargoVersionMatch = cargoContent.match(/^version\s*=\s*"([^"]+)"/m)
9498
const oldCargoVersion = cargoVersionMatch ? cargoVersionMatch[1] : 'unknown'
95-
cargoContent = cargoContent.replace(/^version\s*=\s*"[^"]+"/m, `version = "${version}"`)
99+
cargoContent = cargoContent.replace(/^version\s*=\s*"[^"]+"/m, `version = "${tauriVersion}"`)
96100
fs.writeFileSync(cargoPath, cargoContent)
97-
console.log(` version: ${oldCargoVersion} -> ${version}`)
101+
console.log(` version: ${oldCargoVersion} -> ${tauriVersion}${tauriVersion !== version ? ` (stripped from ${version})` : ''}`)
98102

99103
// 4. Generate CHANGELOG.md from changelog.ts
100104
console.log('\nGenerating CHANGELOG.md from changelog.ts...')

0 commit comments

Comments
 (0)