From d9d4bc3f70a7df35093f3001c84000a77c341c4f Mon Sep 17 00:00:00 2001 From: Justin Kleiber Date: Sat, 30 Nov 2024 16:42:50 -0600 Subject: [PATCH 1/6] Actually gets deploying to central portal to work locally --- .gitignore | 6 ++- README.md | 52 ++++++++++++++++++++++++ build.gradle | 75 +++-------------------------------- controls/build.gradle | 62 +++++++++++++++++++++++++---- geometry/build.gradle | 61 +++++++++++++++++++++++++--- math/build.gradle | 62 +++++++++++++++++++++++++---- monitors/build.gradle | 62 +++++++++++++++++++++++++---- parameter_tools/build.gradle | 61 +++++++++++++++++++++++++--- vision/build.gradle | 55 +++++++++++++++++++++++++ wpilib_interface/build.gradle | 56 +++++++++++++++++++++++++- 10 files changed, 447 insertions(+), 105 deletions(-) create mode 100644 README.md diff --git a/.gitignore b/.gitignore index f9f5c3f..2d946d4 100644 --- a/.gitignore +++ b/.gitignore @@ -165,4 +165,8 @@ build # Ignore auto-generated WPILib stuff. wpi_interface/src/main/java/frc/robot/BuildConstants.java -**/BuildConstants.java \ No newline at end of file +**/BuildConstants.java + +# Ignore gpg keys +gpg.key +gpg.pub diff --git a/README.md b/README.md new file mode 100644 index 0000000..aec45a6 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# coppercore + + +## Maintaining Maven Central Publishing + +In order to publish on Maven Central, multiple secret keys must be maintained. The GPG key and the Sonatype token are independent though, and can be regenerated as needed without updating the other one. + +**Note:** When creating a new GPG key, you must also publish the public key. See the section below on generating the GPG key for details. + +The following secret keys are required to be configured in this repository's Github secrets in order to publish it to maven central: +- `ORG_GRADLE_PROJECT_mavenCentralUsername`: the username **generated from the Sonatype Central Portal** for the current user token, not to be confused with the username of the account. +- `ORG_GRADLE_PROJECT_mavenCentralPassword`: the password generated when the user token is generated. This is linked with the username above and can be generated from the Sonatype Central Portal. +- `ORG_GRADLE_PROJECT_signingInMemoryKey`: The private GPG signing key used for signing the package. Generating this is explained below. +- `ORG_GRADLE_PROJECT_signingInMemoryKeyPassword`: The password generated during the GPG key generation, if one is chosen. + +It also works to include these as organization secrets in GitHub. + +To temporarily set any of these variables locally for testing, you can do the following in VSCode powershell terminals: +``` +$env.ENV_VARIABLE_NAME = "environment-variable-value" +``` + +### Generating a GPG key + +To generate the GPG key, first generate a key locally: +``` +gpg --full-generate-key +``` + +Pick RSA (default option) and then use a key with 4096 bits. The rest of the process is straightforward, just use the team email account (401frc@gmail.com) and your name for the user. + +List the keys using this command and find the one you just generated: +``` +gpg --list-secret-keys +``` + +Then to get the private key in plaintext and save it to a file called `gpg.key` (for easier copy and memory of what the key is), run the following: +``` +gpg --export-secret-keys --armor KEY-ID | grep -v '\-\-' | grep -v '^=.' | tr -d '\n' > gpg.key +``` +where `KEY-ID` is the long string of numbers and letters in the `sec` section of the key that you just generated. + +The long string of the plaintext key is what needs to be set for the `ORG_GRADLE_PROJECT_signingInMemoryKey` environment variable. **This is the private key, so DO NOT share it with anyone or check it into the repository!!!** + +**Note:** if you configure a passphrase for your key, you'll need to add that to a `ORG_GRADLE_PROJECT_signingInMemoryKeyPassword` environment variable. + +Finally, you need to publish the **public** key so users can actually verify the signature. Do that with the following command: +``` +gpg --keyserver keyserver.ubuntu.com KEY-ID +``` + +More information on generating GPG keys can be found [on the Sonatype docs](https://central.sonatype.org/publish/requirements/gpg/) or on the [GitHub docs](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key). \ No newline at end of file diff --git a/build.gradle b/build.gradle index 5520d0b..0de8f12 100644 --- a/build.gradle +++ b/build.gradle @@ -1,77 +1,12 @@ +plugins { + id "com.vanniktech.maven.publish" version "0.30.0" apply false +} + subprojects { apply plugin: 'java' - apply plugin: 'maven-publish' - apply plugin: 'signing' - + group = 'io.github.team401.coppercore' - java { - withJavadocJar() - withSourcesJar() - } - - publishing { - publications { - mavenJava(MavenPublication) { - from components.java - groupId project.group - artifactId project.name - version project.version - versionMapping { - usage('java-api') { - fromResolutionOf('runtimeClasspath') - } - usage('java-runtime') { - fromResolutionResult() - } - } - pom { - name = project.name - description = 'Core library for FRC Team 401' - url = 'http://www.github.com/team401/coppercore' - licenses { - license { - name = 'MIT License' - url = 'https://opensource.org/license/mit' - } - } - developers { - developer { - id = 'aidnem' - name = 'Aiden Mathai' - } - developer { - id = 'linglejack' - name = 'Jack Lingle' - } - developer { - id = 'avidraccoon' - name = 'Nathan Smith' - } - developer { - id = 'minh' - name = 'Minh Ngyuen' - } - } - } - } - } - repositories { - maven { - name = "OSSRH" - url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - credentials { - username = System.getenv("MAVEN_USERNAME") - password = System.getenv("MAVEN_PASSWORD") - } - } - } - } - - // signing { - // sign publishing.publications.mavenJava - // } - javadoc { if(JavaVersion.current().isJava9Compatible()) { options.addBooleanOption('html5', true) diff --git a/controls/build.gradle b/controls/build.gradle index 646994e..a59c385 100644 --- a/controls/build.gradle +++ b/controls/build.gradle @@ -1,15 +1,12 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java library project to get you started. - * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.7/userguide/building_java_projects.html in the Gradle documentation. - */ +import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar plugins { // Apply the java-library plugin for API and implementation separation. id 'java-library' id "com.diffplug.spotless" version "6.24.0" - + id "com.vanniktech.maven.publish" version "0.30.0" } repositories { @@ -70,3 +67,54 @@ tasks.named('test') { } compileJava.dependsOn 'spotlessApply' + + +// Add this to each subproject separately. +mavenPublishing { + + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + // Project release information. + coordinates(group, project.name, version) + pom { + name = project.name + inceptionYear = "2024" + description = 'FRC 401 core controls library' + url = 'http://www.github.com/team401/coppercore' + licenses { + license { + name = 'MIT License' + url = 'https://opensource.org/license/mit' + } + } + developers { + developer { + id = 'aidnem' + name = 'Aiden Mathai' + } + developer { + id = 'linglejack' + name = 'Jack Lingle' + } + developer { + id = 'avidraccoon' + name = 'Nathan Smith' + } + developer { + id = 'minhngyuenbhs' + name = 'Minh Ngyuen' + } + developer { + id = 'jkleiber' + name = 'Justin Kleiber' + } + } + scm { + url = "https://github.com/team401/coppercore/" + connection = "scm:git:git://github.com/team401/coppercore.git" + developerConnection = "scm:git:ssh://git@github.com/team401/coppercore.git" + } + } +} diff --git a/geometry/build.gradle b/geometry/build.gradle index 74879e8..3e00bb2 100644 --- a/geometry/build.gradle +++ b/geometry/build.gradle @@ -1,14 +1,12 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java library project to get you started. - * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.7/userguide/building_java_projects.html in the Gradle documentation. - */ +import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar plugins { // Apply the java-library plugin for API and implementation separation. id 'java-library' id 'com.diffplug.spotless' version '6.24.0' + id "com.vanniktech.maven.publish" version "0.30.0" } repositories { @@ -66,3 +64,54 @@ tasks.named('test') { } compileJava.dependsOn 'spotlessApply' + + +// Add this to each subproject separately. +mavenPublishing { + + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + // Project release information. + coordinates(group, project.name, version) + pom { + name = project.name + inceptionYear = "2024" + description = 'FRC 401 geometry utilities library' + url = 'http://www.github.com/team401/coppercore' + licenses { + license { + name = 'MIT License' + url = 'https://opensource.org/license/mit' + } + } + developers { + developer { + id = 'aidnem' + name = 'Aiden Mathai' + } + developer { + id = 'linglejack' + name = 'Jack Lingle' + } + developer { + id = 'avidraccoon' + name = 'Nathan Smith' + } + developer { + id = 'minhngyuenbhs' + name = 'Minh Ngyuen' + } + developer { + id = 'jkleiber' + name = 'Justin Kleiber' + } + } + scm { + url = "https://github.com/team401/coppercore/" + connection = "scm:git:git://github.com/team401/coppercore.git" + developerConnection = "scm:git:ssh://git@github.com/team401/coppercore.git" + } + } +} diff --git a/math/build.gradle b/math/build.gradle index 646994e..2138c58 100644 --- a/math/build.gradle +++ b/math/build.gradle @@ -1,15 +1,12 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java library project to get you started. - * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.7/userguide/building_java_projects.html in the Gradle documentation. - */ +import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar plugins { // Apply the java-library plugin for API and implementation separation. id 'java-library' id "com.diffplug.spotless" version "6.24.0" - + id "com.vanniktech.maven.publish" version "0.30.0" } repositories { @@ -70,3 +67,54 @@ tasks.named('test') { } compileJava.dependsOn 'spotlessApply' + + +// Add this to each subproject separately. +mavenPublishing { + + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + // Project release information. + coordinates(group, project.name, version) + pom { + name = project.name + inceptionYear = "2024" + description = 'FRC 401 supplemental math functions' + url = 'http://www.github.com/team401/coppercore' + licenses { + license { + name = 'MIT License' + url = 'https://opensource.org/license/mit' + } + } + developers { + developer { + id = 'aidnem' + name = 'Aiden Mathai' + } + developer { + id = 'linglejack' + name = 'Jack Lingle' + } + developer { + id = 'avidraccoon' + name = 'Nathan Smith' + } + developer { + id = 'minhngyuenbhs' + name = 'Minh Ngyuen' + } + developer { + id = 'jkleiber' + name = 'Justin Kleiber' + } + } + scm { + url = "https://github.com/team401/coppercore/" + connection = "scm:git:git://github.com/team401/coppercore.git" + developerConnection = "scm:git:ssh://git@github.com/team401/coppercore.git" + } + } +} diff --git a/monitors/build.gradle b/monitors/build.gradle index 646994e..e85e022 100644 --- a/monitors/build.gradle +++ b/monitors/build.gradle @@ -1,15 +1,12 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java library project to get you started. - * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.7/userguide/building_java_projects.html in the Gradle documentation. - */ +import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar plugins { // Apply the java-library plugin for API and implementation separation. id 'java-library' id "com.diffplug.spotless" version "6.24.0" - + id "com.vanniktech.maven.publish" version "0.30.0" } repositories { @@ -70,3 +67,54 @@ tasks.named('test') { } compileJava.dependsOn 'spotlessApply' + + +// Add this to each subproject separately. +mavenPublishing { + + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + // Project release information. + coordinates(group, project.name, version) + pom { + name = project.name + inceptionYear = "2024" + description = 'FRC 401 core monitors library' + url = 'http://www.github.com/team401/coppercore' + licenses { + license { + name = 'MIT License' + url = 'https://opensource.org/license/mit' + } + } + developers { + developer { + id = 'aidnem' + name = 'Aiden Mathai' + } + developer { + id = 'linglejack' + name = 'Jack Lingle' + } + developer { + id = 'avidraccoon' + name = 'Nathan Smith' + } + developer { + id = 'minhngyuenbhs' + name = 'Minh Ngyuen' + } + developer { + id = 'jkleiber' + name = 'Justin Kleiber' + } + } + scm { + url = "https://github.com/team401/coppercore/" + connection = "scm:git:git://github.com/team401/coppercore.git" + developerConnection = "scm:git:ssh://git@github.com/team401/coppercore.git" + } + } +} diff --git a/parameter_tools/build.gradle b/parameter_tools/build.gradle index f99af0c..481e0f7 100644 --- a/parameter_tools/build.gradle +++ b/parameter_tools/build.gradle @@ -1,14 +1,12 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java library project to get you started. - * For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.7/userguide/building_java_projects.html in the Gradle documentation. - */ +import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar plugins { // Apply the java-library plugin for API and implementation separation. id 'java-library' id "com.diffplug.spotless" version "6.24.0" + id "com.vanniktech.maven.publish" version "0.30.0" } repositories { @@ -69,3 +67,54 @@ java { // Automatically format code on build. compileJava.dependsOn 'spotlessApply' + + +// Add this to each subproject separately. +mavenPublishing { + + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + // Project release information. + coordinates(group, project.name, version) + pom { + name = project.name + inceptionYear = "2024" + description = 'FRC 401 parameter tools library' + url = 'http://www.github.com/team401/coppercore' + licenses { + license { + name = 'MIT License' + url = 'https://opensource.org/license/mit' + } + } + developers { + developer { + id = 'aidnem' + name = 'Aiden Mathai' + } + developer { + id = 'linglejack' + name = 'Jack Lingle' + } + developer { + id = 'avidraccoon' + name = 'Nathan Smith' + } + developer { + id = 'minhngyuenbhs' + name = 'Minh Ngyuen' + } + developer { + id = 'jkleiber' + name = 'Justin Kleiber' + } + } + scm { + url = "https://github.com/team401/coppercore/" + connection = "scm:git:git://github.com/team401/coppercore.git" + developerConnection = "scm:git:ssh://git@github.com/team401/coppercore.git" + } + } +} diff --git a/vision/build.gradle b/vision/build.gradle index ea244a6..dd22667 100644 --- a/vision/build.gradle +++ b/vision/build.gradle @@ -1,10 +1,14 @@ import java.text.SimpleDateFormat +import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar plugins { id "java" id "maven-publish" id "com.peterabeles.gversion" version "1.10" id "com.diffplug.spotless" version "6.24.0" + id "com.vanniktech.maven.publish" version "0.30.0" } java { @@ -114,3 +118,54 @@ java { // Automatically format code on build. compileJava.dependsOn 'spotlessApply' + + +// Add this to each subproject separately. +mavenPublishing { + + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + // Project release information. + coordinates(group, project.name, version) + pom { + name = project.name + inceptionYear = "2024" + description = 'FRC 401 core vision library' + url = 'http://www.github.com/team401/coppercore' + licenses { + license { + name = 'MIT License' + url = 'https://opensource.org/license/mit' + } + } + developers { + developer { + id = 'aidnem' + name = 'Aiden Mathai' + } + developer { + id = 'linglejack' + name = 'Jack Lingle' + } + developer { + id = 'avidraccoon' + name = 'Nathan Smith' + } + developer { + id = 'minhngyuenbhs' + name = 'Minh Ngyuen' + } + developer { + id = 'jkleiber' + name = 'Justin Kleiber' + } + } + scm { + url = "https://github.com/team401/coppercore/" + connection = "scm:git:git://github.com/team401/coppercore.git" + developerConnection = "scm:git:ssh://git@github.com/team401/coppercore.git" + } + } +} diff --git a/wpilib_interface/build.gradle b/wpilib_interface/build.gradle index ff0bd78..c6c843e 100644 --- a/wpilib_interface/build.gradle +++ b/wpilib_interface/build.gradle @@ -1,10 +1,13 @@ import java.text.SimpleDateFormat +import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar plugins { id "java" - id "maven-publish" id "com.peterabeles.gversion" version "1.10" id "com.diffplug.spotless" version "6.24.0" + id "com.vanniktech.maven.publish" version "0.30.0" } java { @@ -117,3 +120,54 @@ java { // Automatically format code on build. compileJava.dependsOn 'spotlessApply' + + +// Add this to each subproject separately. +mavenPublishing { + + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + // Project release information. + coordinates(group, project.name, version) + pom { + name = project.name + inceptionYear = "2024" + description = 'Interface between coppercore and the WPILib' + url = 'http://www.github.com/team401/coppercore' + licenses { + license { + name = 'MIT License' + url = 'https://opensource.org/license/mit' + } + } + developers { + developer { + id = 'aidnem' + name = 'Aiden Mathai' + } + developer { + id = 'linglejack' + name = 'Jack Lingle' + } + developer { + id = 'avidraccoon' + name = 'Nathan Smith' + } + developer { + id = 'minhngyuenbhs' + name = 'Minh Ngyuen' + } + developer { + id = 'jkleiber' + name = 'Justin Kleiber' + } + } + scm { + url = "https://github.com/team401/coppercore/" + connection = "scm:git:git://github.com/team401/coppercore.git" + developerConnection = "scm:git:ssh://git@github.com/team401/coppercore.git" + } + } +} From e55d10d51730cec62ae025780071b39bfb8ada6e Mon Sep 17 00:00:00 2001 From: Justin Kleiber Date: Sat, 30 Nov 2024 16:50:09 -0600 Subject: [PATCH 2/6] Updates workflows to allow testing of publishing --- .github/workflows/publish_library.yml | 8 +++--- .github/workflows/stage_library.yml | 36 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/stage_library.yml diff --git a/.github/workflows/publish_library.yml b/.github/workflows/publish_library.yml index 46771d4..f0f397c 100644 --- a/.github/workflows/publish_library.yml +++ b/.github/workflows/publish_library.yml @@ -31,7 +31,9 @@ jobs: uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - name: Publish package - run: ./gradlew publish + # run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache + run: ./gradlew publishToMavenCentral --no-configuration-cache env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }} diff --git a/.github/workflows/stage_library.yml b/.github/workflows/stage_library.yml new file mode 100644 index 0000000..2f3fcfc --- /dev/null +++ b/.github/workflows/stage_library.yml @@ -0,0 +1,36 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish package to the Maven Central Repository +on: + workflow_dispatch: +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + + - name: Stage package on central portal + run: ./gradlew publishToMavenCentral --no-configuration-cache + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }} From c820f4080bfbf49316ced6f3cc70a4acc0465362 Mon Sep 17 00:00:00 2001 From: Justin Kleiber Date: Sat, 30 Nov 2024 17:02:54 -0600 Subject: [PATCH 3/6] Updates documentation and ready to test the library auto-publish --- .github/workflows/publish_library.yml | 3 +-- README.md | 28 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_library.yml b/.github/workflows/publish_library.yml index f0f397c..0700b05 100644 --- a/.github/workflows/publish_library.yml +++ b/.github/workflows/publish_library.yml @@ -31,8 +31,7 @@ jobs: uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - name: Publish package - # run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache - run: ./gradlew publishToMavenCentral --no-configuration-cache + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} diff --git a/README.md b/README.md index aec45a6..d8ca2b5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # coppercore -## Maintaining Maven Central Publishing +## Maven Central +This project is available on maven central! The instructions below outline how to set this up. + +### Secret Keys In order to publish on Maven Central, multiple secret keys must be maintained. The GPG key and the Sonatype token are independent though, and can be regenerated as needed without updating the other one. @@ -20,6 +23,8 @@ To temporarily set any of these variables locally for testing, you can do the fo $env.ENV_VARIABLE_NAME = "environment-variable-value" ``` +More information about environment variables can be found [on the docs page of our gradle plugin of choice](https://vanniktech.github.io/gradle-maven-publish-plugin/central/#secrets) for publishing to the Central Portal. + ### Generating a GPG key To generate the GPG key, first generate a key locally: @@ -49,4 +54,23 @@ Finally, you need to publish the **public** key so users can actually verify the gpg --keyserver keyserver.ubuntu.com KEY-ID ``` -More information on generating GPG keys can be found [on the Sonatype docs](https://central.sonatype.org/publish/requirements/gpg/) or on the [GitHub docs](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key). \ No newline at end of file +More information on generating GPG keys can be found [on the Sonatype docs](https://central.sonatype.org/publish/requirements/gpg/) or on the [GitHub docs](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key). + +### Publishing + +#### GitHub Actions + +Whenever a release is created on GitHub, the `publish_library` action will automatically publish the released version to the Central Portal. At any time this workflow can be run manually as well. + +The `stage_library` GitHub action can be run manually to confirm that the library stages on the Central Portal. This can be used to preview a release to the Central Portal and also to ensure the maven central formatting is followed correctly. + +#### Locally +To stage the package on the Central Portal for future (manual) release, run the following command: +``` +./gradlew publishToMavenCentral --no-configuration-cache +``` + +Or, to automatically stage and publish a version run: +``` +./gradlew publishAndReleaseToMavenCentral --no-configuration-cache +``` \ No newline at end of file From cc6713f13e4d76d9f65b2a27b8a983ff34537035 Mon Sep 17 00:00:00 2001 From: Justin Kleiber Date: Sat, 30 Nov 2024 17:14:47 -0600 Subject: [PATCH 4/6] Makes signing only happen in github actions in order to allow for local publishing to not need GPG keys --- .github/workflows/publish_library.yml | 2 +- .github/workflows/stage_library.yml | 2 +- README.md | 13 ++++--------- controls/build.gradle | 1 - geometry/build.gradle | 1 - math/build.gradle | 1 - monitors/build.gradle | 1 - parameter_tools/build.gradle | 1 - vision/build.gradle | 1 - wpilib_interface/build.gradle | 1 - 10 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/publish_library.yml b/.github/workflows/publish_library.yml index 0700b05..0f45899 100644 --- a/.github/workflows/publish_library.yml +++ b/.github/workflows/publish_library.yml @@ -31,7 +31,7 @@ jobs: uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - name: Publish package - run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache -PRELEASE_SIGNING_ENABLED=true env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} diff --git a/.github/workflows/stage_library.yml b/.github/workflows/stage_library.yml index 2f3fcfc..d62f9ac 100644 --- a/.github/workflows/stage_library.yml +++ b/.github/workflows/stage_library.yml @@ -29,7 +29,7 @@ jobs: uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - name: Stage package on central portal - run: ./gradlew publishToMavenCentral --no-configuration-cache + run: ./gradlew publishToMavenCentral --no-configuration-cache -PRELEASE_SIGNING_ENABLED=true env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} diff --git a/README.md b/README.md index d8ca2b5..3a270f6 100644 --- a/README.md +++ b/README.md @@ -58,19 +58,14 @@ More information on generating GPG keys can be found [on the Sonatype docs](http ### Publishing -#### GitHub Actions +#### Via GitHub Actions Whenever a release is created on GitHub, the `publish_library` action will automatically publish the released version to the Central Portal. At any time this workflow can be run manually as well. The `stage_library` GitHub action can be run manually to confirm that the library stages on the Central Portal. This can be used to preview a release to the Central Portal and also to ensure the maven central formatting is followed correctly. -#### Locally -To stage the package on the Central Portal for future (manual) release, run the following command: +#### Maven Local +To publish the package on your computer's local maven (typically `~/.m2/`), run the following command: ``` -./gradlew publishToMavenCentral --no-configuration-cache +./gradlew publishToMavenLocal ``` - -Or, to automatically stage and publish a version run: -``` -./gradlew publishAndReleaseToMavenCentral --no-configuration-cache -``` \ No newline at end of file diff --git a/controls/build.gradle b/controls/build.gradle index a59c385..6415c0b 100644 --- a/controls/build.gradle +++ b/controls/build.gradle @@ -74,7 +74,6 @@ mavenPublishing { configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - signAllPublications() // Project release information. coordinates(group, project.name, version) diff --git a/geometry/build.gradle b/geometry/build.gradle index 3e00bb2..eab2071 100644 --- a/geometry/build.gradle +++ b/geometry/build.gradle @@ -71,7 +71,6 @@ mavenPublishing { configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - signAllPublications() // Project release information. coordinates(group, project.name, version) diff --git a/math/build.gradle b/math/build.gradle index 2138c58..b0d8eda 100644 --- a/math/build.gradle +++ b/math/build.gradle @@ -74,7 +74,6 @@ mavenPublishing { configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - signAllPublications() // Project release information. coordinates(group, project.name, version) diff --git a/monitors/build.gradle b/monitors/build.gradle index e85e022..f777111 100644 --- a/monitors/build.gradle +++ b/monitors/build.gradle @@ -74,7 +74,6 @@ mavenPublishing { configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - signAllPublications() // Project release information. coordinates(group, project.name, version) diff --git a/parameter_tools/build.gradle b/parameter_tools/build.gradle index 481e0f7..279ba68 100644 --- a/parameter_tools/build.gradle +++ b/parameter_tools/build.gradle @@ -74,7 +74,6 @@ mavenPublishing { configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - signAllPublications() // Project release information. coordinates(group, project.name, version) diff --git a/vision/build.gradle b/vision/build.gradle index dd22667..1961f43 100644 --- a/vision/build.gradle +++ b/vision/build.gradle @@ -125,7 +125,6 @@ mavenPublishing { configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - signAllPublications() // Project release information. coordinates(group, project.name, version) diff --git a/wpilib_interface/build.gradle b/wpilib_interface/build.gradle index c6c843e..35d3920 100644 --- a/wpilib_interface/build.gradle +++ b/wpilib_interface/build.gradle @@ -127,7 +127,6 @@ mavenPublishing { configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - signAllPublications() // Project release information. coordinates(group, project.name, version) From 0d8d6d49b138d1bc16ae1cc734530bfae047dd38 Mon Sep 17 00:00:00 2001 From: Justin Kleiber Date: Sat, 30 Nov 2024 17:33:37 -0600 Subject: [PATCH 5/6] Updates documentation for external users --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 3a270f6..d721590 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,29 @@ # coppercore +## Using this in your project +To use this in your project, first make sure you have `mavenCentral()` included in your `repositories` block of your `build.gradle`: +``` +repositories { + mavenCentral() +} +``` +**Note:** if you are using the maven local distribution, make sure to include `mavenLocal()` in the repositories block as well. + +Then, you can include any of the following dependencies as you need in your `dependencies` block of your `build.gradle`: +``` +dependencies { + ... + implementation 'io.github.team401.coppercore:controls:VERSION' + implementation 'io.github.team401.coppercore:geometry:VERSION' + implementation 'io.github.team401.coppercore:math:VERSION' + implementation 'io.github.team401.coppercore:monitors:VERSION' + implementation 'io.github.team401.coppercore:parameter_tools:VERSION' + implementation 'io.github.team401.coppercore:vision:VERSION' + implementation 'io.github.team401.coppercore:wpilib_interface:VERSION' + ... +} +``` +where `VERSION` is available for selection from the GitHub releases or you can look it up [on the central portal](https://central.sonatype.com/search?q=coppercore) directly. ## Maven Central This project is available on maven central! The instructions below outline how to set this up. From 6e45ad7bf5717649c3e9378e80b288e6be386bce Mon Sep 17 00:00:00 2001 From: Justin Kleiber Date: Sat, 30 Nov 2024 17:39:43 -0600 Subject: [PATCH 6/6] Changes apostrophes to double quotes --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d721590..a75f615 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,13 @@ Then, you can include any of the following dependencies as you need in your `dep ``` dependencies { ... - implementation 'io.github.team401.coppercore:controls:VERSION' - implementation 'io.github.team401.coppercore:geometry:VERSION' - implementation 'io.github.team401.coppercore:math:VERSION' - implementation 'io.github.team401.coppercore:monitors:VERSION' - implementation 'io.github.team401.coppercore:parameter_tools:VERSION' - implementation 'io.github.team401.coppercore:vision:VERSION' - implementation 'io.github.team401.coppercore:wpilib_interface:VERSION' + implementation "io.github.team401.coppercore:controls:VERSION" + implementation "io.github.team401.coppercore:geometry:VERSION" + implementation "io.github.team401.coppercore:math:VERSION" + implementation "io.github.team401.coppercore:monitors:VERSION" + implementation "io.github.team401.coppercore:parameter_tools:VERSION" + implementation "io.github.team401.coppercore:vision:VERSION" + implementation "io.github.team401.coppercore:wpilib_interface:VERSION" ... } ```