From 9065689d482f1ac1a9fec2373187a526ae7292f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= Date: Fri, 1 Oct 2021 17:41:14 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Installation=20and=20publishing?= =?UTF-8?q?=20magic=20(#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🚀 Add installation info * 📦 Replace jcenter with mavenCentral * ⚙️ Publishing script magic * 📃 Add PUBLISHING.md info * 🚧 Add project status info * Add groovy highlighting * ✉️ Change email to support * Change developer name and version * Readme version changes --- PUBLISHING.md | 60 ++++++++++++++++++++++++++++ README.md | 10 ++++- build.gradle | 7 +++- komposable-architecture/build.gradle | 32 ++++++++++++++- scripts/publish-module.gradle | 55 +++++++++++++++++++++++++ scripts/publish-root.gradle | 36 +++++++++++++++++ 6 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 PUBLISHING.md create mode 100644 scripts/publish-module.gradle create mode 100644 scripts/publish-root.gradle diff --git a/PUBLISHING.md b/PUBLISHING.md new file mode 100644 index 0000000..6f5f1b8 --- /dev/null +++ b/PUBLISHING.md @@ -0,0 +1,60 @@ +## Publishing + +### Credentials + +The library is published to Maven Central with android team's sonatype account + +### GPG Key + +You will need to create a private GPG keyring on your machine, if you don't have one do the +following steps: + +1. Run `gpg --full-generate-key` +1. Choose `RSA and RSA` for the key type +1. Use `4096` for the key size +1. Use `0` for the expiration (never) +1. Use any name, email address, and password + +This creates your key in `~/.gnupg/openpgp-revocs.d/` with `.rev` format. The last 8 characters +before the `.rev` extension are your **Key ID**. + +To export the key, run: + +``` +gpg --export-secret-keys -o $HOME/sonatype.gpg +``` + +Finally upload your key to the keyserver: + +``` +gpg --keyserver keys.openpgp.org --send-keys +``` + +### Local Properties + +Open your `$HOME/.gradle/gradle.properties` file at and fill in the values: + +``` +signing.keyId= +signing.password= +signing.secretKeyRingFile= +mavenCentralRepositoryUsername= +mavenCentralRepositoryUsername= +``` + +### Publish + +To publish, run: + +``` +./gradlew publishReleasePublicationToSonatypeRepository +``` + +### Release + +Follow [the instructions here](https://central.sonatype.org/pages/releasing-the-deployment.html): + +1. Navigate to https://s01.oss.sonatype.org/ and **Log In** +1. On the left side click **Build Promotion** and look for the `com.toggl` repo +1. Click **Close** ... wait a few minutes (you can check status with **Refresh**) +1. Click **Release** diff --git a/README.md b/README.md index 5641309..e8e5c32 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # 🧩 Komposable Architecture [![Build Status](https://app.bitrise.io/app/8fc708d11fa0a5e5/status.svg?token=Q5m1YqGgX4VrIz4V2d0Olg&branch=main)](https://app.bitrise.io/app/8fc708d11fa0a5e5) Kotlin implementation of [Point-Free's The Composable Architecture](https://github.com/pointfreeco/swift-composable-architecture) +## 🚧 Project Status +We've been using Komposable Architecture in production for almost a year now, and we haven't encountered any major issues. However, the API is still subject to change at least until we reach version 1.0. +We definitely want to make the setup more straightforward, and we are thinking about ways to integrate jetpack navigation as well. + ## 💡 Motivations When the time of rewriting Toggl's mobile apps came, we decided that we would take the native approach rather than insisting on using Xamarin We quickly realized, however, that we could still share many things across the app, even if the apps didn't share a common codebase @@ -36,7 +40,11 @@ Next, open Android Studio and open the newly created project folder. You'll want For more examples take a look at [Point-Free's swift samples](https://github.com/pointfreeco/swift-composable-architecture#examples) ## 🚀 Installation -Soon:tm: +The latest release is available on [Maven Central](https://search.maven.org/artifact/com.toggl/komposable-architecture/0.1.1/jar). + +```groovy +implementation 'com.toggl:komposable-architecture:0.1.1' +``` ## © Licence diff --git a/build.gradle b/build.gradle index 3f5bf1f..50cb1c1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ import com.toggl.komposable.buildsrc.Versions buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { classpath Libs.androidGradlePlugin @@ -18,12 +18,15 @@ buildscript { plugins { id 'com.diffplug.spotless' version '5.14.2' id "com.github.ben-manes.versions" version '0.39.0' + id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' } +apply from: "${rootDir}/scripts/publish-root.gradle" + allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/komposable-architecture/build.gradle b/komposable-architecture/build.gradle index 869f9c0..255e8be 100644 --- a/komposable-architecture/build.gradle +++ b/komposable-architecture/build.gradle @@ -1,6 +1,36 @@ import com.toggl.komposable.buildsrc.Libs -apply plugin: 'kotlin' +plugins { + id 'kotlin' +} + +ext { + PUBLISH_GROUP_ID = 'com.toggl' + PUBLISH_VERSION = '0.1.1' + PUBLISH_ARTIFACT_ID = 'komposable-architecture' + PUBLISH_DESCRIPTION = 'Kotlin implementation of Point-Free\'s composable architecture' + PUBLISH_URL = 'https://github.com/toggl/komposable-architecture' + PUBLISH_LICENSE_NAME = 'Apache License' + PUBLISH_LICENSE_URL = + 'https://github.com/toggl/komposable-architecture/blob/main/LICENSE' + PUBLISH_DEVELOPER_ID = 'toggl' + PUBLISH_DEVELOPER_NAME = 'Toggle Track Android Team ♥️' + PUBLISH_DEVELOPER_EMAIL = 'support@toggl.com' + PUBLISH_SCM_CONNECTION = + 'scm:git:github.com/toggl/komposable-architecture.git' + PUBLISH_SCM_DEVELOPER_CONNECTION = + 'scm:git:ssh://github.com/toggl/komposable-architecture.git' + PUBLISH_SCM_URL = + 'https://github.com/toggl/komposable-architecture/tree/main' +} + +apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" + + +java { + withJavadocJar() + withSourcesJar() +} dependencies { implementation Libs.Kotlin.stdlib diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle new file mode 100644 index 0000000..4a8ca00 --- /dev/null +++ b/scripts/publish-module.gradle @@ -0,0 +1,55 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +group = PUBLISH_GROUP_ID +version = PUBLISH_VERSION + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + // The coordinates of the library + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + from components.java + + // Metadata + pom { + name = PUBLISH_ARTIFACT_ID + description = PUBLISH_DESCRIPTION + url = PUBLISH_URL + licenses { + license { + name = PUBLISH_LICENSE_NAME + url = PUBLISH_LICENSE_URL + } + } + developers { + developer { + id = PUBLISH_DEVELOPER_ID + name = PUBLISH_DEVELOPER_NAME + email = PUBLISH_DEVELOPER_EMAIL + } + } + + // Version control info + scm { + connection = PUBLISH_SCM_CONNECTION + developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION + url = PUBLISH_SCM_URL + } + } + } + } + } +} + +ext["signing.keyId"] = rootProject.ext["signing.keyId"] +ext["signing.password"] = rootProject.ext["signing.password"] +ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] + +signing { + sign publishing.publications +} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle new file mode 100644 index 0000000..caec3a3 --- /dev/null +++ b/scripts/publish-root.gradle @@ -0,0 +1,36 @@ +// Create variables with empty default values +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +File secretPropsFile = project.rootProject.file('local.properties') +if (secretPropsFile.exists()) { + // Read local.properties file first if it exists + Properties p = new Properties() + new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } + p.each { name, value -> ext[name] = value } +} else { + // Use system environment variables + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') + ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') + ext["signing.password"] = System.getenv('SIGNING_PASSWORD') + ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') +} + +// Set up Sonatype repository +nexusPublishing { + repositories { + sonatype { + stagingProfileId = sonatypeStagingProfileId + username = ossrhUsername + password = ossrhPassword + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + } + } +}