-
Notifications
You must be signed in to change notification settings - Fork 32
83 lines (71 loc) · 2.81 KB
/
Copy pathversion-sync.yml
File metadata and controls
83 lines (71 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Version Sync
on:
push:
branches:
- '**'
paths:
- 'package.json'
- 'src-tauri/tauri.conf.json'
pull_request:
branches:
- '**'
paths:
- 'package.json'
- 'src-tauri/tauri.conf.json'
jobs:
sync-versions:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
- name: Check and sync versions
id: sync
run: |
# Extract versions
PKG_VERSION=$(node -p "require('./package.json').version")
TAURI_VERSION=$(node -p "require('./src-tauri/tauri.conf.json').version")
echo "package.json version: $PKG_VERSION"
echo "tauri.conf.json version: $TAURI_VERSION"
if [ "$PKG_VERSION" != "$TAURI_VERSION" ]; then
echo "❌ Version mismatch detected!"
echo "mismatch=true" >> $GITHUB_OUTPUT
echo "pkg_version=$PKG_VERSION" >> $GITHUB_OUTPUT
echo "tauri_version=$TAURI_VERSION" >> $GITHUB_OUTPUT
# Update tauri.conf.json with package.json version
node -e "
const fs = require('fs');
const tauriConfig = JSON.parse(fs.readFileSync('./src-tauri/tauri.conf.json', 'utf8'));
tauriConfig.version = '$PKG_VERSION';
fs.writeFileSync('./src-tauri/tauri.conf.json', JSON.stringify(tauriConfig, null, 2) + '\n');
"
echo "✅ Updated tauri.conf.json to version $PKG_VERSION"
else
echo "✅ Versions are in sync"
echo "mismatch=false" >> $GITHUB_OUTPUT
fi
- name: Commit version sync
if: steps.sync.outputs.mismatch == 'true' && github.event_name == 'push'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src-tauri/tauri.conf.json
git commit -m "chore: Sync tauri.conf.json version to ${{ steps.sync.outputs.pkg_version }}
Auto-synced from package.json version
Previous version: ${{ steps.sync.outputs.tauri_version }}
New version: ${{ steps.sync.outputs.pkg_version }}"
git push
- name: Fail on version mismatch (PR only)
if: steps.sync.outputs.mismatch == 'true' && github.event_name == 'pull_request'
run: |
echo "::error::Version mismatch detected! package.json (${{ steps.sync.outputs.pkg_version }}) != tauri.conf.json (${{ steps.sync.outputs.tauri_version }})"
echo "Please run 'npm run sync-version' or manually update tauri.conf.json"
exit 1