Skip to content

Commit

Permalink
ci: refactor flags script and no need to make project secret
Browse files Browse the repository at this point in the history
  • Loading branch information
SKetU-l committed Sep 15, 2024
1 parent 619fa69 commit 3e8ad30
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 54 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ jobs:
RELEASE: ${{ inputs.RELEASE }}
VARIANT: ${{ inputs.VARIANT }}
STAGING: ${{ needs.check-limit.outputs.staging }}
PROJECT: ${{ secrets.PROJECT }}
SF_HOST: ${{ secrets.SF_HOST }}
SF_USERNAME: ${{ secrets.SF_USERNAME }}
SF_PASSWORD: ${{ secrets.SF_PASSWORD }}
Expand Down
101 changes: 50 additions & 51 deletions misc/flags.sh
Original file line number Diff line number Diff line change
@@ -1,67 +1,66 @@
#!/bin/bash

if [ -z "$VARIANT" ]; then
echo "Error: The VARIANT environment variable is not set."
exit 1
fi

value=$(echo "$VARIANT" | tr '[:lower:]' '[:upper:]')

if [[ "$value" != "VANILLA" && "$value" != "CORE" && "$value" != "GAPPS" ]]; then
exit 1
fi

VARIANT=$(echo "$VARIANT" | tr '[:lower:]' '[:upper:]')
process_file() {
local file="$1"
local value="$2"
tmp_file=$(mktemp)
WITH_GMS_handled=false
TARGET_CORE_GMS_handled=false
TARGET_DEFAULT_PIXEL_LAUNCHER_handled=false
local tmp_file=$(mktemp)
local with_gms_found=false
local target_core_gms_found=false
local target_default_pixel_launcher_found=false
local changes_made=false

while IFS= read -r line; do
if [[ "$line" =~ WITH_GMS ]]; then
WITH_GMS_handled=true
case $value in
VANILLA)
line="${line/true/false}"
;;
CORE)
if [[ "$line" == *"false"* ]]; then
line="${line/false/true}"
fi
;;
GAPPS)
line="${line/false/true}"
;;
esac
fi

if [[ "$value" == "CORE" && "$line" =~ TARGET_CORE_GMS ]]; then
TARGET_CORE_GMS_handled=true
line="TARGET_CORE_GMS := true"
with_gms_found=true
new_line="WITH_GMS := $([ "$VARIANT" != "VANILLA" ] && echo "true" || echo "false")"
if [ "$line" != "$new_line" ]; then
line="$new_line"
changes_made=true
fi
elif [[ "$line" =~ TARGET_CORE_GMS ]]; then
target_core_gms_found=true
new_line="TARGET_CORE_GMS := $([ "$VARIANT" == "CORE" ] && echo "true" || echo "false")"
if [ "$line" != "$new_line" ]; then
line="$new_line"
changes_made=true
fi
elif [[ "$line" =~ TARGET_DEFAULT_PIXEL_LAUNCHER ]]; then
target_default_pixel_launcher_found=true
if [ "$VARIANT" == "VANILLA" ]; then
new_line="TARGET_DEFAULT_PIXEL_LAUNCHER := false"
if [ "$line" != "$new_line" ]; then
line="$new_line"
changes_made=true
fi
fi
fi
echo "$line" >> "$tmp_file"
done < "$file"

if [[ "$value" == "GAPPS" && "$line" =~ TARGET_CORE_GMS && "$line" == *"true"* ]]; then
line="TARGET_CORE_GMS := false"
if [ "$VARIANT" == "CORE" ]; then
if [ "$with_gms_found" = false ]; then
echo "WITH_GMS := true" >> "$tmp_file"
changes_made=true
fi

if [[ "$value" == "VANILLA" && "$line" =~ TARGET_DEFAULT_PIXEL_LAUNCHER ]]; then
TARGET_DEFAULT_PIXEL_LAUNCHER_handled=true
line="TARGET_DEFAULT_PIXEL_LAUNCHER := false"
if [ "$target_core_gms_found" = false ]; then
echo "TARGET_CORE_GMS := true" >> "$tmp_file"
changes_made=true
fi
elif [ "$VARIANT" == "GAPPS" ] && [ "$with_gms_found" = false ]; then
echo "WITH_GMS := true" >> "$tmp_file"
changes_made=true
fi

echo "$line" >> "$tmp_file"
done < "$file"
if [[ "$value" == "VANILLA" && "$WITH_GMS_handled" == "false" ]]; then
if [ "$changes_made" = true ]; then
mv "$tmp_file" "$file"
echo "Modified: $file"
echo " - Updated flags for $VARIANT Build"
else
rm "$tmp_file"
return
echo "No changes needed for: $file"
fi
mv "$tmp_file" "$file"
}

files=$(find /home/sketu/rising/device/$BRAND/$CODENAME -name "lineage_$CODENAME.mk")
echo "Edited flags in: $files"

for file in $files; do
process_file "$file" "$value"
find "/home/sketu/test/device/$BRAND/$CODENAME" -name "lineage_$CODENAME.mk" | while read -r file; do
process_file "$file"
done
4 changes: 2 additions & 2 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upload_to_drive() {
upload_to_sourceforge() {
local file="$1"
echo "Attempting to upload $file to SourceForge..."
sshpass -p "$SF_PASSWORD" rsync -avP -e "ssh -o StrictHostKeyChecking=no" "$file" $SF_USERNAME@$SF_HOST:/home/frs/project/$PROJECT/$CODENAME/
sshpass -p "$SF_PASSWORD" rsync -avP -e "ssh -o StrictHostKeyChecking=no" "$file" $SF_USERNAME@$SF_HOST:/home/frs/project/risingos-test/$CODENAME/
if [ $? -eq 0 ]; then
echo "Uploaded $file to SourceForge successfully."
else
Expand Down Expand Up @@ -78,7 +78,7 @@ case $DESTINATION in
upload_to_sourceforge "$FILE" || exit 1
done
echo "All uploads to SourceForge completed."
echo "Uploaded to here: https://sourceforge.net/projects/$PROJECT/files/$CODENAME"
echo "Uploaded to here: https://sourceforge.net/projects/risingos-test/files/$CODENAME"
;;
*)
echo "Error: Invalid destination '$DESTINATION'."
Expand Down

0 comments on commit 3e8ad30

Please sign in to comment.