mirror of
https://github.com/Nezumi-2711/revanced-apk-build.git
synced 2026-09-22 13:38:52 +00:00
404 lines
15 KiB
YAML
Executable File
404 lines
15 KiB
YAML
Executable File
name: Build Modules
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
from_ci:
|
|
type: boolean
|
|
required: false
|
|
default: true
|
|
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
run:
|
|
permissions: write-all
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-java@v5
|
|
with:
|
|
distribution: "zulu"
|
|
java-version: "21"
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: true
|
|
|
|
- name: Update config
|
|
if: ${{ inputs.from_ci }}
|
|
run: |
|
|
if git checkout origin/update build.md; then
|
|
UPDATE_CFG=$(./build.sh config.toml --config-update)
|
|
if [ "$UPDATE_CFG" ]; then
|
|
echo "$UPDATE_CFG" > config.json
|
|
fi
|
|
fi
|
|
|
|
- name: Get next version code
|
|
id: next_ver_code
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
TAG=$(gh release list -L 1 | awk -F '\t' '{print $3}')
|
|
if [ -z "$TAG" ]; then TAG=0; fi
|
|
echo "NEXT_VER_CODE=$((TAG + 1))" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build modules/APKs
|
|
run: if [ -f "config.json" ]; then ./build.sh config.json; else ./build.sh config.toml; fi
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
|
NEXT_VER_CODE: ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}
|
|
|
|
- name: Get output
|
|
id: get_output
|
|
run: |
|
|
DELIM="$(openssl rand -hex 8)"
|
|
echo "BUILD_LOG<<${DELIM}" >> "$GITHUB_OUTPUT"
|
|
cat build.md >> "$GITHUB_OUTPUT"
|
|
echo "${DELIM}" >> "$GITHUB_OUTPUT"
|
|
cp -f build.md build.tmp
|
|
|
|
- name: Upload release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
TAG: ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}
|
|
BODY: ${{ steps.get_output.outputs.BUILD_LOG }}
|
|
run: |
|
|
if gh release view "$TAG" >/dev/null 2>&1; then
|
|
gh release edit "$TAG" --title "Release" --notes "$BODY"
|
|
gh release upload "$TAG" ./build/* --clobber
|
|
else
|
|
gh release create "$TAG" ./build/* --title "Release" --notes "$BODY"
|
|
fi
|
|
|
|
- name: Update modules changelog and update json
|
|
id: update_config
|
|
run: |
|
|
git checkout -f update || git switch --discard-changes --orphan update
|
|
cp -f build.tmp build.md
|
|
get_update_json() {
|
|
echo "{
|
|
\"version\": \"$1\",
|
|
\"versionCode\": ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }},
|
|
\"zipUrl\": \"$2\",
|
|
\"changelog\": \"https://raw.githubusercontent.com/$GITHUB_REPOSITORY/update/build.md\"
|
|
}"
|
|
}
|
|
|
|
cd build || { echo "build folder not found"; exit 1; }
|
|
for OUTPUT in *module*.zip; do
|
|
[ "$OUTPUT" = "*module*.zip" ] && continue
|
|
ZIP_S=$(unzip -p "$OUTPUT" module.prop)
|
|
if ! UPDATE_JSON=$(echo "$ZIP_S" | grep updateJson); then continue; fi
|
|
UPDATE_JSON="${UPDATE_JSON##*/}"
|
|
VER=$(echo "$ZIP_S" | grep version=)
|
|
VER="${VER##*=}"
|
|
DLURL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}/${OUTPUT}"
|
|
get_update_json "$VER" "$DLURL" >"../$UPDATE_JSON"
|
|
done
|
|
cd ..
|
|
|
|
find . -name "*-update.json" | grep . || : >dummy-update.json
|
|
|
|
- name: Commit module json changes
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
git add build.md *-update.json
|
|
|
|
if ! git diff --cached --quiet; then
|
|
git commit -m "Bump version ${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}"
|
|
git push origin HEAD:update
|
|
else
|
|
echo "no changes!"
|
|
fi
|
|
|
|
- name: Report to Telegram
|
|
env:
|
|
TG_TOKEN: ${{ secrets.TG_TOKEN }}
|
|
if: env.TG_TOKEN != null
|
|
run: |
|
|
cd build || { echo "build folder not found"; exit 1; }
|
|
|
|
TG_CHAT="@rvc_magisk"
|
|
NL=$'\n'
|
|
APKS=""
|
|
MODULES=""
|
|
for OUTPUT in *; do
|
|
DL_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}/${OUTPUT}"
|
|
if [[ $OUTPUT = *.apk ]]; then
|
|
APKS+="${NL}📦[${OUTPUT}](${DL_URL})"
|
|
elif [[ $OUTPUT = *.zip ]]; then
|
|
MODULES+="${NL}📦[${OUTPUT}](${DL_URL})"
|
|
fi
|
|
done
|
|
MODULES=${MODULES#"$NL"}
|
|
APKS=${APKS#"$NL"}
|
|
|
|
BODY="$(sed 's/^\* \*\*/↪ \*\*/g; s/^\* `/↪ \*\*/g; s/`/\*/g; s/^\* /\↪/g; s/\*\*/\*/g; s/###//g; s/^- /↪ /g; /^==/d;' ../build.md)"
|
|
MSG="*New build!*
|
|
|
|
${BODY}
|
|
|
|
*▼ Download Links:*
|
|
Modules:
|
|
${MODULES}
|
|
|
|
APKs:
|
|
${APKS}
|
|
"
|
|
echo "'$MSG'"
|
|
MSG=${MSG:0:9450}
|
|
POST="https://api.telegram.org/bot${TG_TOKEN}/sendMessage"
|
|
curl -X POST --data-urlencode "parse_mode=Markdown" --data-urlencode "disable_web_page_preview=true" --data-urlencode "text=${MSG}" --data-urlencode "chat_id=${TG_CHAT}" "$POST"
|
|
|
|
- name: Report to Discord
|
|
env:
|
|
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
|
if: env.DISCORD_WEBHOOK_URL != null
|
|
run: |
|
|
cd build || { echo "build folder not found"; exit 1; }
|
|
|
|
NL=$'\n'
|
|
APKS=""
|
|
MODULES=""
|
|
for OUTPUT in *; do
|
|
DL_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}/${OUTPUT}"
|
|
if [[ $OUTPUT = *.apk ]]; then
|
|
APKS+="${NL}- [${OUTPUT}](${DL_URL})"
|
|
elif [[ $OUTPUT = *.zip ]]; then
|
|
MODULES+="${NL}- [${OUTPUT}](${DL_URL})"
|
|
fi
|
|
done
|
|
|
|
MODULES=${MODULES#"$NL"}
|
|
APKS=${APKS#"$NL"}
|
|
|
|
BODY="$(sed 's/^\* \*\*/- \*\*/g; s/^\* `/- \*\*/g; s/`/\*/g; s/^\* /\-/g; s/\*\*/\*/g; s/###//g; s/^- /- /g; /^==/d;' ../build.md)"
|
|
MSG="**New build is ready!**
|
|
|
|
${BODY}
|
|
|
|
**Download Links:**
|
|
"
|
|
|
|
MODULES_MSG="
|
|
**Modules:**
|
|
${MODULES}
|
|
"
|
|
|
|
APKS_MSG="
|
|
**APKs:**
|
|
${APKS}
|
|
"
|
|
|
|
curl -X POST -H "Content-Type: application/json" \
|
|
-d "$(jq -n --arg content "$MSG" '{content: $content}')" \
|
|
"$DISCORD_WEBHOOK_URL"
|
|
|
|
# curl -X POST -H "Content-Type: application/json" \
|
|
# -d "$(jq -n --arg content "$MODULES_MSG" '{content: $content}')" \
|
|
# "$DISCORD_WEBHOOK_URL"
|
|
|
|
curl -X POST -H "Content-Type: application/json" \
|
|
-d "$(jq -n --arg content "$APKS_MSG" '{content: $content}')" \
|
|
"$DISCORD_WEBHOOK_URL"
|
|
|
|
- name: Report to Noob Discord
|
|
env:
|
|
DISCORD_WEBHOOK_NOOB_URL: ${{ secrets.DISCORD_WEBHOOK_NOOB_URL }}
|
|
if: env.DISCORD_WEBHOOK_NOOB_URL != null
|
|
run: |
|
|
cd build || { echo "build folder not found"; exit 1; }
|
|
|
|
NL=$'\n'
|
|
APKS=""
|
|
MODULES=""
|
|
for OUTPUT in *; do
|
|
DL_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}/${OUTPUT}"
|
|
if [[ $OUTPUT = *.apk ]]; then
|
|
APKS+="${NL}- [${OUTPUT}](${DL_URL})"
|
|
elif [[ $OUTPUT = *.zip ]]; then
|
|
MODULES+="${NL}- [${OUTPUT}](${DL_URL})"
|
|
fi
|
|
done
|
|
|
|
MODULES=${MODULES#"$NL"}
|
|
APKS=${APKS#"$NL"}
|
|
|
|
BODY="$(sed 's/^\* \*\*/- \*\*/g; s/^\* `/- \*\*/g; s/`/\*/g; s/^\* /\-/g; s/\*\*/\*/g; s/###//g; s/^- /- /g; /^==/d;' ../build.md)"
|
|
MSG="**New build is ready!**
|
|
|
|
${BODY}
|
|
|
|
**Download Links:**
|
|
"
|
|
|
|
MODULES_MSG="
|
|
**Modules:**
|
|
${MODULES}
|
|
"
|
|
|
|
APKS_MSG="
|
|
**APKs:**
|
|
${APKS}
|
|
"
|
|
|
|
curl -X POST -H "Content-Type: application/json" \
|
|
-d "$(jq -n --arg content "$MSG" '{content: $content}')" \
|
|
"$DISCORD_WEBHOOK_NOOB_URL"
|
|
|
|
# curl -X POST -H "Content-Type: application/json" \
|
|
# -d "$(jq -n --arg content "$MODULES_MSG" '{content: $content}')" \
|
|
# "$DISCORD_WEBHOOK_NOOB_URL"
|
|
|
|
curl -X POST -H "Content-Type: application/json" \
|
|
-d "$(jq -n --arg content "$APKS_MSG" '{content: $content}')" \
|
|
"$DISCORD_WEBHOOK_NOOB_URL"
|
|
|
|
- name: Send Email Notification (Resend)
|
|
env:
|
|
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
|
|
MAIL_TO: ${{ secrets.MAIL_TO }}
|
|
MAIL_CC: ${{ secrets.MAIL_CC }}
|
|
MAIL_BCC: ${{ secrets.MAIL_BCC }}
|
|
MAIL_FROM: ${{ secrets.MAIL_FROM }}
|
|
if: env.RESEND_API_KEY != null && env.MAIL_TO != null
|
|
run: |
|
|
VERSION="${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}"
|
|
RELEASE_URL="${{ github.server_url }}/${{ github.repository }}/releases/tag/${VERSION}"
|
|
REPO="${{ github.repository }}"
|
|
|
|
# Set default FROM address if not provided
|
|
FROM_ADDRESS="${MAIL_FROM:-ReVanced Build Bot <onboarding@resend.dev>}"
|
|
|
|
# Build download links from build folder (separate APKs and Modules)
|
|
cd build || { echo "build folder not found"; exit 1; }
|
|
|
|
APK_LINKS=""
|
|
MODULE_LINKS=""
|
|
for OUTPUT in *; do
|
|
DL_URL="${{ github.server_url }}/${{ github.repository }}/releases/download/${VERSION}/${OUTPUT}"
|
|
if [[ $OUTPUT = *.apk ]]; then
|
|
APK_LINKS+="<li style=\"margin: 8px 0;\">📦 <a href=\"${DL_URL}\" style=\"color: #667eea; text-decoration: none;\">${OUTPUT}</a></li>"
|
|
elif [[ $OUTPUT = *.zip ]]; then
|
|
MODULE_LINKS+="<li style=\"margin: 8px 0;\">📁 <a href=\"${DL_URL}\" style=\"color: #667eea; text-decoration: none;\">${OUTPUT}</a></li>"
|
|
fi
|
|
done
|
|
cd ..
|
|
|
|
# Get current time in Vietnam timezone (UTC+7)
|
|
BUILD_TIME=$(TZ='Asia/Ho_Chi_Minh' date '+%Y-%m-%d %H:%M:%S (UTC+7)')
|
|
|
|
# Get changelog from build.md and convert to HTML
|
|
if [ -f "build.md" ]; then
|
|
# Convert markdown to simple HTML
|
|
CHANGELOG_HTML=$(sed 's/^### \(.*\)/<h3 style="color: #667eea; font-size: 16px; margin: 15px 0 8px 0;">\1<\/h3>/g;
|
|
s/^\* \*\*\(.*\)\*\*/<li style="margin: 5px 0;"><strong>\1<\/strong><\/li>/g;
|
|
s/^\* \(.*\)/<li style="margin: 5px 0;">\1<\/li>/g;
|
|
s/^- \(.*\)/<li style="margin: 5px 0;">\1<\/li>/g;
|
|
s/`\([^`]*\)`/<code style="background: #e9ecef; padding: 2px 6px; border-radius: 3px; font-size: 13px;">\1<\/code>/g;
|
|
/^==/d;
|
|
/^$/d' build.md | tr '\n' ' ')
|
|
else
|
|
CHANGELOG_HTML="<p>No changelog available.</p>"
|
|
fi
|
|
|
|
# Create HTML email body (similar structure to Telegram)
|
|
HTML_BODY=$(cat <<EOF
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
</head>
|
|
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 0;">
|
|
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 30px; text-align: center;">
|
|
<h1 style="margin: 0;">🎉 New ReVanced Build!</h1>
|
|
<p style="margin: 10px 0 0 0; font-size: 18px;">Version: v${VERSION}</p>
|
|
<p style="margin: 5px 0 0 0; font-size: 14px; opacity: 0.9;">🕐 ${BUILD_TIME}</p>
|
|
</div>
|
|
|
|
<div style="padding: 25px; background: #f9f9f9;">
|
|
<!-- Changelog Section -->
|
|
<div style="margin-bottom: 25px; background: white; padding: 20px; border-radius: 8px; border-left: 4px solid #667eea;">
|
|
<h2 style="color: #667eea; font-size: 18px; margin: 0 0 15px 0;">📋 Changelog</h2>
|
|
<div style="font-size: 14px;">
|
|
${CHANGELOG_HTML}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Download Links Section -->
|
|
<div style="margin-bottom: 25px; background: white; padding: 20px; border-radius: 8px;">
|
|
<h2 style="color: #667eea; font-size: 18px; margin: 0 0 15px 0;">� Download Links</h2>
|
|
|
|
<!-- Modules -->
|
|
$(if [ -n "$MODULE_LINKS" ]; then echo "
|
|
<div style=\"margin-bottom: 15px;\">
|
|
<h3 style=\"color: #555; font-size: 15px; margin: 0 0 10px 0;\">� Modules:</h3>
|
|
<ul style=\"list-style: none; padding: 0; margin: 0;\">
|
|
${MODULE_LINKS}
|
|
</ul>
|
|
</div>
|
|
"; fi)
|
|
|
|
<!-- APKs -->
|
|
$(if [ -n "$APK_LINKS" ]; then echo "
|
|
<div>
|
|
<h3 style=\"color: #555; font-size: 15px; margin: 0 0 10px 0;\">📱 APKs:</h3>
|
|
<ul style=\"list-style: none; padding: 0; margin: 0;\">
|
|
${APK_LINKS}
|
|
</ul>
|
|
</div>
|
|
"; fi)
|
|
</div>
|
|
|
|
<!-- GitHub Button -->
|
|
<div style="text-align: center;">
|
|
<a href="${RELEASE_URL}" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 30px; text-decoration: none; border-radius: 25px; font-weight: bold;">
|
|
View Release on GitHub
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="text-align: center; padding: 20px; background: #333; color: #999; font-size: 12px;">
|
|
<p style="margin: 0;">This is an automated message from ReVanced Build Bot</p>
|
|
<p style="margin: 5px 0 0 0;">Repository: ${REPO}</p>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
EOF
|
|
)
|
|
|
|
# Build JSON payload with TO, CC and BCC recipients
|
|
# Resend allows up to 50 recipients per field (to, cc, bcc)
|
|
JSON_PAYLOAD=$(jq -n \
|
|
--arg from "$FROM_ADDRESS" \
|
|
--arg to "$MAIL_TO" \
|
|
--arg cc "$MAIL_CC" \
|
|
--arg bcc "$MAIL_BCC" \
|
|
--arg subject "🚀 New ReVanced Build Available - v${VERSION}" \
|
|
--arg html "$HTML_BODY" \
|
|
'{
|
|
from: $from,
|
|
to: ($to | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; ""))),
|
|
subject: $subject,
|
|
html: $html
|
|
}
|
|
+ (if $cc != "" then {cc: ($cc | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; "")))} else {} end)
|
|
+ (if $bcc != "" then {bcc: ($bcc | split(",") | map(select(. != "") | gsub("^\\s+|\\s+$"; "")))} else {} end)'
|
|
)
|
|
|
|
echo "📧 Sending email notification..."
|
|
|
|
# Send email via Resend API
|
|
RESPONSE=$(curl -s -X POST "https://api.resend.com/emails" \
|
|
-H "Authorization: Bearer ${RESEND_API_KEY}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$JSON_PAYLOAD")
|
|
|
|
echo "Response: $RESPONSE"
|
|
echo "✅ Email sent successfully!"
|