[skip ci] feat(github): create releases on forks (#449)
This commit is contained in:
parent
79742f415b
commit
09c5d9ce91
1 changed files with 55 additions and 13 deletions
66
.github/workflows/beta.yml
vendored
66
.github/workflows/beta.yml
vendored
|
@ -2,14 +2,20 @@ name: Build APK and Notify Discord
|
|||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
branches-ignore:
|
||||
- main
|
||||
- l10n_dev_crowdin
|
||||
- custom-download-location
|
||||
paths-ignore:
|
||||
- '**/README.md'
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
CI: true
|
||||
SKIP_BUILD: false
|
||||
|
@ -50,6 +56,10 @@ jobs:
|
|||
# Debugging: Print the variable to check its content
|
||||
echo "$COMMIT_LOGS"
|
||||
echo "$COMMIT_LOGS" > commit_log.txt
|
||||
# Extract branch name from github.ref
|
||||
BRANCH=${{ github.ref }}
|
||||
BRANCH=${BRANCH#refs/heads/}
|
||||
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
|
||||
shell: /usr/bin/bash -e {0}
|
||||
env:
|
||||
CI: true
|
||||
|
@ -99,7 +109,7 @@ jobs:
|
|||
fi
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
if: ${{ env.SKIP_BUILD != 'true' }}
|
||||
if: ${{ env.SKIP_BUILD != 'true' && github.repository == 'rebelonion/Dantotsu' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Dantotsu
|
||||
|
@ -107,30 +117,46 @@ jobs:
|
|||
compression-level: 9
|
||||
path: "app/build/outputs/apk/google/alpha/app-google-alpha.apk"
|
||||
|
||||
- name: Create GitHub Release
|
||||
if: ${{ env.SKIP_BUILD != 'true' && github.repository != 'rebelonion/Dantotsu' }}
|
||||
uses: softprops/action-gh-release@v2.0.6
|
||||
with:
|
||||
files: app/build/outputs/apk/google/alpha/app-google-alpha.apk
|
||||
name: ${{ env.BRANCH }} build ${{ env.VERSION }}
|
||||
tag_name: v${{ env.VERSION }}
|
||||
body: |
|
||||
New Pretester Build ${{ env.VERSION }} released on branch "${{ env.BRANCH }}" :)
|
||||
|
||||
Commits:
|
||||
${{ env.COMMIT_LOG }}
|
||||
prerelease: false
|
||||
make_latest: true
|
||||
generate_release_notes: true
|
||||
fail_on_unmatched_files: true
|
||||
|
||||
- name: Upload APK to Discord and Telegram
|
||||
shell: bash
|
||||
run: |
|
||||
# Prepare Discord embed
|
||||
fetch_user_details() {
|
||||
local login=$1
|
||||
user_details=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
"https://api.github.com/users/$login")
|
||||
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"
|
||||
}
|
||||
|
||||
# Additional information for the goats
|
||||
# Additional information for the goatss
|
||||
declare -A additional_info
|
||||
additional_info["ibo"]="\n Discord: <@951737931159187457>\n AniList: [takarealist112](<https://anilist.co/user/takarealist112/>)"
|
||||
additional_info["aayush262"]="\n Discord: <@918825160654598224>\n AniList: [aayush262](<https://anilist.co/user/aayush262/>)"
|
||||
additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion](<https://anilist.co/user/rebelonion/>)\n PornHub: [rebelonion](<https://www.cornhub.com/model/rebelonion>)"
|
||||
additional_info["ibo"]="\n Discord: <@951737931159187457>\n AniList: [takarealist112](<https://anilist.co/user/5790266/>)"
|
||||
additional_info["aayush262"]="\n Discord: <@918825160654598224>\n AniList: [aayush262](<https://anilist.co/user/5144645/>)"
|
||||
additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion](<https://anilist.co/user/6077251/>)\n PornHub: [rebelonion](<https://www.cornhub.com/model/rebelonion>)"
|
||||
|
||||
# Decimal color codes for contributors
|
||||
declare -A contributor_colors
|
||||
default_color="#ff25f9"
|
||||
contributor_colors["ibo"]="#ff7500"
|
||||
contributor_colors["ibo"]="#ff9b46"
|
||||
contributor_colors["aayush262"]="#5d689d"
|
||||
contributor_colors["Sadwhy"]="#ff7e95"
|
||||
contributor_colors["rebelonion"]="#d4e5ed"
|
||||
|
@ -138,12 +164,18 @@ jobs:
|
|||
|
||||
# Count recent commits and create an associative array
|
||||
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"
|
||||
# Fetch contributors from GitHub
|
||||
contributors=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
"https://api.github.com/repos/${{ github.repository }}/contributors")
|
||||
contributors=$(curl -s "https://api.github.com/repos/${{ github.repository }}/contributors")
|
||||
echo "Debug: Contributors response:"
|
||||
echo "$contributors"
|
||||
|
||||
# Create a sorted list of contributors based on recent commit counts
|
||||
sorted_contributors=$(for login in $(echo "$contributors" | jq -r '.[].login'); do
|
||||
|
@ -184,10 +216,18 @@ jobs:
|
|||
top_contributor_count=$((top_contributor_count + 1))
|
||||
embed_color=$default_color
|
||||
fi
|
||||
echo "Debug top contributors:"
|
||||
echo "$top_contributors"
|
||||
|
||||
# Get commit count for this contributor on the dev branch
|
||||
branch_commit_count=$(git rev-list --count dev --author="$login")
|
||||
|
||||
# Debug: Print recent_commit_counts
|
||||
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')
|
||||
|
@ -264,6 +304,8 @@ jobs:
|
|||
],
|
||||
"attachments": []
|
||||
}')
|
||||
echo "Debug: Final Discord payload:"
|
||||
echo "$discord_data"
|
||||
|
||||
# Send Discord message
|
||||
curl -H "Content-Type: application/json" \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue