Skip to content
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
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish

on:
release:
types: [ created ]

env:
JAVA_VERSION: 17
JAVA_DISTRO: 'temurin'

jobs:
publish:
name: Publish to GitHub Packages
runs-on: macos-latest
permissions:
contents: read
packages: write

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

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v6

- name: Set up JDK 17
uses: actions/setup-java@v6
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}

- name: Set up gradle
uses: gradle/actions/setup-gradle@v6

- name: Publish to GitHub Packages
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository --no-configuration-cache
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ github.event.release.tag_name }}

- name: Upload build reports
if: failure()
uses: actions/upload-artifact@v7
with:
name: build-reports
path: '**/build/reports/'
retention-days: 7
5 changes: 5 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies {
compileOnly(libs.androidx.gradle)
compileOnly(libs.kotlin.gradle)
compileOnly(libs.compose.compiler.gradle)
compileOnly(libs.vanniktech.maven.publish.gradle)
implementation(libs.spotless.gradle)
}

Expand Down Expand Up @@ -35,5 +36,9 @@ gradlePlugin {
id = "cfw.sample.common.deps"
implementationClass = "SampleCommonDepsConventionPlugin"
}
register("mavenPublish") {
id = "cfw.maven.publish"
implementationClass = "MavenPublishConventionPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import cfw.buildlogic.configureMavenPublish
import org.gradle.api.Plugin
import org.gradle.api.Project

@Suppress("unused")
class MavenPublishConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.vanniktech.maven.publish")

configureMavenPublish()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package cfw.buildlogic

import com.vanniktech.maven.publish.MavenPublishBaseExtension
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.kotlin.dsl.configure

internal fun Project.configureMavenPublish() {
version = providers.environmentVariable("RELEASE_TAG")
.map { it.removePrefix("v") }
.getOrElse("1.0.0")

extensions.configure<PublishingExtension> {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ArthurKun21/compose-overlay-window")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

extensions.configure<MavenPublishBaseExtension> {
pom {
url.set("https://github.com/ArthurKun21/compose-overlay-window")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

developers {
developer {
id.set("ArthurKun21")
name.set("Arthur")
email.set("16458204+ArthurKun21@users.noreply.github.com")
}
}

scm {
connection.set("scm:git:git://github.com/ArthurKun21/compose-overlay-window.git")
developerConnection.set("scm:git:ssh://github.com/ArthurKun21/compose-overlay-window.git")
url.set("https://github.com/ArthurKun21/compose-overlay-window")
}
}
}
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ plugins {
alias(libs.plugins.spotless) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.hilt.android) apply false
alias(libs.plugins.vanniktech.maven.publish) apply false
}
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ datastore = "1.2.1"
spotless = "8.10.2"
ktlint-core = "1.8.0"

vanniktech-maven-publish = "0.37.0"

[libraries]
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "android-core-ktx" }
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
Expand Down Expand Up @@ -72,6 +74,8 @@ compose-compiler-gradle = { module = "org.jetbrains.kotlin:compose-compiler-grad

spotless-gradle = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless" }

vanniktech-maven-publish-gradle = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "vanniktech-maven-publish" }

[plugins]
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
agp = { id = "com.android.application", version.ref = "agp" }
Expand All @@ -82,6 +86,7 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }

spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech-maven-publish" }

[bundles]
datastore = ["datastore", "datastore-preferences"]
Expand Down
29 changes: 11 additions & 18 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
`maven-publish`
id("cfw.library")
id("cfw.library.tests")
id("cfw.maven.publish")
}

android {
Expand All @@ -16,16 +16,8 @@ android {
)
}
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

version = 1.0

kotlin {
explicitApi()

Expand All @@ -51,14 +43,15 @@ dependencies {
implementation(libs.google.material)
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.only52607"
artifactId = "compose-floating-window"
afterEvaluate {
from(components["release"])
}
}
mavenPublishing {
coordinates(
groupId = "com.github.ArthurKun21",
artifactId = "compose-floating-window",
version = version.toString(),
)

pom {
name.set("compose-floating-window")
description.set("Global Floating Window Framework based on Jetpack Compose")
}
}