Skip to content

Commit

Permalink
Merge branch 'dev_brave'
Browse files Browse the repository at this point in the history
  • Loading branch information
asandikci committed Jul 15, 2024
2 parents f222c3d + edbc2b9 commit f7d3e94
Show file tree
Hide file tree
Showing 254 changed files with 21,387 additions and 303 deletions.
66 changes: 66 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# The Last Pipe Bender
> NewPipe + PipePipe + BraveNewPipe + Tubular
# Forks
- [x] NewPipe
- [x] Tubular
- [ ] BraveNewPipe
- [ ] PipePipe

<!-- [Original NewPipe Readme](../README.md)
## About this fork
Due to restrictive project policy, the NewPipeTeam refuses to add platforms that they
find offensive. This fork (BraveNewPipe) will not be as restrictive. As long as the
platforms work in the spirit of free speech, they could be integrated.
Nevertheless, platforms that promote pornography or other degrading things will
__NOT__ be included here.
## APK variants
Currently there are 3 variants:
- `BraveNewPipe_v${TAG}.apk`: version most people want to install.
- `BraveNewPipe_conscrypt_v${TAG}.apk`: like the first but with lastest TLS library aka conscrypt
- `BraveNewPipe_legacy_v${TAG}.apk`: based on same code like above variants but with some checks to
make it work on SDK 19 aka Kitkat. [BraveNewPipeLegacy](https://github.com/bravenewpipe/BraveNewPipeLegacy)
is dumped instead. I hope this approach is more reliable and less a burden to maintain.
## Contribute
This fork will focus only on integrating other platforms. Unrelated patches will
be rejected for now.
Feel free to suggest which alternative platforms should be included. Any contribution
(development/testing/bug report) is greatly appreciated.
## Which additional platforms are supported?
- Bitchute
- Rumble
## Other features not found in NewPipe
- merged NewPipe x Sponsorblock into this fork. [NewPipe x Sponsorblock Readme](../README.md)
- searchfilters: in the action menu of the search page you can now change
the search behavior for the actual search. The supported content/sort
filters depend on the service. More information [PR TeamNewPipe#8837](https://github.com/TeamNewPipe/NewPipe/pull/8837)
## Reporting bugs
Most problems with BraveNewPipe should be reported to the NewPipeExtractor
project, as platform support is developed there.
[Issues](../../../../NewPipeExtractor/issues)
## Building the project
Before building any flavor you should (if you want everything to be named BraveNewPipe) call the
gradle task:
```
gradle bravify
```
For the `brave` and `braveConscrypt` flavor there is nothing special you have to do. But for the
flavor `braveLegacy` you should also call before building:
```
gradle prepareLegacyFlavor
```
It will move some duplicated files from 'main' to a temp directory and alters the new version URL.
Later if you want to restore the files after the Legacy flavor build (in case you want to build
another flavor) run:
```
gradle unPrepareLegacyFlavor
``` -->
132 changes: 132 additions & 0 deletions .github/scripts/brave-new-pipe-releast-actions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#!/usr/bin/env bash
# this script updates the json file with new version that BraveNewPipe is fetching regulary

set -e

if [[ $# -ne 2 ]]; then
echo "This needs a release tag and a apk file:"
echo "e.g. $0 v0.22.0-1.0.5 /path/to/BraveNewPipe_v0.22.0-1.0.5.apk"
exit 1
fi

if [[ -z "$GITHUB_SUPER_TOKEN" ]]; then
echo "This script needs a GitHub personal access token."
exit 1
fi

TAG=$1
APK_FILE=$2

BNP_R_MGR_REPO="bnp-r-mgr"

GITHUB_USER="bravenewpipe"
RELEASE_REPO="NewPipe"
RELEASE_BODY="Apk available at ${GITHUB_USER}/${RELEASE_REPO}@${TAG}](https://github.com/${GITHUB_USER}/${RELEASE_REPO}/releases/tag/${TAG})."

PRERELEASE="false"
if [[ "$TAG" == "latest" ]]; then
PRERELEASE="true"
fi

if [[ "$GITHUB_REPOSITORY" != "${GITHUB_USER}/${RELEASE_REPO}" ]]; then
echo "This mirror script is only meant to be run from ${GITHUB_USER}/${RELEASE_REPO}, not ${GITHUB_REPOSITORY}. Nothing to do here."
exit 0
fi

create_tagged_release() {
local L_REPO=$1
local L_BRANCH=$2
local L_COMMIT_MSG=$3
pushd /tmp/${L_REPO}/

# Set the local git identity
git config user.email "${GITHUB_USER}@users.noreply.github.com"
git config user.name "$GITHUB_USER"

# Obtain the release ID for the previous release of $TAG (if present)
local previous_release_id=$(curl --user ${GITHUB_USER}:${GITHUB_SUPER_TOKEN} --request GET --silent https://api.github.com/repos/${GITHUB_USER}/${L_REPO}/releases/tags/${TAG} | jq '.id')

# Delete the previous release (if present)
if [[ -n "$previous_release_id" ]]; then
echo "Deleting previous release: ${previous_release_id}"
curl \
--user ${GITHUB_USER}:${GITHUB_SUPER_TOKEN} \
--request DELETE \
--silent \
https://api.github.com/repos/${GITHUB_USER}/${L_REPO}/releases/${previous_release_id}
fi

# Delete previous identical tags, if present
git tag -d $TAG || true
git push origin :$TAG || true

# Add all the changed files and push the changes upstream
git add -f .
git commit -m "${L_COMMIT_MSG}" || true
git push -f origin ${L_BRANCH}:${L_BRANCH}
git tag $TAG
git push origin $TAG

# evermind -- we don't want any release entries there # Generate a skeleton release on GitHub
# evermind -- we don't want any release entries there curl \
# evermind -- we don't want any release entries there --user ${GITHUB_USER}:${GITHUB_SUPER_TOKEN} \
# evermind -- we don't want any release entries there --request POST \
# evermind -- we don't want any release entries there --silent \
# evermind -- we don't want any release entries there --data @- \
# evermind -- we don't want any release entries there https://api.github.com/repos/${GITHUB_USER}/${L_REPO}/releases <<END
# evermind -- we don't want any release entries there {
# evermind -- we don't want any release entries there "tag_name": "$TAG",
# evermind -- we don't want any release entries there "name": "Auto-generated release for tag $TAG",
# evermind -- we don't want any release entries there "body": "$RELEASE_BODY",
# evermind -- we don't want any release entries there "draft": false,
# evermind -- we don't want any release entries there "prerelease": $PRERELEASE
# evermind -- we don't want any release entries there }
# evermind -- we don't want any release entries thereEND
popd
}

create_json_file_and_create_tagged_release() {
local L_BRANCH="$1"
local L_URL_STABLE="$2"
local L_URL_ALTERNATIVE="$3"
# checkout json release file repo
rm -rf "/tmp/${BNP_R_MGR_REPO}"
git clone --branch "${L_BRANCH}" "https://${GITHUB_USER}:${GITHUB_SUPER_TOKEN}@github.com/${GITHUB_USER}/${BNP_R_MGR_REPO}.git" /tmp/${BNP_R_MGR_REPO}
# update version{code,name} and download url
cat $JSON_FILE \
| jq '.flavors.github.stable.version_code = '${VERSION_CODE}'' \
| jq '.flavors.github.stable.version = "'${VERSION_NAME}'"' \
| jq '.flavors.github.stable.apk = "'${L_URL_STABLE}'"' \
| jq '( .flavors.github.stable.alternative_apks[] | select(.alternative == "conscrypt") ).url |= "'${L_URL_ALTERNATIVE}'"' \
> $TEMPFILE
mv $TEMPFILE $JSON_FILE

create_tagged_release "$BNP_R_MGR_REPO" "$L_BRANCH" "\"version\": \"$VERSION_NAME\""
}

detect_build_tools_version() {
ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1
}

BUILD_TOOLS_VERSION="${BUILD_TOOLS_VERSION:-$(detect_build_tools_version)}"

AAPT=$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION/aapt

URL_PREFIX="https://github.com/${GITHUB_USER}/${RELEASE_REPO}/releases/download/${TAG}"
URL="$URL_PREFIX/BraveNewPipe_${TAG}.apk"
URL_CONSCRYPT="$URL_PREFIX/BraveNewPipe_conscrypt_${TAG}.apk"
URL_LEGACY="$URL_PREFIX/BraveNewPipe_legacy_${TAG}.apk"
VERSION_NAME=${TAG/v/}
VERSION_CODE="$($AAPT d badging $APK_FILE | grep -Po "(?<=\sversionCode=')([0-9.-]+)")"

TEMPFILE="$(mktemp -p /tmp -t sdflhXXXXXXXXX)"
JSON_FILE=/tmp/${BNP_R_MGR_REPO}/api/data.json

# We have two different json files for now:
# The first is used within the flavors brave and braveConscrypt
# and the second is used in braveLegacy. The json files
# are stored in the same repo but in different branches.
# We call kitkat stuff first as each call tags and delete same exising
# tags before and we want the master branch to have the actual tag.
create_json_file_and_create_tagged_release "kitkat" "$URL_LEGACY" "$URL_LEGACY"
create_json_file_and_create_tagged_release "master" "$URL" "$URL_CONSCRYPT"
100 changes: 99 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,109 @@ jobs:
distribution: "temurin"
cache: 'gradle'

# - name: Rename strings from NewPipe to BraveNewPipe
# run: ./gradlew bravify

# - name: Build brave flavor
# run: ./gradlew assembleBraveDebug

# - name: Build braveConscrypt flavor
# run: ./gradlew assembleBraveConscryptDebug

# - name: Prepare for building braveLegacy flavor
# run: ./gradlew prepareLegacyFlavor

# - name: Build braveLegacy flavor
# run: ./gradlew assembleBraveLegacyDebug

# - name: Unprepare for building braveLegacy flavor
# run: ./gradlew unPrepareLegacyFlavor

- name: Build debug APK and run jvm tests
run: ./gradlew assembleDebug lintDebug testDebugUnitTest --stacktrace -DskipFormatKtlint
run: ./gradlew assembleDebug testDebugUnitTest --stacktrace -DskipFormatKtlint

# lintDebug gives error: ask 'lintDebug' is ambiguous in root project 'LastPipeBender' and its subprojects. Candidates are: 'lintAnalyzeBraveConscryptDebug', 'lintAnalyzeBraveDebug', 'lintAnalyzeBraveLegacyDebug', 'lintAnalyzeSponsorblockDebug', 'lintBraveConscryptDebug', 'lintBraveDebug', 'lintBraveLegacyDebug', 'lintFixBraveConscryptDebug', 'lintFixBraveDebug', 'lintFixBraveLegacyDebug', 'lintFixSponsorblockDebug', 'lintReportBraveConscryptDebug', 'lintReportBraveDebug', 'lintReportBraveLegacyDebug', 'lintReportSponsorblockDebug', 'lintSponsorblockDebug'.
# run: ./gradlew assembleDebug lintDebug testDebugUnitTest --stacktrace -DskipFormatKtlint

- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: app
path: app/build/outputs/apk/debug/*.apk
# path: app/build/outputs/apk/brave*/debug/*.apk

# - name: Build debug APK and run jvm tests
# run: ./gradlew assembleBraveDebug lintBraveDebug testBraveDebugUnitTest --stacktrace -DskipFormatKtlint

# test-android:
# # macos has hardware acceleration. See android-emulator-runner action
# runs-on: macos-latest
# timeout-minutes: 20
# strategy:
# matrix:
# include:
# - api-level: 21
# target: default
# arch: x86
# - api-level: 33
# target: google_apis # emulator API 33 only exists with Google APIs
# arch: x86_64

# permissions:
# contents: read

# steps:
# - uses: actions/checkout@v4

# - name: set up JDK 17
# uses: actions/setup-java@v4
# with:
# java-version: 17
# distribution: "temurin"
# cache: 'gradle'

# - name: Run android tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ matrix.api-level }}
# target: ${{ matrix.target }}
# arch: ${{ matrix.arch }}
# script: ./gradlew connectedCheck --stacktrace

# - name: Upload test report when tests fail # because the printed out stacktrace (console) is too short, see also #7553
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: android-test-report-api${{ matrix.api-level }}
# path: app/build/reports/androidTests/connected/**

# sonar:
# runs-on: ubuntu-latest
#
# permissions:
# contents: read
#
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
#
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# java-version: 17
# distribution: "temurin"
# cache: 'gradle'
#
# - name: Cache SonarCloud packages
# uses: actions/cache@v4
# with:
# path: ~/.sonar/cache
# key: ${{ runner.os }}-sonar
# restore-keys: ${{ runner.os }}-sonar
#
# - name: Build and analyze
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: ./gradlew build sonar --info
Loading

0 comments on commit f7d3e94

Please sign in to comment.