forked from InfinityLoop1308/PipePipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
153 lines (121 loc) · 4.51 KB
/
release.sh
File metadata and controls
153 lines (121 loc) · 4.51 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
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
#!/bin/bash
# Usage: ./release.sh <version> [-i]
# Example: ./release.sh v5.0.0 -i
# -i flag: increment versionCode and update fastlane changelog
VERSION=""
INCREMENT_VERSION_CODE=false
# Parse arguments
for arg in "$@"; do
if [[ "$arg" == "-i" ]]; then
INCREMENT_VERSION_CODE=true
elif [[ "$arg" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
VERSION="${arg#v}" # Remove 'v' prefix if present
fi
done
if [ -z "$VERSION" ]; then
echo "Error: Version number required. Usage: ./release.sh <version> [-i]"
echo "Example: ./release.sh v5.0.0 -i"
exit 1
fi
echo "Processing release for version: $VERSION"
if [ "$INCREMENT_VERSION_CODE" = true ]; then
echo "Will increment versionCode and update fastlane changelog"
fi
# Function to update version in build.gradle.kts
update_version() {
local file=$1
local version=$2
if [ ! -f "$file" ]; then
echo "Warning: $file not found, skipping..."
return
fi
# Check if it's the main client build.gradle.kts (has versionName)
if grep -q "versionName" "$file"; then
echo "Updating versionName in $file to $version"
sed -i "s/versionName = \"[^\"]*\"/versionName = \"$version\"/" "$file"
fi
# Update version = "..." pattern (for extractor and shared modules)
if grep -q "^version = " "$file"; then
echo "Updating version in $file to $version"
sed -i "s/^version = \"[^\"]*\"/version = \"$version\"/" "$file"
fi
# Update dependency versions for shared and extractor
echo "Updating dependency versions in $file to $version"
sed -i "s/implementation(\"project.pipepipe:shared:[^\"]*\")/implementation(\"project.pipepipe:shared:$version\")/" "$file"
sed -i "s/implementation(\"project.pipepipe:extractor:[^\"]*\")/implementation(\"project.pipepipe:extractor:$version\")/" "$file"
}
# Function to increment versionCode
increment_version_code() {
local file=$1
if [ ! -f "$file" ]; then
echo "Warning: $file not found, skipping versionCode increment..."
return
fi
if grep -q "versionCode" "$file"; then
local current_code=$(grep "versionCode = " "$file" | sed 's/.*versionCode = \([0-9]*\).*/\1/')
local new_code=$((current_code + 1))
echo "Incrementing versionCode from $current_code to $new_code in $file"
sed -i "s/versionCode = $current_code/versionCode = $new_code/" "$file"
echo "$new_code"
fi
}
# Client module
echo "=== Processing client module ==="
git pull
git pull git@codeberg.org:NullPointerException/PipePipe.git
# Update version numbers in client build.gradle.kts
update_version "android/build.gradle.kts" "$VERSION"
# Handle versionCode increment and fastlane changelog
if [ "$INCREMENT_VERSION_CODE" = true ]; then
NEW_VERSION_CODE=$(increment_version_code "android/build.gradle.kts")
if [ -n "$NEW_VERSION_CODE" ]; then
CHANGELOG_FILE="fastlane/metadata/android/en-US/changelogs/${NEW_VERSION_CODE}.txt"
mkdir -p "fastlane/metadata/android/en-US/changelogs"
if [ ! -f "$CHANGELOG_FILE" ]; then
echo "Creating changelog file: $CHANGELOG_FILE"
touch "$CHANGELOG_FILE"
fi
echo "Opening changelog file for editing..."
vim "$CHANGELOG_FILE"
fi
else
echo "Skipping versionCode increment (use -i flag to enable)"
fi
# Commit changes
git add android/build.gradle.kts
if [ "$INCREMENT_VERSION_CODE" = true ] && [ -n "$NEW_VERSION_CODE" ]; then
git add "fastlane/metadata/android/en-US/changelogs/${NEW_VERSION_CODE}.txt"
fi
git commit -m "v$VERSION"
git push
git push git@codeberg.org:NullPointerException/PipePipe.git
# Extractor module
echo "=== Processing extractor module ==="
cd ../extractor
git pull
git pull git@codeberg.org:NullPointerException/PipePipeExtractor.git
# Update version numbers in extractor build.gradle.kts
update_version "build.gradle.kts" "$VERSION"
# Commit changes
git add build.gradle.kts
git commit -m "v$VERSION"
git push
git push git@codeberg.org:NullPointerException/PipePipeExtractor.git
# Shared module
echo "=== Processing shared module ==="
cd ../shared
git pull
# Update version numbers in shared build.gradle.kts
update_version "build.gradle.kts" "$VERSION"
# Commit changes
git add build.gradle.kts
git commit -m "v$VERSION"
git push
echo ""
echo "=== Release process completed ==="
echo "Version updated to: $VERSION"
if [ "$INCREMENT_VERSION_CODE" = true ] && [ -n "$NEW_VERSION_CODE" ]; then
echo "Version code incremented to: $NEW_VERSION_CODE"
fi
# Return to client directory
cd ../client