-
Notifications
You must be signed in to change notification settings - Fork 8
/
justfile
188 lines (161 loc) · 6.94 KB
/
justfile
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
alias b := build
alias cncfrn := copy-native-code-from-react-native
alias d := docs
alias f := format
alias gd := get-dependencies
alias pt := push-tag
alias od := open-docs
alias ogp := open-github-prs
alias ogr := open-github-releases
alias r := release
alias s := setup
alias us := update-sdk
alias usa := update-sdk-android
alias usal := update-sdk-android-latest
alias usi := update-sdk-ios
alias usil := update-sdk-ios-latest
alias usl := update-sdk-latest
alias v := version
# Source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# \ are escaped
SEMVER_REGEX := "(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?"
# MAKE SURE YOU HAVE
# #!/usr/bin/env sh
# set -e
# AT THE TOP OF YOUR RECIPE
_ask-confirm:
@bash -c 'read confirmation; if [[ $confirmation != "y" && $confirmation != "Y" ]]; then echo "Okay 😮💨 😅"; exit 1; fi'
build: get-dependencies docs
copy-native-code-from-react-native:
cp -rf ../sdk-react-native/sdk/android/src/main/java/com/reactnativehypertracksdk/common android/src/main/kotlin/com/hypertrack/sdk/flutter/
cp -rf ../sdk-react-native/sdk/ios/common ios/Classes/
docs: format
@echo "Docs generation usually takes ~1 minute"
dart doc --output=docs > /dev/null
format:
brew upgrade ktlint
ktlint --format android/src/main/
get-dependencies:
flutter pub get
_latest-android:
@curl -s https://s3-us-west-2.amazonaws.com/m2.hypertrack.com/com/hypertrack/sdk-android/maven-metadata-sdk-android.xml | grep latest | grep -o -E '{{SEMVER_REGEX}}' | head -n 1
_latest-ios:
@curl -s https://cocoapods.org/pods/HyperTrack | grep -m 1 -o -E "HyperTrack <span>{{SEMVER_REGEX}}" | grep -o -E '{{SEMVER_REGEX}}' | head -n 1
open-docs:
open docs/index.html
_open-github-release-data:
code CHANGELOG.md
just open-github-releases
open-github-prs:
open "https://github.com/hypertrack/sdk-flutter/pulls"
open-github-releases:
open "https://github.com/hypertrack/sdk-flutter/releases"
push-tag:
#!/usr/bin/env sh
if [ $(git symbolic-ref --short HEAD) = "master" ] ; then
VERSION=$(just version)
git tag $VERSION
git push origin $VERSION
just _open-github-release-data
else
echo "You are not on master branch"
fi
release type="dry-run": setup docs
#!/usr/bin/env sh
set -euo pipefail
VERSION=$(just version)
if [ "{{type}}" = "publish" ] ; then
BRANCH=$(git branch --show-current)
if [ $BRANCH != "master" ]; then
echo "You must be on main branch to publish a new version (current branch: $BRANCH))"
exit 1
fi
echo "Are you sure you want to publish version $VERSION? (y/N)"
just _ask-confirm
flutter pub publish
echo "Generating the docs back (removed to avoid doc/ folder warning)"
open https://pub.dev/packages/hypertrack_plugin/versions/$VERSION
else
echo "Dry run for version $VERSION"
flutter pub publish --dry-run
fi
setup: get-dependencies
update-sdk-latest wrapper_version commit="true" branch="true":
#!/usr/bin/env sh
LATEST_IOS=$(just _latest-ios)
LATEST_ANDROID=$(just _latest-android)
just update-sdk {{wrapper_version}} $LATEST_IOS $LATEST_ANDROID {{commit}} {{branch}}
update-sdk-android-latest wrapper_version commit="true" branch="true":
#!/usr/bin/env sh
LATEST_ANDROID=$(just _latest-android)
just update-sdk-android {{wrapper_version}} $LATEST_ANDROID {{commit}} {{branch}}
update-sdk-ios-latest wrapper_version commit="true" branch="true":
#!/usr/bin/env sh
LATEST_IOS=$(just _latest-ios)
just update-sdk-ios {{wrapper_version}} $LATEST_IOS {{commit}} {{branch}}
update-sdk wrapper_version ios_version android_version commit="true" branch="true": build
#!/usr/bin/env sh
if [ "{{branch}}" = "true" ] ; then
git checkout -b update-sdk-ios-{{ios_version}}-android-{{android_version}}
fi
just version
echo "New version is {{wrapper_version}}"
just _update-wrapper-version-file {{wrapper_version}}
./scripts/update_changelog.sh -w {{wrapper_version}} -i {{ios_version}} -a {{android_version}}
echo "Updating HyperTrack SDK iOS to {{ios_version}}"
just _update-sdk-ios-version-file {{ios_version}}
echo "Updating HyperTrack SDK Android to {{android_version}}"
just _update-sdk-android-version-file {{android_version}}
just docs
if [ "{{commit}}" = "true" ] ; then
git add .
git commit -m "Update HyperTrack SDK iOS to {{ios_version}} and Android to {{android_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
update-sdk-android wrapper_version android_version commit="true" branch="true": build
#!/usr/bin/env sh
if [ "{{branch}}" = "true" ] ; then
git checkout -b update-sdk-android-{{android_version}}
fi
just version
echo "Updating HyperTrack SDK Android to {{android_version}} on {{wrapper_version}}"
just _update-wrapper-version-file {{wrapper_version}}
just _update-sdk-android-version-file {{android_version}}
./scripts/update_changelog.sh -w {{wrapper_version}} -a {{android_version}}
just docs
if [ "{{commit}}" = "true" ] ; then
git add .
git commit -m "Update HyperTrack SDK Android to {{android_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
update-sdk-ios wrapper_version ios_version commit="true" branch="true": build
#!/usr/bin/env sh
if [ "{{branch}}" = "true" ] ; then
git checkout -b update-sdk-ios-{{ios_version}}
fi
just version
echo "Updating HyperTrack SDK iOS to {{ios_version}} on {{wrapper_version}}"
just _update-wrapper-version-file {{wrapper_version}}
just _update-sdk-ios-version-file {{ios_version}}
./scripts/update_changelog.sh -w {{wrapper_version}} -i {{ios_version}}
just docs
if [ "{{commit}}" = "true" ] ; then
git add .
git commit -m "Update HyperTrack SDK iOS to {{ios_version}}"
fi
if [ "{{branch}}" = "true" ] && [ "{{commit}}" = "true" ] ; then
just open-github-prs
fi
_update-sdk-android-version-file android_version:
./scripts/update_file.sh android/build.gradle 'def hyperTrackVersion = \".*\"' 'def hyperTrackVersion = \"{{android_version}}\"'
_update-sdk-ios-version-file ios_version:
./scripts/update_file.sh ios/hypertrack_plugin.podspec "'HyperTrack', '.*'" "'HyperTrack', '{{ios_version}}'"
_update-wrapper-version-file wrapper_version:
./scripts/update_file.sh pubspec.yaml 'version: .*' 'version: {{wrapper_version}}'
./scripts/update_file.sh ios/hypertrack_plugin.podspec "s.version = '.*'" "s.version = '{{wrapper_version}}'"
version:
@cat pubspec.yaml | grep version | grep -o -E '{{SEMVER_REGEX}}'