Update strings.xml #191
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Publish Alpha APK | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- "docs/**" | |
- "README.md" | |
- "LICENSE.md" | |
- ".github/workflows/bug_greetings.yml" | |
- ".github/workflows/feature_greetings.yml" | |
- ".github/workflows/pr_greetings.yml" | |
- ".github/workflows/test_build.yml" | |
- ".github/ISSUE_TEMPLATE/config.yml" | |
- ".github/ISSUE_TEMPLATE/report_issue.yml" | |
- ".github/ISSUE_TEMPLATE/request_feature.yml" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
COMMIT_LOG: "" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download last SHA artifact | |
uses: dawidd6/action-download-artifact@v3 | |
with: | |
workflow: publish_alpha.yml | |
name: last-sha | |
path: . | |
continue-on-error: true | |
- name: Get Commits Since Last Run | |
run: | | |
if [ -f last_sha.txt ]; then | |
LAST_SHA=$(cat last_sha.txt) | |
else | |
LAST_SHA=$(git rev-list --max-parents=0 HEAD) | |
fi | |
echo "Commits since $LAST_SHA:" | |
COMMIT_LOGS=$(git log "$LAST_SHA"..HEAD --pretty=format:"● %s ~%an [֍](https://github.com/MrBoomDeveloper/Awery/commit/%H)" --max-count=10) | |
COMMIT_LOGS=$(echo "$COMMIT_LOGS" | sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/MrBoomDeveloper\/Awery\/pull\/\1)/g') | |
COMMIT_LOGS="${COMMIT_LOGS//'%'/'%25'}" | |
COMMIT_LOGS="${COMMIT_LOGS//$'\n'/'%0A'}" | |
COMMIT_LOGS="${COMMIT_LOGS//$'\r'/'%0D'}" | |
echo "COMMIT_LOG=${COMMIT_LOGS}" >> $GITHUB_ENV | |
echo "$COMMIT_LOGS" > commit_log.txt | |
BRANCH=${{ github.ref }} | |
BRANCH=${BRANCH#refs/heads/} | |
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV | |
continue-on-error: true | |
- name: Save Current SHA for Next Run | |
run: echo ${{ github.sha }} > last_sha.txt | |
- name: Set variables | |
run: | | |
VER=$(grep -E -o "versionName \".*\"" app/build.gradle | sed -e 's/versionName //g' | tr -d '"') | |
SHA=${{ github.sha }} | |
VERSION="$VER+${SHA:0:7}" | |
echo "Version $VERSION" | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Setup JDK 17 | |
if: ${{ env.SKIP_BUILD != 'true' }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
cache: gradle | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build Alpha APK | |
id: build_alpha | |
run: ./gradlew assembleAlphaRelease | |
- name: Sign Alpha APK | |
if: success() | |
uses: r0adkll/sign-android-release@v1 | |
with: | |
releaseDirectory: app/build/outputs/apk/alpha/release | |
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} | |
alias: ${{ secrets.ANDROID_KEY_ALIAS }} | |
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }} | |
env: | |
BUILD_TOOLS_VERSION: "34.0.0" | |
- name: Upload Alpha APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "Alpha APK" | |
retention-days: 90 | |
path: "app/build/outputs/apk/alpha/release/app-alpha-release-signed.apk" | |
- name: Upload APK to Discord and Telegram | |
shell: bash | |
run: | | |
fetch_user_details() { | |
local login=$1 | |
user_details=$(curl -s "https://api.github.com/users/$login") | |
name=$(echo "$user_details" | jq -r '.name // .login') | |
login=$(echo "$user_details" | jq -r '.login') | |
avatar_url=$(echo "$user_details" | jq -r '.avatar_url') | |
echo "$name|$login|$avatar_url" | |
} | |
declare -A additional_info | |
additional_info["Sheby"]="\n Discord: <@612532963938271232>\n AniList: [Sheby](<https://anilist.co/user/5724017/>)" | |
additional_info["itsmechinmoy"]="\n Discord: <@523539866311720963>\n AniList: [itsmechinmoy](<https://anilist.co/user/6110204/>)" | |
additional_info["MrBoomDev"]="\n Discord: <@1034891767822176357>" | |
declare -A contributor_colors | |
default_color="6121629" | |
contributor_colors["Sheby"]="#ff9b46" | |
contributor_colors["itsmechinmoy"]="#5d689d" | |
contributor_colors["MrBoomDev"]="#ff7e95" | |
hex_to_decimal() { printf '%d' "0x${1#"#"}"; } | |
declare -A recent_commit_counts | |
echo "Debug: Processing COMMIT_LOG:" | |
echo "$COMMIT_LOG" | |
while read -r count name; do | |
recent_commit_counts["$name"]=$count | |
echo "Debug: Commit count for $name: $count" | |
done < <(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | grep -oP '(?<=~)[^[]*' | sort | uniq -c | sort -rn) | |
echo "Debug: Fetching contributors from GitHub" | |
contributors=$(curl -s "https://api.github.com/repos/${{ github.repository }}/contributors") | |
echo "Debug: Contributors response:" | |
echo "$contributors" | |
sorted_contributors=$(for login in $(echo "$contributors" | jq -r '.[].login'); do | |
user_info=$(fetch_user_details "$login") | |
name=$(echo "$user_info" | cut -d'|' -f1) | |
count=${recent_commit_counts["$name"]:-0} | |
echo "$count|$login" | |
done | sort -rn | cut -d'|' -f2) | |
developers="" | |
committers_count=0 | |
max_commits=0 | |
top_contributor="" | |
top_contributor_count=0 | |
top_contributor_avatar="" | |
embed_color=$default_color | |
while read -r login; do | |
user_info=$(fetch_user_details "$login") | |
name=$(echo "$user_info" | cut -d'|' -f1) | |
login=$(echo "$user_info" | cut -d'|' -f2) | |
avatar_url=$(echo "$user_info" | cut -d'|' -f3) | |
commit_count=${recent_commit_counts["$name"]:-0} | |
if [ $commit_count -gt 0 ]; then | |
if [ $commit_count -gt $max_commits ]; then | |
max_commits=$commit_count | |
top_contributor="$login" | |
top_contributor_count=1 | |
top_contributor_avatar="$avatar_url" | |
embed_color=$(hex_to_decimal "${contributor_colors[$name]:-$default_color}") | |
elif [ $commit_count -eq $max_commits ]; then | |
top_contributors+=("$login") | |
top_contributor_count=$((top_contributor_count + 1)) | |
embed_color=$default_color | |
fi | |
branch_commit_count=$(git log --author="$login" --author="$name" --oneline | awk '!seen[$0]++' | wc -l) | |
echo "Debug: recent_commit_counts contents:" | |
for key in "${!recent_commit_counts[@]}"; do | |
echo "$key: ${recent_commit_counts[$key]}" | |
done | |
extra_info="${additional_info[$name]}" | |
if [ -n "$extra_info" ]; then | |
extra_info=$(echo "$extra_info" | sed 's/\\n/\n- /g') | |
fi | |
developer_entry="◗ **${name}** ${extra_info} | |
- Github: [${login}](https://github.com/${login}) | |
- Commits: ${branch_commit_count}" | |
if [ -n "$developers" ]; then | |
developers="${developers} | |
${developer_entry}" | |
else | |
developers="${developer_entry}" | |
fi | |
committers_count=$((committers_count + 1)) | |
fi | |
done <<< "$sorted_contributors" | |
if [ $top_contributor_count -eq 1 ]; then | |
thumbnail_url="$top_contributor_avatar" | |
else | |
thumbnail_url="https://i.imgur.com/sP4FR70.png" | |
embed_color=$default_color | |
fi | |
max_length=1000 | |
commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g; s/^/\n/') | |
if [ ${#developers} -gt $max_length ]; then | |
developers="${developers:0:$max_length}... (truncated)" | |
fi | |
if [ ${#commit_messages} -gt $max_length ]; then | |
commit_messages="${commit_messages:0:$max_length}... (truncated)" | |
fi | |
discord_data=$(jq -nc \ | |
--arg field_value "$commit_messages" \ | |
--arg author_value "$developers" \ | |
--arg footer_text "Version $VERSION" \ | |
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \ | |
--arg thumbnail_url "$thumbnail_url" \ | |
--argjson embed_color "$embed_color" \ | |
'{ | |
"content": "<@&1208839371575529572>", | |
"embeds": [ | |
{ | |
"title": "New Alpha-Build dropped", | |
"color": $embed_color, | |
"fields": [ | |
{ | |
"name": "Commits:", | |
"value": $field_value, | |
"inline": true | |
}, | |
{ | |
"name": "Developers:", | |
"value": $author_value, | |
"inline": false | |
} | |
], | |
"footer": { | |
"text": $footer_text | |
}, | |
"timestamp": $timestamp, | |
"thumbnail": { | |
"url": $thumbnail_url | |
} | |
} | |
], | |
"attachments": [] | |
}') | |
echo "Debug: Final Discord payload:" | |
echo "$discord_data" | |
curl -H "Content-Type: application/json" \ | |
-d "$discord_data" \ | |
${{ secrets.DISCORD_WEBHOOK_URL }} | |
if [ "$SKIP_BUILD" != "true" ]; then | |
curl -F "payload_json=${contentbody}" \ | |
-F "Awery_debug=@app/build/outputs/apk/alpha/release/app-alpha-release-signed.apk" \ | |
${{ secrets.DISCORD_WEBHOOK_URL }} | |
else | |
echo "Skipping APK upload to Discord due to SKIP_BUILD being set to true" | |
fi | |
telegram_commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | while read -r line; do | |
message=$(echo "$line" | sed -E 's/● (.*) ~(.*) \[֍\]\((.*)\)/● \1 ~\2 <a href="\3">֍<\/a>/') | |
message=$(echo "$message" | sed -E 's/\[#([0-9]+)\]\((https:\/\/github\.com\/[^)]+)\)/<a href="\2">#\1<\/a>/g') | |
echo "$message" | |
done) | |
telegram_commit_messages="<blockquote>${telegram_commit_messages}</blockquote>" | |
echo "$developers" > dev_info.txt | |
chmod +x workflowscripts/tel_parser.sed | |
./workflowscripts/tel_parser.sed dev_info.txt >> output.txt | |
dev_info_tel=$(< output.txt) | |
telegram_dev_info="<blockquote>${dev_info_tel}</blockquote>" | |
echo "$telegram_dev_info" | |
if [ "$SKIP_BUILD" != "true" ]; then | |
response=$(curl -sS -f -X POST \ | |
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" \ | |
-F "chat_id=-1002206819738" \ | |
-F "message_thread_id=174" \ | |
-F "document=@app/build/outputs/apk/alpha/release/app-alpha-release-signed.apk" \ | |
-F "caption=New Alpha-Build dropped 🔥 | |
Commits: | |
${telegram_commit_messages} | |
Dev: | |
${telegram_dev_info} | |
version: ${VERSION}" \ | |
-F "parse_mode=HTML") | |
else | |
echo "Skipping because skip build set to true" | |
fi | |
env: | |
COMMIT_LOG: ${{ env.COMMIT_LOG }} | |
VERSION: ${{ env.VERSION }} | |
- name: Upload Current SHA as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: last-sha | |
path: last_sha.txt | |
- name: Upload Commit log as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: commit-log | |
path: commit_log.txt |