From 21727ebfc715c978ac008d82400829785ded5067 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 4 Oct 2021 15:28:47 +0200 Subject: [PATCH] build: Overhaul build & deployment workflow (#3267) * Fixes #3250 * build: Overhaul build & deployment workflow - Move to release drafter - Replace publishing with gradle nexus - Conventional commits are handy - Determine build status in gh actions before deploying --- .editorconfig | 2 +- .github/release-drafter.yml | 20 ++++++ .github/workflows/build.yml | 26 +++++++- .github/workflows/release-drafter.yml | 14 ++++ .github/workflows/validate-gradle-wrapper.yml | 12 ---- CONTRIBUTING.md | 5 ++ Core/src/main/resources/lang/messages_en.json | 2 - build.gradle.kts | 65 ++++++------------- gradle/libs.versions.toml | 2 + renovate.json | 4 +- 10 files changed, 90 insertions(+), 62 deletions(-) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/release-drafter.yml delete mode 100644 .github/workflows/validate-gradle-wrapper.yml diff --git a/.editorconfig b/.editorconfig index f72383ca5..16b2c7ec4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1008,6 +1008,6 @@ ij_html_uniform_ident = false indent_size = 2 ij_yaml_keep_indents_on_empty_lines = false ij_yaml_keep_line_breaks = true -ij_yaml_space_before_colon = true +ij_yaml_space_before_colon = false ij_yaml_spaces_within_braces = true ij_yaml_spaces_within_brackets = true diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 000000000..b2b5e9280 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,20 @@ +categories: + - title: '🐛 Fixes' + label: 'Bugfix' + - title: '✨ Features' + label: 'Feature' + - title: '🧭 Changes' + label: 'Enhancement' + - title: '📦 Dependency updates' + labels: + - 'Renovate' + - 'Dependency updates' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&@' +exclude-contributors: + - 'renovate' + - 'renovate-bot' +template: | + ## PlotSquared v6. + + $CHANGES diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8e842bfa..e5c29acea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ name: "build" -on: ["pull_request", "push"] +on: [ "pull_request", "push" ] jobs: build: @@ -8,6 +8,8 @@ jobs: steps: - name: "Checkout Repository" uses: "actions/checkout@v2.3.4" + - name: "Validate Gradle Wrapper" + uses: "gradle/wrapper-validation-action@v1.0.4" - name: "Setup JDK 16" uses: "actions/setup-java@v2.2.0" with: @@ -15,3 +17,25 @@ jobs: java-version: "16" - name: "Clean Build" run: "./gradlew clean build" + - name: "Determine release status" + if: "${{ runner.os == 'Linux' }}" + run: | + if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then + echo "STATUS=snapshot" >> $GITHUB_ENV + else + echo "STATUS=release" >> $GITHUB_ENV + fi + - name: "Publish Release" + if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}" + run: "./gradlew publishToSonatype closeSonatypeStagingRepository" + env: + ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" + ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" + ORG_GRADLE_PROJECT_signingKey: "${{ secrets.SIGNING_KEY }}" + ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.SIGNING_PASSWORD }}" + - name: "Publish Snapshot" + if: "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6' }}" + run: "./gradlew publishToSonatype" + env: + ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" + ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 000000000..d3ba4de8b --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,14 @@ +name: "draft release" + +on: + push: + branches: + - v6 + +jobs: + update_release_draft: + runs-on: "ubuntu-latest" + steps: + - uses: "release-drafter/release-drafter@v5.15.0" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/validate-gradle-wrapper.yml b/.github/workflows/validate-gradle-wrapper.yml deleted file mode 100644 index a94b68913..000000000 --- a/.github/workflows/validate-gradle-wrapper.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: "validate gradle wrapper" - -on: ["pull_request", "push"] - -jobs: - build: - runs-on: "ubuntu-20.04" - steps: - - name: "Checkout Repository" - uses: "actions/checkout@v2.3.4" - - name: "Validate Gradle Wrapper" - uses: "gradle/wrapper-validation-action@v1.0.4" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66ea03d3d..a049a8432 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,3 +6,8 @@ If you are planning to commit any changes to the project, it would be highly app code style conventions. To make this easier we have provided settings that can be picked up by your IDE. IntelliJ: Install the `EditorConfig` plugin. Now IntelliJ is able to pick up the provided `.editorconfig` file automatically. + +### Committing + +We are using [conventional commits](https://www.conventionalcommits.org/en/) to make commit messages more descriptive and +generate changelogs based on them. diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index c6a19b3bc..ded6005a4 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -183,8 +183,6 @@ "error.task_in_process": "Task is already running.", "titles.title_entered_plot": "Plot: ;", "titles.title_entered_plot_sub": "Owned by ", - "titles.prefix_greeting": ">", - "titles.prefix_farewell": ">", "core.prefix": "[P2] ", "core.enabled": " is now enabled.", "placeholder.hooked": "PlotSquared hooked into MVdWPlaceholderAPI", diff --git a/build.gradle.kts b/build.gradle.kts index d240878a0..619351632 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin import org.cadixdev.gradle.licenser.LicenseExtension import org.cadixdev.gradle.licenser.Licenser +import java.net.URI plugins { java @@ -11,22 +12,13 @@ plugins { alias(libs.plugins.shadow) alias(libs.plugins.licenser) alias(libs.plugins.grgit) + alias(libs.plugins.nexus) eclipse idea } -var ver by extra("6.1.3") -var versuffix by extra("-SNAPSHOT") -val versionsuffix: String? by project -if (versionsuffix != null) { - versuffix = "-$versionsuffix" -} -version = if (!project.hasProperty("release")) { - ver + versuffix -} else { - ver -} +version = "6.1.3-SNAPSHOT" allprojects { group = "com.plotsquared" @@ -103,6 +95,9 @@ allprojects { signing { if (!version.toString().endsWith("-SNAPSHOT")) { + val signingKey: String? by project + val signingPassword: String? by project + useInMemoryPgpKeys(signingKey, signingPassword) signing.isRequired sign(publishing.publications) } @@ -111,8 +106,6 @@ allprojects { publishing { publications { create("maven") { - // This includes not only the original jar (i.e. not shadowJar), - // but also sources & javadocs due to the above java block. from(components["java"]) pom { @@ -133,18 +126,23 @@ allprojects { developer { id.set("Sauilitired") name.set("Alexander Söderberg") + organization.set("IntellectualSites") } developer { id.set("NotMyFault") name.set("NotMyFault") + organization.set("IntellectualSites") + email.set("contact@notmyfault.dev") } developer { id.set("SirYwell") name.set("Hannes Greule") + organization.set("IntellectualSites") } developer { id.set("dordsor21") name.set("dordsor21") + organization.set("IntellectualSites") } } @@ -161,34 +159,6 @@ allprojects { } } } - - repositories { - mavenLocal() // Install to own local repository - - // Accept String? to not err if they're not present. - // Check that they both exist before adding the repo, such that - // `credentials` doesn't err if one is null. - // It's not pretty, but this way it can compile. - val nexusUsername: String? by project - val nexusPassword: String? by project - if (nexusUsername != null && nexusPassword != null) { - maven { - val releasesRepositoryUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - val snapshotRepositoryUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" - url = uri( - if (version.toString().endsWith("-SNAPSHOT")) snapshotRepositoryUrl - else releasesRepositoryUrl - ) - - credentials { - username = nexusUsername - password = nexusPassword - } - } - } else { - logger.warn("No nexus repository is added; nexusUsername or nexusPassword is null.") - } - } } tasks { @@ -217,10 +187,6 @@ allprojects { ) } - jar { - this.archiveClassifier.set("jar") - } - shadowJar { this.archiveClassifier.set(null as String?) this.archiveFileName.set("${project.name}-${project.version}.${this.archiveExtension.getOrElse("jar")}") @@ -237,6 +203,15 @@ allprojects { } +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(URI.create("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(URI.create("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + } + } +} + tasks { val aggregatedJavadocs = create("aggregatedJavadocs") { title = "${project.name} ${project.version} API" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5fcf212f6..ec5cc2529 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,6 +42,7 @@ http4j = "1.3" shadow = "7.0.0" grgit = "4.1.0" licenser = "0.6.1" +nexus = "1.1.0" [libraries] # Platform expectations @@ -92,3 +93,4 @@ paster = { group = "com.intellectualsites.paster", name = "Paster", version.ref shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" } grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" } licenser = { id = "org.cadixdev.licenser", version.ref = "licenser" } +nexus = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus" } diff --git a/renovate.json b/renovate.json index 521730a15..239438c66 100644 --- a/renovate.json +++ b/renovate.json @@ -12,5 +12,7 @@ "timezone": "Europe/Berlin", "schedule": [ "on monday after 9am" - ] + ], + "labels": ["Renovate"], + "commitMessagePrefix": "chore: " }