From cdab0e6a53dd9395822172c4162af10e1130f092 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 20 Feb 2024 05:48:23 +0100 Subject: [PATCH] build: Sign release artifacts --- .github/workflows/release.yml | 7 +++++ .releaserc | 2 +- build.gradle.kts | 53 ++++++++++++++++++++--------------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 970ac34d8..9c384f380 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/.releaserc b/.releaserc index 0e4fa8b8a..6193511b8 100644 --- a/.releaserc +++ b/.releaserc @@ -33,7 +33,7 @@ { "assets": [ { - "path": "build/libs/*.jar" + "path": "build/libs/revanced-patches*" }, { "path": "patches.json" diff --git a/build.gradle.kts b/build.gradle.kts index 1db66cd75..d63c72177 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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("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") +}