Skip to content

Commit

Permalink
updating version made easy
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiyandhakal committed Jul 17, 2023
1 parent c3efec2 commit 6d9a3c0
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions update-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
import os
import sys
import json
import re

# check if version is provided
if len(sys.argv) < 2:
print('Version is required')
sys.exit(1)

# check if version is valid
version = sys.argv[1]

version_pattern = r'^\d+\.\d+\.\d+$'

if not re.match(version_pattern, version):
print('Version is invalid')
sys.exit(1)

# PACKAGE.JSON
with open('package.json', 'r') as f:
package_json = json.load(f)

package_json['version'] = version

with open('package.json', 'w') as f:
json.dump(package_json, f, indent=2)

# TAURI.CONF.JSON
tauri_conf_path = os.path.join('src-tauri', 'tauri.conf.json')
with open(tauri_conf_path, 'r') as f:
tauri_conf_json = json.load(f)

tauri_conf_json['package']['version'] = version

with open(tauri_conf_path, 'w') as f:
json.dump(tauri_conf_json, f, indent=2)

# CARGO.TOML
cargo_toml_path = os.path.join('src-tauri', 'Cargo.toml')
with open(cargo_toml_path, 'r') as f:
cargo_toml = f.read()

cargo_toml = re.sub(r'version = "\d+\.\d+\.\d+"',
f'version = "{version}"', cargo_toml)

with open(cargo_toml_path, 'w') as f:
f.write(cargo_toml)

0 comments on commit 6d9a3c0

Please sign in to comment.