Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Merge branch dev to main #3430

Merged
merged 16 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.{kt,kts}]
ktlint_code_style = intellij_idea
ktlint_standard_no-wildcard-imports = disabled
9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Cache Gradle
uses: burrunan/gradle-cache-action@v1

- name: Build with Gradle
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build clean
Expand All @@ -41,6 +41,13 @@ jobs:
- name: Install dependencies
run: npm install

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
fingerprint: ${{ env.GPG_FINGERPRINT }}

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }}
Expand Down
5 changes: 1 addition & 4 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
{
"assets": [
{
"path": "build/libs/*.jar"
},
{
"path": "patches.json"
"path": "build/libs/revanced-patches*"
}
],
successComment: false
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.0.1-dev.1](https://github.com/ReVanced/revanced-patches-template/compare/v1.0.0...v1.0.1-dev.1) (2024-02-21)


### Bug Fixes

* Compile DEX without debugging information ([73f6506](https://github.com/ReVanced/revanced-patches-template/commit/73f6506bccc01e5622a6e19bedcf6d54d3f701c7))

# 1.0.0 (2024-01-26)


Expand Down
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ For an example repository, see [ReVanced Patches](https://github.com/revanced/re
To start using this template, follow these steps:

1. [Create a new repository using this template](https://github.com/new?template_name=revanced-patches-template&template_owner=ReVanced)
2. Set up the [build.gradle.kts](build.gradle.kts) file (Match the [group of the project](build.gradle.kts#L8), [manifest attributes](build.gradle.kts#L35-L43), and the [POM](build.gradle.kts#L84-L106) that will be published to yours)
3. Update the dependencies in the [libs.versions.toml](gradle/libs.versions.toml) file
4. [Add a secret](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) to your repository named [REPOSITORY_PUSH_ACCESS](.github/workflows/release.yml#L47) containing a GitHub access token with [push access](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/ci-configuration.md#authentication)
5. Set up the [README.md](README.md) file[^1] (e.g, title, description, license, summary of the patches that are included in the repository)
2. Set up the [build.gradle.kts](build.gradle.kts) file (Specifically, the [group of the project](build.gradle.kts#L10), [manifest attributes](build.gradle.kts#L37-L47), and the [POM](build.gradle.kts#L98-L121))
3. Update dependencies in the [libs.versions.toml](gradle/libs.versions.toml) file
4. [Create a pass-phrased GPG master key and subkey](https://mikeross.xyz/create-gpg-key-pair-with-subkeys/)
1. Add the private key as a secret named [GPG_PRIVATE_KEY](.github/workflows/release.yml#L47) to your repository
2. Add the passphrase as a secret named [GPG_PASSPHRASE](.github/workflows/release.yml#L48) to your repository
3. Add the fingerprint of the GPG subkey as a secret named [GPG_FINGERPRINT](.github/workflows/release.yml#L49) to your repository
6. [Create a PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with [push access](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/ci-configuration.md#authentication)
1. Add it as a secret named [REPOSITORY_PUSH_ACCESS](.github/workflows/release.yml#L53) to your repository
7. Set up the [README.md](README.md) file[^1] (e.g, title, description, license, summary of the patches that are included in the repository)

🎉 You are now ready to start creating patches!

Expand All @@ -34,9 +39,21 @@ You can also add the following things to the repository:

In order to develop and release ReVanced Patches using this template, some things need to be considered:

- Development originates in feature branches. Once a feature branch is ready, it is squshed and merged into the `dev` branch
- Development occurs in feature branches. Once a feature branch is ready, it is squshed and merged into the `dev` branch
- The `dev` branch is merged into the `main` branch once it is ready for release
- Semantic versioning is used for versioning ReVanced Patches. ReVanced Patches have a public API for other patches to use
- Semantic commit messages are used for commits
- Commits on the `dev` branch and `main` branch are automatically released via the [release.yml](.github/workflows/release.yml) workflow, which is also responsible for generating the changelog and updating the version of ReVanced Patches. It is triggered by pushing to the `dev` or `main` branch. The workflow uses the `publish` task to publish the release of ReVanced Patches
- In order to build ReVanced Patches, that can be used on Android, the [`generateBundle`](build.gradle.kts#L48-L70) task needs to be run. The [`publish` task depends on the `generateBundle`](build.gradle.kts#L74-L76) task, so it will be run automatically when publishing a release.
- In order to build ReVanced Patches, that can be used on Android, the [`buildDexJar`](build.gradle.kts#L50-L73) task needs to be run. The [`publish` task depends on the `buildDexJar`](build.gradle.kts#L78) task, so it will be run automatically when publishing a release.

## 📚 Everything else

### 🛠️ Building

In order to build ReVanced Patches template, you can follow the [ReVanced documentation](https://github.com/ReVanced/revanced-documentation).

## 📜 Licence

ReVanced Patches template is licensed under the GPLv3 licence. Please see the [licence file](LICENSE) for more information.
[tl;dr](https://www.tldrlegal.com/license/gnu-general-public-license-v3-gpl-3) you may copy, distribute and modify ReVanced Patches template as long as you track changes/dates in source files.
Any modifications to ReVanced Patches template must also be made available under the GPL along with build & install instructions.
6 changes: 6 additions & 0 deletions api/revanced-patches-template.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public final class app/revanced/patches/example/ExamplePatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/example/ExamplePatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

100 changes: 60 additions & 40 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,90 +1,104 @@
import org.gradle.kotlin.dsl.support.listFilesOrdered

plugins {
kotlin("jvm") version "1.9.10"
alias(libs.plugins.kotlin)
alias(libs.plugins.binary.compatibility.validator)
`maven-publish`
signing
}

group = "your.org"
group = "app.revanced"

repositories {
mavenCentral()
mavenLocal()
google()
maven { url = uri("https://jitpack.io") }
maven {
// A repository must be speficied for some reason. "registry" is a dummy.
url = uri("https://maven.pkg.github.com/revanced/registry")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}

dependencies {
implementation(libs.revanced.patcher)
implementation(libs.smali)
// TODO: Required because build fails without it. Find a way to remove this dependency.
implementation(libs.guava)
// Used in JsonGenerator.
implementation(libs.gson)

// A dependency to the Android library unfortunately fails the build, which is why this is required.
compileOnly(project("dummy"))
}

kotlin {
jvmToolchain(11)
}

tasks.withType(Jar::class) {
manifest {
attributes["Name"] = "Your Patches"
attributes["Description"] = "Patches for ReVanced."
attributes["Version"] = version
attributes["Timestamp"] = System.currentTimeMillis().toString()
attributes["Source"] = "[email protected]:you/revanced-patches.git"
attributes["Author"] = "You"
attributes["Contact"] = "[email protected]"
attributes["Origin"] = "https://your.homepage"
attributes["License"] = "GNU General Public License v3.0"
tasks {
withType(Jar::class) {
manifest {
attributes["Name"] = "ReVanced Patches template"
attributes["Description"] = "Patches template for ReVanced."
attributes["Version"] = version
attributes["Timestamp"] = System.currentTimeMillis().toString()
attributes["Source"] = "[email protected]:revanced/revanced-patches-template.git"
attributes["Author"] = "ReVanced"
attributes["Contact"] = "[email protected]"
attributes["Origin"] = "https://revanced.app"
attributes["License"] = "GNU General Public License v3.0"
}
}
}

tasks {
register<DefaultTask>("generateBundle") {
description = "Generate DEX files and add them in the JAR file"
register("buildDexJar") {
description = "Build and add a DEX to the JAR file"
group = "build"

dependsOn(build)

doLast {
val d8 = File(System.getenv("ANDROID_HOME")).resolve("build-tools")
.listFilesOrdered().last().resolve("d8").absolutePath

val artifacts = configurations.archives.get().allArtifacts.files.files.first().absolutePath
val patchesJar = configurations.archives.get().allArtifacts.files.files.first().absolutePath
val workingDirectory = layout.buildDirectory.dir("libs").get().asFile

exec {
workingDir = workingDirectory
commandLine = listOf(d8, artifacts)
commandLine = listOf(d8, "--release", patchesJar)
}

exec {
workingDir = workingDirectory
commandLine = listOf("zip", "-u", artifacts, "classes.dex")
commandLine = listOf("zip", "-u", patchesJar, "classes.dex")
}
}
}

// Required to run tasks because Gradle semantic-release plugin runs the publish task.
// Needed by gradle-semantic-release-plugin.
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
named("publish") {
dependsOn("generateBundle")
publish {
dependsOn("buildDexJar")
}
}

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

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

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

licenses {
license {
Expand All @@ -94,17 +108,23 @@ publishing {
}
developers {
developer {
id = "Your ID"
name = "Your Name"
email = "contact@your.homepage"
id = "ReVanced"
name = "ReVanced"
email = "contact@revanced.app"
}
}
scm {
connection = "scm:git:git://github.com/you/revanced-patches.git"
developerConnection = "scm:git:[email protected]:you/revanced-patches.git"
url = "https://github.com/you/revanced-patches"
connection = "scm:git:git://github.com/revanced/revanced-patches-template.git"
developerConnection = "scm:git:[email protected]:revanced/revanced-patches-template.git"
url = "https://github.com/revanced/revanced-patches-template"
}
}
}
}
}

signing {
useGpgCmd()

sign(publishing.publications["revanced-patches-publication"])
}
9 changes: 0 additions & 9 deletions dummy/build.gradle.kts

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
kotlin.code.style = official
version = 1.0.0
version = 1.0.1-dev.1
14 changes: 8 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[versions]
revanced-patcher = "19.0.0"
smali = "3.0.3"
guava = "32.1.2-jre"
gson = "2.10.1"
revanced-patcher = "19.3.1"
smali = "3.0.4"
binary-compatibility-validator = "0.14.0"
kotlin = "1.9.22"

[libraries]
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
smali = { module = "com.android.tools.smali:smali", version.ref = "smali" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }

[plugins]
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dist
Loading
Loading