-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.py
More file actions
executable file
·74 lines (55 loc) · 2.53 KB
/
release.py
File metadata and controls
executable file
·74 lines (55 loc) · 2.53 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
#!/usr/bin/env python3
import re
import subprocess
pubspecRawContent = ''
podspecRawContent = ''
version = ''
# read the current version number
with open('pubspec.yaml', 'r') as pubspec:
pubspecRawContent = pubspec.read()
match = re.search(r'version: (\d+\.\d+\.\d+)', pubspecRawContent)
version = match.group(1)
# read the current podspec content
with open('ios/flutter_native_barcode_scanner.podspec', 'r') as podspec:
podspecRawContent = podspec.read()
# Ask for a new version number
newVersion = input('New version number: [%s] ' % (version))
# validate the input
if newVersion:
match = re.search(r'^\d+\.\d+\.\d+$', newVersion)
if not match:
print('ERROR: Invalid version number given: %s' % (newVersion))
exit(1)
# default to current version
else:
print('ERROR: A new version version number has to be given: %s' % (newVersion))
exit(1)
# place the new version combination to the pubspecRawContent string
pubspecRawContent = re.sub(r'version: (\d+\.\d+\.\d+)', 'version: %s' %
(newVersion), pubspecRawContent)
podspecRawContent = re.sub(r'\'(\d+\.\d+\.\d+)\'', '\'%s\'' %
(newVersion), podspecRawContent)
# write the updated pubspec content to the pubspec.yaml file
with open('pubspec.yaml', 'w') as pubspec:
pubspec.write(pubspecRawContent)
# write the updated podspec content to the iOS podspec file
with open('ios/flutter_native_barcode_scanner.podspec', 'w') as podspec:
podspec.write(podspecRawContent)
print('Updated pubspec.yaml and ios/flutter_native_barcode_scanner.podspec! Running "flutter pub get" to update other files.')
# update lockfiles
subprocess.run(['flutter', 'pub', 'get'])
# update example iOS Podfile.lock
subprocess.run(['pod', 'install'], cwd = 'example/ios')
print('Staging pubspec.yaml, pubspec.lock, ios/flutter_native_barcode_scanner.podspec, example/pubspec.lock, example/ios/Podfile.lock and CHANGELOG.md ...')
subprocess.run(['git', 'add', 'pubspec.yaml'])
subprocess.run(['git', 'add', 'pubspec.lock'])
subprocess.run(['git', 'add', 'ios/flutter_native_barcode_scanner.podspec'])
subprocess.run(['git', 'add', 'example/pubspec.lock'])
subprocess.run(['git', 'add', 'example/ios/Podfile.lock'])
subprocess.run(['git', 'add', 'CHANGELOG.md'])
print('Creating version commit and tag ...')
subprocess.run(['git', 'commit', '-m', 'v%s' % (newVersion)])
subprocess.run(['git', 'tag', '%s' % (newVersion)])
print('Pushing version commit and tag ...')
subprocess.run(['git', 'push'])
subprocess.run(['git', 'push', '--tags'])