build: Sign release artifacts

This commit is contained in:
oSumAtrIX
2024-02-20 05:48:23 +01:00
parent 526d901146
commit cdab0e6a53
3 changed files with 38 additions and 24 deletions

View File

@@ -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 }}

View File

@@ -33,7 +33,7 @@
{
"assets": [
{
"path": "build/libs/*.jar"
"path": "build/libs/revanced-patches*"
},
{
"path": "patches.json"

View File

@@ -4,6 +4,7 @@ plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.binary.compatibility.validator)
`maven-publish`
signing
}
group = "your.org"
@@ -24,49 +25,49 @@ 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"] = "git@github.com:you/revanced-patches.git"
attributes["Author"] = "You"
attributes["Contact"] = "contact@your.homepage"
attributes["Origin"] = "https://your.homepage"
attributes["License"] = "GNU General Public License v3.0"
}
}
tasks {
register<DefaultTask>("generateBundle") {
description = "Generate DEX files and add them in the JAR file"
withType(Jar::class) {
manifest {
attributes["Name"] = "Your Patches"
attributes["Description"] = "Patches for ReVanced."
attributes["Version"] = version
attributes["Timestamp"] = System.currentTimeMillis().toString()
attributes["Source"] = "git@github.com:you/revanced-patches.git"
attributes["Author"] = "You"
attributes["Contact"] = "contact@your.homepage"
attributes["Origin"] = "https://your.homepage"
attributes["License"] = "GNU General Public License v3.0"
}
}
dependsOn(build)
register("buildDexJar") {
description = "Build and add a DEX to the JAR file"
group = "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, 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(build)
dependsOn("buildDexJar")
}
}
@@ -102,3 +103,9 @@ publishing {
}
}
}
signing {
useGpgCmd()
sign(publishing.publications["revanced-patches-publication"])
sign(configurations.archives.get()).first().dependsOn("buildDexJar")
}