Skip to content

Commit

Permalink
perf: Personal Logo && Add upstream sync
Browse files Browse the repository at this point in the history
  • Loading branch information
E85Addict committed Apr 2, 2024
1 parent c1c3154 commit 755a32e
Show file tree
Hide file tree
Showing 48 changed files with 193 additions and 43 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/clean.yml
@@ -0,0 +1,28 @@
name: Delete old workflow runs
on:
workflow_dispatch:
inputs:
days:
description: 'Number of days.'
required: true
default: 0
minimum_runs:
description: 'The minimum runs to keep for each workflow.'
required: true
default: 0
delete_workflow_pattern:
description: 'The name of the workflow. if not set then it will target all workflows.'
required: false

jobs:
del_runs:
runs-on: ubuntu-22.04
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: ${{ github.event.inputs.days }}
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
1 change: 1 addition & 0 deletions .github/workflows/release.yml
@@ -1,6 +1,7 @@
name: Release

on:
workflow_call:
workflow_dispatch:
push:
branches:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/sync_upstream.yml
@@ -0,0 +1,44 @@
name: Sync upstream
on:
workflow_call:
workflow_dispatch:
schedule:
- cron: "0 */8 * * *"

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}

- name: sync
id: sync
shell: bash
run: |
git config --global user.name 'E85Addict'
git config --global user.email '77761710+E85Addict@users.noreply.github.com'
if [[ $(git log | grep Author | head -1) == *"semantic"* ]]; then
git reset --hard HEAD~1
fi
T=$(git tag --sort=creatordate | tail -1)
git remote add upstream https://github.com/revanced/revanced-patches
git tag -d $(git tag -l)
git fetch upstream --tags -f
LatestRemoteTag=$(curl -s https://api.github.com/repos/revanced/revanced-patches/releases/latest | jq -r '.tag_name')
C=$(git rev-list --left-right --count origin/main...remotes/upstream/main | awk '{print$2}')
echo "Ahead $C commits."
if [ "$C" -gt 0 ]; then
echo "Rebasing"
# git push origin --delete $T
git rebase -X ours upstream/main
git push --tags -f
git push origin --delete $LatestRemoteTag
git push -f
else
echo "in sync"
fi
7 changes: 0 additions & 7 deletions .releaserc
Expand Up @@ -41,13 +41,6 @@
],
successComment: false
}
],
[
"@saithodev/semantic-release-backmerge",
{
backmergeBranches: [{"from": "main", "to": "dev"}],
clearWorkspace: true
}
]
]
}
6 changes: 6 additions & 0 deletions api/revanced-patches.api
Expand Up @@ -350,6 +350,12 @@ public final class app/revanced/patches/music/interaction/permanentshuffle/Perma
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/music/layout/branding/CustomBrandingMusicPatch : app/revanced/patcher/patch/ResourcePatch {
public static final field INSTANCE Lapp/revanced/patches/music/layout/branding/CustomBrandingMusicPatch;
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
}

public final class app/revanced/patches/music/layout/compactheader/CompactHeaderPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/music/layout/compactheader/CompactHeaderPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down
34 changes: 1 addition & 33 deletions build.gradle.kts
Expand Up @@ -104,44 +104,12 @@ tasks {

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/revanced/revanced-patches")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
mavenLocal()
}

publications {
create<MavenPublication>("revanced-patches-publication") {
from(components["java"])

pom {
name = "ReVanced Patches"
description = "Patches for ReVanced."
url = "https://revanced.app"

licenses {
license {
name = "GNU General Public License v3.0"
url = "https://www.gnu.org/licenses/gpl-3.0.en.html"
}
}
developers {
developer {
id = "ReVanced"
name = "ReVanced"
email = "contact@revanced.app"
}
}
scm {
connection = "scm:git:git://github.com/revanced/revanced-patches.git"
developerConnection = "scm:git:git@github.com:revanced/revanced-patches.git"
url = "https://github.com/revanced/revanced-patches"
}
}
}
}
}
Expand Down
@@ -0,0 +1,110 @@
package app.revanced.patches.music.layout.branding

import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
import app.revanced.util.ResourceGroup
import app.revanced.util.Utils.trimIndentMultiline
import app.revanced.util.copyResources
import java.io.File
import java.nio.file.Files

@Patch(
name = "Custom Music branding",
description = "Changes the app icon and name to your choice (defaults to YT Music and the ReVanced logo).",
compatiblePackages = [
CompatiblePackage("com.google.android.apps.youtube.music")
],
use = true
)
@Suppress("unused")
object CustomBrandingMusicPatch : ResourcePatch() {
private const val REVANCED_ICON = "ReVanced*Logo" // Can never be a valid path.
private const val APP_NAME = "YT Music"

private val iconResourceFileNames = arrayOf(
"adaptiveproduct_youtube_music_background_color_108",
"adaptiveproduct_youtube_music_foreground_color_108",
"ic_launcher",
"ic_launcher_round"
).map { "$it.png" }.toTypedArray()

private val mipmapDirectories = arrayOf(
"xxxhdpi",
"xxhdpi",
"xhdpi",
"hdpi",
"mdpi"
).map { "mipmap-$it" }

private var appName by stringPatchOption(
key = "appName",
default = APP_NAME,
values = mapOf(
"YouTube Music ReVanced" to APP_NAME,
"YTM ReVanced" to "YTM ReVanced",
"YTM" to "YTM",
"YouTube Music" to "YouTube Music",
),
title = "App name",
description = "The name of the app."
)

private var icon by stringPatchOption(
key = "iconPath",
default = REVANCED_ICON,
values = mapOf("ReVanced Logo" to REVANCED_ICON),
title = "App icon",
description = """
The path to a folder containing the following folders:
${mipmapDirectories.joinToString("\n") { "- $it" }}
Each of these folders has to have the following files:
${iconResourceFileNames.joinToString("\n") { "- $it" }}
""".trimIndentMultiline()
)

override fun execute(context: ResourceContext) {
icon?.let { icon ->
// Change the app icon.
mipmapDirectories.map { directory ->
ResourceGroup(
directory, *iconResourceFileNames
)
}.let { resourceGroups ->
if (icon != REVANCED_ICON) {
val path = File(icon)
val resourceDirectory = context["res"]

resourceGroups.forEach { group ->
val fromDirectory = path.resolve(group.resourceDirectoryName)
val toDirectory = resourceDirectory.resolve(group.resourceDirectoryName)

group.resources.forEach { iconFileName ->
Files.write(
toDirectory.resolve(iconFileName).toPath(),
fromDirectory.resolve(iconFileName).readBytes()
)
}
}
} else resourceGroups.forEach { context.copyResources("branding/music", it) }
}
}

appName?.let { name ->
// Change the app name.
val manifest = context["AndroidManifest.xml"]
manifest.writeText(
manifest.readText()
.replace(
"android:label=\"@string/application_name",
"android:label=\"$name"
)
)
}
}
}
Expand Up @@ -17,12 +17,12 @@ import java.nio.file.Files
compatiblePackages = [
CompatiblePackage("com.google.android.youtube"),
],
use = false,
use = true,
)
@Suppress("unused")
object CustomBrandingPatch : ResourcePatch() {
private const val REVANCED_ICON = "ReVanced*Logo" // Can never be a valid path.
private const val APP_NAME = "YouTube ReVanced"
private const val APP_NAME = "YouTube"

private val iconResourceFileNames = arrayOf(
"adaptiveproduct_youtube_background_color_108",
Expand Down Expand Up @@ -95,7 +95,7 @@ object CustomBrandingPatch : ResourcePatch() {
}
}
} else {
resourceGroups.forEach { context.copyResources("custom-branding", it) }
resourceGroups.forEach { context.copyResources("branding/youtube", it) }
}
}
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 755a32e

Please sign in to comment.