Skip to content

Commit

Permalink
feat: prereleases
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko committed Jan 23, 2024
1 parent 607d8b6 commit 9e344a9
Show file tree
Hide file tree
Showing 7 changed files with 7,065 additions and 27 deletions.
40 changes: 18 additions & 22 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
name: Release Build

on:
workflow_dispatch:
push:
tags:
- "v*"
branches:
- main
- dev

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Node modules
uses: actions/cache@v3
with:
path: |
node_modules
key: npm-${{ hashFiles('package-lock.json') }}

- name: Setup semantic-release
run: npm install

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
Expand All @@ -28,24 +38,10 @@ jobs:
- name: Build with Gradle
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew assembleRelease --no-daemon

- name: Sign APK
id: sign_apk
uses: ilharp/sign-android-release@v1
with:
releaseDir: ./app/build/outputs/apk/release/
signingKey: ${{ secrets.SIGNING_KEYSTORE }}
signingKey: "keystore.jks"
keyStorePassword: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
keyAlias: ${{ secrets.SIGNING_KEY_ALIAS }}
keyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}

- name: Add version to APK
run: mv ${{ steps.sign_apk.outputs.signedFile }} revanced-manager-${{ env.RELEASE_VERSION }}.apk

- name: Publish release APK
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: revanced-manager-${{ env.RELEASE_VERSION }}.apk
run: |
echo ${{ secrets.SIGNING_KEYSTORE }} | base64 --decode > keystore.jks
npx semantic-release
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
.externalNativeBuild
.cxx
local.properties

/node_modules
47 changes: 47 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"branches": [
"main",
{
"name": "dev",
"prerelease": true
}
],
"plugins": [
[
"@semantic-release/commit-analyzer", {
"releaseRules": [
{ "type": "build", "scope": "Needs bump", "release": "patch" }
]
}
],
"@semantic-release/changelog",
"@semantic-release/release-notes-generator",
"gradle-semantic-release-plugin",
[
"@semantic-release/git",
{
"assets": [
"gradle.properties"
]
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "app/build/outputs/apk/release/*.apk"
}
],
"successComment": false
}
],
[
"@saithodev/semantic-release-backmerge",
{
"backmergeBranches": [{"from": "main", "to": "dev"}],
"clearWorkspace": true
}
]
]
}
33 changes: 30 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
kotlin("plugin.serialization") version "1.9.10"
}

val (majorVersion, minorVersion, patchVersion, devVersion) = "${project.version}.0".replace("-dev","").split(".")
android {
namespace = "app.revanced.manager"
compileSdk = 34
Expand All @@ -16,14 +17,26 @@ android {
applicationId = "app.revanced.manager"
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "0.0.1"
versionName = project.version.toString()
versionCode = (majorVersion.toInt() * 100000000) + (minorVersion.toInt() * 100000) + (patchVersion.toInt() * 100) + devVersion.toInt()
resourceConfigurations.addAll(listOf(
"en",
))
vectorDrawables.useSupportLibrary = true
}

val hasReleaseConfig = (System.getenv("KEYSTORE_FILE") != null)
signingConfigs {
if (hasReleaseConfig) {
create("release") {
storeFile = file(System.getenv("KEYSTORE_FILE"))
storePassword = System.getenv("KEYSTORE_PASSWORD")
keyAlias = System.getenv("KEY_ALIAS")
keyPassword = System.getenv("KEY_PASSWORD")
}
}
}

buildTypes {
debug {
applicationIdSuffix = ".debug"
Expand All @@ -36,11 +49,19 @@ android {
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}

if (project.hasProperty("signAsDebug")) {
applicationIdSuffix = ".debug"
resValue("string", "app_name", "ReVanced Manager Debug")
signingConfig = signingConfigs.getByName("debug")
} else if (hasReleaseConfig) {
signingConfig = signingConfigs.getByName("release")
}
applicationVariants.all {
this.outputs
.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
.forEach { output ->
output.outputFileName = "revanced-manager-v${project.version}.apk"
}
}
}
}
Expand Down Expand Up @@ -89,6 +110,12 @@ kotlin {
jvmToolchain(17)
}

tasks.register("publish") {
group = "Build"
description = "Assemble main outputs for all the variants."
dependsOn("assembleRelease")
}

dependencies {

// AndroidX Core
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonFinalResIds=false
android.nonFinalResIds=false
version=0.0.1
Loading

0 comments on commit 9e344a9

Please sign in to comment.