Skip to content

Update NewPipeExtractor #125

Update NewPipeExtractor

Update NewPipeExtractor #125

name: Update NewPipeExtractor
on:
schedule:
# Every day at 06:00 UTC
- cron: "0 6 * * *"
workflow_dispatch: # allow manual trigger
concurrency:
group: update-newpipe
cancel-in-progress: true
permissions:
contents: write
jobs:
check-update:
runs-on: ubuntu-latest
outputs:
updated: ${{ steps.check.outputs.updated }}
current: ${{ steps.check.outputs.current }}
latest: ${{ steps.check.outputs.latest }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: gradle/libs.versions.toml
sparse-checkout-cone-mode: false
- name: Check for NewPipeExtractor update
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CURRENT=$(grep '^newpipeextractor = "' gradle/libs.versions.toml \
| sed 's/.*= *"\(.*\)"/\1/')
echo "current=$CURRENT"
LATEST=$(curl -sf \
-H "Authorization: Bearer $GH_TOKEN" \
https://api.github.com/repos/TeamNewPipe/NewPipeExtractor/releases/latest \
| jq -r '.tag_name')
echo "latest=$LATEST"
if [ "$LATEST" = "null" ] || [ -z "$LATEST" ]; then
echo "Failed to fetch latest release tag"
exit 1
fi
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "latest=$LATEST" >> "$GITHUB_OUTPUT"
if [ "$CURRENT" = "$LATEST" ]; then
echo "Already up to date ($CURRENT)"
echo "updated=false" >> "$GITHUB_OUTPUT"
else
echo "Update available: $CURRENT -> $LATEST"
echo "updated=true" >> "$GITHUB_OUTPUT"
fi
update-and-build:
needs: check-update
if: needs.check-update.outputs.updated == 'true'
runs-on: ubuntu-latest
env:
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASS: ${{ secrets.KEY_PASS }}
STORE_PASS: ${{ secrets.STORE_PASS }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update version catalog
run: |
LATEST="${{ needs.check-update.outputs.latest }}"
sed -i "s/^newpipeextractor = \".*\"/newpipeextractor = \"${LATEST}\"/" \
gradle/libs.versions.toml
grep '^newpipeextractor = "' gradle/libs.versions.toml
- name: Commit and push
run: |
CURRENT="${{ needs.check-update.outputs.current }}"
LATEST="${{ needs.check-update.outputs.latest }}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add gradle/libs.versions.toml
git commit -m "build(deps): bump NewPipeExtractor from $CURRENT to $LATEST"
git push
# Capture the actual new commit SHA (GITHUB_SHA is stale after push)
echo "BUILD_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
echo "SHORT_SHA=$(git rev-parse --short=8 HEAD)" >> "$GITHUB_ENV"
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25
cache: gradle
- name: Telegram — build started
continue-on-error: true
env:
TG_BOT_KEY: ${{ secrets.TG_BOT_KEY }}
run: |
curl -sf -X POST "https://api.telegram.org/bot${TG_BOT_KEY}/sendMessage" \
-d chat_id="-1001415196670" \
-d disable_web_page_preview=true \
-d parse_mode=markdown \
-d text="🤖 \`building with HEAD as\` [${SHORT_SHA}](https://github.com/${{ github.repository }}/commit/${BUILD_SHA}) 🤖"
- name: Inject API keys
env:
RAPID_KEY: ${{ secrets.RAPID_KEY }}
run: |
CONSTANTS="app/src/main/kotlin/io/github/uditkarode/able/utils/Constants.kt"
sed -i "s/INSERT_RAPID_KEY/${RAPID_KEY}/" "$CONSTANTS"
- name: Fetch signing keystore
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
git clone --depth 1 \
"https://x-access-token:${TOKEN}@github.com/uditkarode/AbleMusicKeystore.git" \
_keystore
mv _keystore/release.keystore app/
rm -rf _keystore
- name: Build release APK
run: ./gradlew :app:assembleRelease --configuration-cache --parallel
- name: Telegram — upload APKs
continue-on-error: true
env:
TG_BOT_KEY: ${{ secrets.TG_BOT_KEY }}
run: |
for APK in app/build/outputs/apk/release/*.apk; do
ABI=$(basename "$APK" .apk | sed 's/app-//' | sed 's/-release//' | sed 's/-unsigned//')
RENAMED="app/build/outputs/apk/release/AbleMusic-${ABI}-${SHORT_SHA}.apk"
mv "$APK" "$RENAMED"
curl -sf -F document=@"${RENAMED}" \
"https://api.telegram.org/bot${TG_BOT_KEY}/sendDocument" \
-F chat_id="-1001415196670" \
-F parse_mode=Markdown \
-F caption="\`${SHORT_SHA} — ${ABI}\`"
done
- name: Upload APK artifacts
uses: actions/upload-artifact@v4
with:
name: AbleMusic-${{ env.BUILD_SHA }}
path: app/build/outputs/apk/release/*.apk
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="build-${SHORT_SHA}"
COMMIT_MSG=$(git log -1 --pretty=%s)
NOTES=$(printf 'Automated release from commit [`%s`](https://github.com/${{ github.repository }}/commit/%s)\n\n**%s**' \
"$SHORT_SHA" "$BUILD_SHA" "$COMMIT_MSG")
gh release create "$TAG" \
--target "$BUILD_SHA" \
--title "Build ${SHORT_SHA}" \
--notes "$NOTES" \
--latest \
app/build/outputs/apk/release/*.apk
- name: Telegram — build finished
continue-on-error: true
env:
TG_BOT_KEY: ${{ secrets.TG_BOT_KEY }}
run: |
curl -sf -X POST "https://api.telegram.org/bot${TG_BOT_KEY}/sendMessage" \
-d chat_id="-1001415196670" \
-d disable_web_page_preview=true \
-d parse_mode=markdown \
-d text="🤖 \`workflow for\` [${SHORT_SHA}](https://github.com/${{ github.repository }}/commit/${BUILD_SHA}) \`finished\` 🤖"
curl -sf -X POST "https://api.telegram.org/bot${TG_BOT_KEY}/sendSticker" \
-d chat_id="-1001415196670" \
-d sticker="CAACAgUAAxkBAAJc416cRVy18acXP6HgtZSnxuuoJi01AAK9AAMtO2YjehthhceJ__sYBA"