Skip to content

Commit

Permalink
fdroid publish fix
Browse files Browse the repository at this point in the history
fdroid publish fix

fdroid publish fix
  • Loading branch information
Wavesonics committed Jun 19, 2024
1 parent 1d627e1 commit 90e329b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
RELEASE_BUILD: true

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v4
Expand Down Expand Up @@ -57,7 +58,7 @@ jobs:

- name: Publish F-Droid
run: |
gradlew publishFdroid
./gradlew publishFdroid
- name: Distribute app to Production track 🚀
run: bundle exec fastlane release
Expand Down
54 changes: 46 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.darkrockstudios.build.configureRelease
import com.darkrockstudios.build.parseSemVar
import com.darkrockstudios.build.writeChangelogMarkdown
import com.darkrockstudios.build.writeSemvar

Expand Down Expand Up @@ -59,7 +60,8 @@ kover {

tasks.register("prepareForRelease") {
doLast {
val releaseInfo = configureRelease(libs.versions.app.get()) ?: error("Failed to configure new release")
val releaseInfo =
configureRelease(libs.versions.app.get()) ?: error("Failed to configure new release")

println("Creating new release")
val versionCode = releaseInfo.semVar.createVersionCode(true, 0)
Expand All @@ -78,7 +80,8 @@ tasks.register("prepareForRelease") {

// Write the Fastlane changelog file
val rootDir: File = project.rootDir
val changelogsPath = "fastlane/metadata/android/en-US/changelogs".replace("/", File.separator)
val changelogsPath =
"fastlane/metadata/android/en-US/changelogs".replace("/", File.separator)
val changeLogsDir = rootDir.resolve(changelogsPath)
val changeLogFile = File(changeLogsDir, "$versionCode.txt")
changeLogFile.writeText(truncatedChangelog)
Expand All @@ -92,27 +95,62 @@ tasks.register("prepareForRelease") {
exec { commandLine = listOf("git", "add", changeLogFile.absolutePath) }
exec { commandLine = listOf("git", "add", versionsFile.absolutePath) }
exec { commandLine = listOf("git", "add", globalChangelogFile.absolutePath) }
exec { commandLine = listOf("git", "commit", "-m", "Prepared for release: v${releaseInfo.semVar}") }
exec {
commandLine =
listOf("git", "commit", "-m", "Prepared for release: v${releaseInfo.semVar}")
}

// Merge develop into release
exec { commandLine = listOf("git", "checkout", "release") }
exec { commandLine = listOf("git", "merge", "develop") }

// Create the release tag
exec { commandLine = listOf("git", "tag", "-a", "v${releaseInfo.semVar}", "-m", releaseInfo.changeLog) }
exec {
commandLine =
listOf("git", "tag", "-a", "v${releaseInfo.semVar}", "-m", releaseInfo.changeLog)
}

// Push and begin the release process
exec { commandLine = listOf("git", "push", "origin", "--all") }
exec { commandLine = listOf("git", "push", "origin", "--tags") }

// Leave the repo back on develop
exec { commandLine = listOf("git", "checkout", "develop") }
}
}

tasks.register("publishFdroid") {
doLast {
val releaseInfo = configureRelease(libs.versions.app.get()) ?: error("Failed to configure fdroid release")
val versionCode = releaseInfo.semVar.createVersionCode(true, 0)
val semvarStr = libs.versions.app.get()
val curSemVar = parseSemVar(semvarStr)
val versionCode = curSemVar.createVersionCode(true, 0)
val tag = "fdroid-${versionCode}"

exec {
commandLine = listOf(
"git",
"config",
"--global",
"user.email",
"github-actions[bot]@users.noreply.github.com"
)
}
exec {
commandLine = listOf("git", "config", "--global", "user.name", "github-actions[bot]")
}

exec { commandLine = listOf("git", "fetch", "origin", "release") }
exec { commandLine = listOf("git", "checkout", "release") }
exec { commandLine = listOf("git", "tag", "-a", "fdroid-${versionCode}") }
exec { commandLine = listOf("git", "push", "origin", "--tags") }
exec {
commandLine = listOf(
"git",
"tag",
"-a",
tag,
"-m",
"FDroid release tag for $semvarStr"
)
}
exec { commandLine = listOf("git", "push", "origin", "tag", tag) }
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/versioncode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ data class SemVar(
}
}

internal fun parseSemVar(semVarStr: String): SemVar {
fun parseSemVar(semVarStr: String): SemVar {
val semVarPattern = Pattern.compile("""^(\d+)\.(\d+)\.(\d+)$""")
val matcher = semVarPattern.matcher(semVarStr)

Expand Down

0 comments on commit 90e329b

Please sign in to comment.