feat(bump-versions.sh): Add support to multisrc (#1356)
* feat(bump-versions.sh): Add support to multisrc * [skip ci] re-add fix in workflow for library updates
This commit is contained in:
parent
140620670c
commit
2c6d80c90f
76
.github/scripts/bump-versions.sh
vendored
76
.github/scripts/bump-versions.sh
vendored
@ -1,32 +1,90 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
versionStr="extVersionCode ="
|
versionStr="extVersionCode ="
|
||||||
|
multisrcVersionStr="overrideVersionCode ="
|
||||||
|
bumpedFiles=""
|
||||||
|
|
||||||
|
|
||||||
|
# cut -d "=" -f 2 -> string.split("=")[1]
|
||||||
|
# "extVersionCode = 6" -> ["extVersionCode ", " 6"] -> " 6" -> "6"
|
||||||
|
getValue() { cut -d "=" -f 2 | cut -d " " -f 2;}
|
||||||
getVersion() {
|
getVersion() {
|
||||||
# cut -d "=" -f 2 -> string.split("=")[1]
|
if [[ $1 =~ ^multisrc/ ]]; then
|
||||||
# "extVersionCode = 6" -> ["extVersionCode ", " 6"] -> " 6" -> "6"
|
# We are going to be piped, so no file specified, just read from stdin.
|
||||||
grep "$versionStr" "$1" | cut -d "=" -f 2 | cut -d " " -f 2
|
grep -Po "$multisrcVersionStr \d+" | getValue
|
||||||
|
else
|
||||||
|
grep "$versionStr" "$1" | getValue
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# expected input: multisrc/overrides/<theme>/<override>/....
|
||||||
|
# if override is default, then it will bump all overrides.
|
||||||
|
bumpMultisrcVersion() {
|
||||||
|
local overridePath=$1
|
||||||
|
# Prevents bumping extensions multiple times.
|
||||||
|
# Ex: When a theme uses a extractor per default, but one extension(override)
|
||||||
|
# also uses another, so if both libs are modifyed, such extension will be
|
||||||
|
# bumped only once instead of two times.
|
||||||
|
if [[ $bumpedFiles =~( |^)$overridePath( |$) ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
bumpedFiles+="$overridePath "
|
||||||
|
|
||||||
|
# Bump all extensions from a multisrc that implements a lib by default
|
||||||
|
if [[ $overridePath =~ .*/default/.* ]]; then
|
||||||
|
local themeBase=$(echo $overridePath | cut -d/ -f-3)
|
||||||
|
for file in $(ls $themeBase | grep -v default); do
|
||||||
|
bumpMultisrcVersion $themeBase/$file/
|
||||||
|
done
|
||||||
|
else
|
||||||
|
local theme=$(echo $overridePath | cut -d/ -f3)
|
||||||
|
local themePath="multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/$theme"
|
||||||
|
local sourceName=$(echo $overridePath | cut -d/ -f4)
|
||||||
|
local generator=$(echo $themePath/*Generator.kt)
|
||||||
|
bumpedFiles+="$generator " # Needed to commit the changes
|
||||||
|
|
||||||
|
local sourceLine=$(grep -i $sourceName $generator)
|
||||||
|
local oldVersion=$(echo $sourceLine | getVersion $generator)
|
||||||
|
local newVersionStr="$multisrcVersionStr $((oldVersion + 1))"
|
||||||
|
|
||||||
|
if [[ $sourceLine =~ .*$multisrcVersionStr.* ]]; then
|
||||||
|
# if the override already have a "overrideVersionCode" param at
|
||||||
|
# the generator, then just bump it
|
||||||
|
local newSourceLine=${sourceLine/$multisrcVersionStr $oldVersion/$newVersionStr}
|
||||||
|
else
|
||||||
|
# else, add overrideVersionCode param to its line on the generator
|
||||||
|
local newSourceLine=${sourceLine/)/, $newVersionStr)}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\nmultisrc $sourceName($theme): $oldVersion -> $((oldVersion + 1))\n"
|
||||||
|
sed -i "s@$sourceLine@$newSourceLine@g" $generator
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
bumpVersion() {
|
bumpVersion() {
|
||||||
local file=$1
|
local file=$1
|
||||||
local old_version=$(getVersion $file)
|
local oldVersion=$(getVersion $file)
|
||||||
local new_version=$((old_version + 1))
|
local newVersion=$((oldVersion + 1))
|
||||||
|
|
||||||
echo -e "\n$file: $old_version -> $new_version\n"
|
echo -e "\n$file: $oldVersion -> $newVersion\n"
|
||||||
sed -i "s/$versionStr $old_version/$versionStr $new_version/" $file
|
sed -i "s/$versionStr $oldVersion/$versionStr $newVersion/" $file
|
||||||
}
|
}
|
||||||
|
|
||||||
findAndBump() {
|
findAndBump() {
|
||||||
local bumpedFiles=""
|
|
||||||
for lib in $@; do
|
for lib in $@; do
|
||||||
for file in $(grep -l -R ":lib-$lib" --include "build.gradle"); do
|
for file in $(grep -l -R ":lib-$lib" --include "build.gradle" --include "additional.gradle"); do
|
||||||
# prevent bumping the same extension multiple times
|
# prevent bumping the same extension multiple times
|
||||||
if [[ ! $bumpedFiles =~ ( |^)$file( |$) ]]; then
|
if [[ ! $bumpedFiles =~ ( |^)$file( |$) ]]; then
|
||||||
|
if [[ $file =~ ^multisrc ]]; then
|
||||||
|
bumpMultisrcVersion ${file/additional.gradle/}
|
||||||
|
else
|
||||||
bumpedFiles+="$file "
|
bumpedFiles+="$file "
|
||||||
bumpVersion $file
|
bumpVersion $file
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
commitChanges $bumpedFiles
|
commitChanges $bumpedFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
.github/workflows/build_push.yml
vendored
6
.github/workflows/build_push.yml
vendored
@ -26,6 +26,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Clone repo
|
- name: Clone repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
|
||||||
- name: Find lib changes
|
- name: Find lib changes
|
||||||
id: modified-libs
|
id: modified-libs
|
||||||
@ -89,6 +91,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout master branch
|
- name: Checkout master branch
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
@ -138,6 +142,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout master branch
|
- name: Checkout master branch
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user