From 6e3f7949a593a89800c1399c435804b663ec1bd7 Mon Sep 17 00:00:00 2001 From: "kamel.mohamad" Date: Mon, 25 Mar 2024 10:14:37 +0100 Subject: [PATCH 1/6] add publish workflow --- .github/workflows/publish.yml | 9 +++++++++ .idea/misc.xml | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f5e9497 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,9 @@ +name: publish to maven +on: + release: + types: [ created ] +jobs: + publish: + runs-on: ubuntu-latest + steps: + -uses actions/ diff --git a/.idea/misc.xml b/.idea/misc.xml index 0ad17cb..8978d23 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - From 074ec423aa8b735e8827db0c9ac709e8278551c1 Mon Sep 17 00:00:00 2001 From: "kamel.mohamad" Date: Mon, 25 Mar 2024 11:00:46 +0100 Subject: [PATCH 2/6] add gradle-maven-publish plugin --- build.gradle.kts | 1 + gradle/libs.versions.toml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 4348480..9aee112 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,6 +8,7 @@ plugins { alias(libs.plugins.spotless) alias(libs.plugins.detekt) apply false alias(libs.plugins.kotlin.dokka) + alias(libs.plugins.gradle.maven.publish) apply false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7349213..5a06d74 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,6 +10,7 @@ activityCompose = "1.8.2" composeBom = "2024.02.00" spotless="6.25.0" detekt="1.23.5" +gradle-maven-publsih ="0.28.0" [libraries] android_gradle_plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" } @@ -38,6 +39,7 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin" } mosaic-application = { id = "io.monstarlab.mosaic.application", version = "undefined" } mosaic-library = { id = "io.monstarlab.mosaic.library", version = "undefined" } +gradle-maven-publish = {id = "com.vanniktech.maven.publish", version.ref = "gradle-maven-publsih"} From 4079f5f55826ea0eceb1d750d62fa21db16ebd75 Mon Sep 17 00:00:00 2001 From: "kamel.mohamad" Date: Tue, 26 Mar 2024 11:32:59 +0100 Subject: [PATCH 3/6] apply gradle-maven-publish plugin and add pom properties --- gradle.properties | 28 +++++++++++++++++++++++++++- lib/build.gradle.kts | 10 ++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 20e2a01..e7f12ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,30 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # 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 \ No newline at end of file +android.nonTransitiveRClass=true + +# POM values +GROUP=io.monstarlab +POM_ARTIFACT_ID=mosaic +VERSION_NAME=0.0.1-SNAPSHOT + +POM_NAME=Mosaic +POM_DESCRIPTION=A collection of UI components . +POM_INCEPTION_YEAR=2024 +POM_URL=https://github.com/monstar-lab-oss/android-mosaic + +POM_LICENSE_NAME=The Apache Software License, Version 2.0 +POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENSE_DIST=repo + +POM_SCM_URL=scm:git@github.com:monstar-lab-oss/android-mosaic.git +POM_SCM_CONNECTION=scm:git@github.com:monstar-lab-oss/android-mosaic.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:monstar-lab-oss/android-mosaic.git + +POM_DEVELOPER_ID=Monstarlab +POM_DEVELOPER_NAME=Monstarlab +POM_DEVELOPER_EMAIL=sonatype@monstar-lab.com +POM_DEVELOPER_URL=https://github.com/username/ + +mavenCentralUsername=username +mavenCentralPassword=the_password \ No newline at end of file diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 3304c36..8d215ca 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,7 +1,11 @@ +import com.vanniktech.maven.publish.SonatypeHost + plugins { alias(libs.plugins.android.library) alias(libs.plugins.mosaic.library) alias(libs.plugins.kotlin.android) + alias(libs.plugins.gradle.maven.publish) + } android { @@ -20,6 +24,12 @@ android { } } } +mavenPublishing{ + publishToMavenCentral(SonatypeHost.DEFAULT) + signAllPublications() +} + + kotlin { jvmToolchain(17) } From 47870b44c78680e29f7bac8980c948d81143f473 Mon Sep 17 00:00:00 2001 From: "kamel.mohamad" Date: Tue, 26 Mar 2024 13:42:30 +0100 Subject: [PATCH 4/6] add the step to publish to maven --- .github/workflows/publish.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f5e9497..02ac557 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,4 +6,14 @@ jobs: publish: runs-on: ubuntu-latest steps: - -uses actions/ + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Java + uses: actions/setup-java@v1 + with: + java-version: 17 + + - name: publish to maven central + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache + + From 011277ba4c9cf8f87921969ea753abe397b2f0be Mon Sep 17 00:00:00 2001 From: Roman Levinzon Date: Tue, 26 Mar 2024 15:16:16 +0100 Subject: [PATCH 5/6] build: update test module configuration --- .idea/inspectionProfiles/Project_Default.xml | 41 ++++++++++++++++++++ gradle.properties | 14 +++---- lib/build.gradle.kts | 6 ++- lib/gradle.properties | 5 +++ 4 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 lib/gradle.properties diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..44ca2d9 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,41 @@ + + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index e7f12ec..dc72c44 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,17 +23,16 @@ kotlin.code.style=official android.nonTransitiveRClass=true # POM values -GROUP=io.monstarlab -POM_ARTIFACT_ID=mosaic +GROUP=io.monstarlab.mosaic VERSION_NAME=0.0.1-SNAPSHOT POM_NAME=Mosaic -POM_DESCRIPTION=A collection of UI components . +POM_DESCRIPTION=A collection of UI components. POM_INCEPTION_YEAR=2024 POM_URL=https://github.com/monstar-lab-oss/android-mosaic -POM_LICENSE_NAME=The Apache Software License, Version 2.0 -POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENSE_NAME=MIT License +POM_LICENSE_URL=https://raw.githubusercontent.com/monstar-lab-oss/android-mosaic/main/LICENSE POM_LICENSE_DIST=repo POM_SCM_URL=scm:git@github.com:monstar-lab-oss/android-mosaic.git @@ -43,7 +42,4 @@ POM_SCM_DEV_CONNECTION=scm:git@github.com:monstar-lab-oss/android-mosaic.git POM_DEVELOPER_ID=Monstarlab POM_DEVELOPER_NAME=Monstarlab POM_DEVELOPER_EMAIL=sonatype@monstar-lab.com -POM_DEVELOPER_URL=https://github.com/username/ - -mavenCentralUsername=username -mavenCentralPassword=the_password \ No newline at end of file +POM_DEVELOPER_URL=https://github.com/monstar-lab-oss \ No newline at end of file diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 8d215ca..7322eb0 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,3 +1,4 @@ +import com.vanniktech.maven.publish.AndroidSingleVariantLibrary import com.vanniktech.maven.publish.SonatypeHost plugins { @@ -24,8 +25,9 @@ android { } } } -mavenPublishing{ - publishToMavenCentral(SonatypeHost.DEFAULT) +mavenPublishing { + configure(AndroidSingleVariantLibrary("release")) + publishToMavenCentral(SonatypeHost.S01) signAllPublications() } diff --git a/lib/gradle.properties b/lib/gradle.properties new file mode 100644 index 0000000..b3f8c25 --- /dev/null +++ b/lib/gradle.properties @@ -0,0 +1,5 @@ +POM_NAME=Test Library +POM_DESCRIPTION=Test Library +POM_INCEPTION_YEAR=2024 +POM_ARTIFACT_ID=lib +POM_PACKAGING=aar From 553dc79ff418469b9a4ec85d7e813e726c67ebca Mon Sep 17 00:00:00 2001 From: Roman Levinzon Date: Tue, 26 Mar 2024 15:39:49 +0100 Subject: [PATCH 6/6] ci: Add main.yml to facilitate draft releases --- .github/workflows/main.yml | 44 ++++++++++++++++++++++++++++++++++++++ README.md | 5 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1d59681 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,44 @@ +# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps: +# - Remove Old Draft Releases +# - Create New Draft Release +# The workflow is triggered on push to the main branch +# +# GitHub Actions reference: https://help.github.com/en/actions +# + on: + push: + branches: + - main + + jobs: + main: + runs-on: ubuntu-latest + steps: + # Check out current repository + - name: Fetch Sources + uses: actions/checkout@v3 + + # Set up Java environment for the next steps + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: 17 + + # Remove old release drafts by using the curl request for the available releases with a draft flag + - name: Remove Old Release Drafts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh api repos/{owner}/{repo}/releases \ + --jq '.[] | select(.draft == true) | .id' \ + | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} + + # Create a new release draft which is not publicly visible and requires manual acceptance + - name: Create Release Draft + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v${{ needs.build.outputs.version }} \ + --draft \ + --title "v${{ needs.build.outputs.version }}" \ diff --git a/README.md b/README.md index 28b010c..f75d9f9 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ Collection of UI components and utilities for Jetpack Compose - [x] Convention Plugins - [ ] Sonarqube - [x] CI/CD and PR validation, Spotless, Detekt, tests -- [ ] Release management, Maven Publish, Changelog, Tags & Releases +- [ ] Release management, + - [x] Maven Publish + - [ ] Changelog + - [ ] Tags & Releases - [x] Documentation setup