forked from mrgnhnt96/pub_version_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.yaml
80 lines (64 loc) · 2.13 KB
/
scripts.yaml
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
test: sip test --bail --recursive --concurrent --test-randomize-ordering-seed random
install:
(aliases): i
(command): dart pub global activate . --source path --overwrite
clean:
(command):
- dart analyze .
- dart format .
pub:
get: sip pub get --recursive --no-version-check --precompile
upgrade: sip pub upgrade --recursive --no-version-check --major-versions --tighten
prep:
pubspecs: |
# get version from changelog
version=$(grep -m 1 "# " CHANGELOG.md | awk '{print $2}')
echo "Updating pubspec.yaml version to $version"
sed -i '' "s|^version: .*|version: $version|g" "pubspec.yaml"
publish:
(bail):
(command):
- '{$clean}'
- '{$pub:get}'
- '{$test}'
- '{$prep:pubspecs}'
- dart pub publish
- "{$publish:commit}"
- "{$publish:tag}"
- "{$publish:_push}"
commit: |
# get version from changelog
version=$(grep -m 1 "# " CHANGELOG.md | awk '{print $2}')
echo "Committing version $version"
git add .
git commit -m "v$version"
tag: |
# get version from changelog
version=$(grep -m 1 "# " CHANGELOG.md | awk '{print $2}')
echo "Tagging version $version"
git tag -a "v$version" -m "v$version"
_push: |
echo "Pushing to origin"
git push
git push --tags
sync-version:
(aliases): version
(command): |
# Sets package version in source code
VERSION=$(cat pubspec.yaml | grep "version:" | head -n 1 | awk '{print $2}' | sed 's/\"//g')
# Check if version extraction was successful
if [ -z "$VERSION" ]; then
echo "Error: Version could not be extracted from pubspec.yaml."
exit 1
fi
# Prepare the content of the version file
content="// GENERATED CODE - DO NOT MODIFY BY HAND
//
// Generated by \`sip run sync-version\`
const String version = '$VERSION';"
# Write the content to the version.dart file, creating or overwriting it
echo "$content" > lib/src/version.dart || {
echo "Error writing to lib/src/version.dart"
exit 1
}
echo "Version updated to $VERSION in lib/src/version.dart"