-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitpush.sh
executable file
·68 lines (46 loc) · 1.6 KB
/
gitpush.sh
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
#!/bin/bash
# File to update
CHANGELOG="CHANGELOG.md"
# Read the first line of the CHANGELOG to get the current version
current_version=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/{print $2; exit}' $CHANGELOG)
# Extract major, minor, and patch numbers
IFS='.' read -r major minor patch <<<"$current_version"
# Increment the patch number
patch=$((patch + 1))
# New version
new_version="## $major.$minor.$patch"
# New content to add
NEW_CONTENT="$new_version\n- update\n"
# Append new content to the CHANGELOG
echo -e "$NEW_CONTENT" | cat - $CHANGELOG >temp && mv temp $CHANGELOG
## Update Pubspec.yaml
# File to update
PUBSPEC="pubspec.yaml"
# Check if the file exists
if [ ! -f "$PUBSPEC" ]; then
echo "File not found: $PUBSPEC"
exit 1
fi
# Extract the current version number
current_version=$(grep 'version:' $PUBSPEC | cut -d ' ' -f 2)
echo "Current version: $current_version"
# Break down the version into major, minor, and patch numbers
IFS='.' read -r major minor patch <<<"$current_version"
# Increment the patch number
patch=$((patch + 1))
# Construct the new version string
new_version="$major.$minor.$patch"
echo "New version: $new_version"
# Replace the old version with the new version in the file
# Note the '' after -i for macOS compatibility
sed -i '' "s/version: $current_version/version: $new_version/" $PUBSPEC
# Verify if the replacement was successful
grep 'version:' $PUBSPEC
# ファイルをステージングエリアに追加
git add .
# コミットメッセージとともにコミット
git commit -m 'exp'
# developブランチにプッシュ
git push origin develop
# publish
dart pub publish