Skip to content

Commit

Permalink
chore: refactor project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara committed Apr 27, 2023
1 parent 6d67ac6 commit 93032ff
Show file tree
Hide file tree
Showing 9 changed files with 9,400 additions and 3,926 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: CI/CD Process
on:
workflow_call:
workflow_dispatch:

jobs:
build:
strategy:
matrix:
os: [ windows-2022, macos-12, ubuntu-22.04 ]
runs-on: ${{ matrix.os }}
concurrency:
group: build-${{ github.workflow }}-${{ matrix.os }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: DanySK/[email protected]
with:
# Dry-deployment
check-command: ./gradlew build --parallel
deploy-command: >-
./gradlew
uploadKotlinOSSRHToMavenCentralNexus
uploadPluginMavenToMavenCentralNexus
uploadPluginMarkerMavenToMavenCentralNexus
close
drop
--parallel
should-run-codecov: ${{ runner.os == 'Linux' }}
should-deploy: >-
${{
runner.os == 'Linux'
&& !github.event.repository.fork
&& github.event_name != 'pull_request'
}}
maven-central-username: nicolasfarabegoli
maven-central-password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
signing-key: ${{ secrets.SIGNING_KEY }}
signing-password: ${{ secrets.SIGNING_PASSWORD }}

release:
concurrency:
# Only one release job at a time. Strictly sequential.
group: release
needs:
- build
runs-on: ubuntu-22.04
if: >-
!github.event.repository.fork
&& github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/[email protected]
with:
token: ${{ secrets.PERSONAL_TOKEN }}
- name: Find the version of Node from package.json
id: node-version
run: echo "version=$(jq -r .engines.node package.json)" >> $GITHUB_OUTPUT
- name: Install Node
uses: actions/[email protected]
with:
node-version: ${{ steps.node-version.outputs.version }}
- uses: DanySK/[email protected]
with:
build-command: true
check-command: true
deploy-command: |
npm install
npx semantic-release
should-run-codecov: false
should-deploy: true
github-token: ${{ github.token }}
gradle-publish-secret: ${{ secrets.GRADLE_PUBLISH_SECRET }}
gradle-publish-key: ${{ secrets.GRADLE_PUBLISH_KEY }}
maven-central-username: nicolasfarabegoli
maven-central-password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
signing-key: ${{ secrets.SIGNING_KEY }}
signing-password: ${{ secrets.SIGNING_PASSWORD }}

success:
runs-on: ubuntu-22.04
needs:
- release
- build
if: >-
always() && (
contains(join(needs.*.result, ','), 'failure')
|| !contains(join(needs.*.result, ','), 'cancelled')
)
steps:
- name: Verify that there were no failures
run: ${{ !contains(join(needs.*.result, ','), 'failure') }}
70 changes: 0 additions & 70 deletions .github/workflows/build-release.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/dispatcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI/CD
on:
push:
branches-ignore:
- 'dependabot/**'
paths-ignore:
- '.gitignore'
- '.mergify.yml'
- 'CHANGELOG.md'
- 'LICENSE'
- 'README.md'
- 'renovate.json'
pull_request:
workflow_dispatch:

jobs:
dispatcher:
runs-on: ubuntu-22.04
if: >-
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name != github.repository
|| startsWith(github.head_ref, 'dependabot/')
steps:
- run: 'true'
ci-cd:
needs:
- dispatcher
uses: ./.github/workflows/build-and-deploy.yml
secrets: inherit
20 changes: 0 additions & 20 deletions .releaserc.yml

This file was deleted.

69 changes: 53 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION as KOTLIN_VERSION

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
Expand All @@ -9,17 +10,23 @@ plugins {
alias(libs.plugins.dokka)
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
alias(libs.plugins.publish.central)
alias(libs.plugins.publishOnCentral)
alias(libs.plugins.gitSemVer)
alias(libs.plugins.publish)
alias(libs.plugins.conventional.commits)
}

group = "it.nicolasfarabegoli"
val projectId = "$group.$name"
val fullName = "Configure conventional commit"
val websiteUrl = "https://github.com/nicolasfara/conventional-commits"
val projectDetail = "Plugin to check if commits are 'Conventional Commits' compliant"
val pluginImplementationClass = "it.nicolasfarabegoli.gradle.ConventionalCommits"
description = "Plugin to check if commits are 'Conventional Commits' compliant"
inner class ProjectInfo {
val longName = "Template for Gradle Plugins"
val website = "https://github.com/nicolasfara/conventional-commits"
val vcsUrl = "$website.git"
val scm = "scm:git:$website.git"
val pluginImplementationClass = "$group.gradle.ConventionalCommits"
val tags = listOf("conventional-commit")
}
val info = ProjectInfo()

repositories {
mavenCentral()
Expand Down Expand Up @@ -54,29 +61,59 @@ tasks.withType<Test> {
}

gradlePlugin {
website.set(websiteUrl)
vcsUrl.set(websiteUrl)
plugins {
create("ConventionalCommits") {
id = projectId
displayName = fullName
description = projectDetail
implementationClass = pluginImplementationClass
website.set(info.website)
vcsUrl.set(info.vcsUrl)
create("") {
id = "$group.${project.name}"
displayName = info.longName
description = project.description
implementationClass = info.pluginImplementationClass
tags.set(info.tags)
}
}
}

// Enforce Kotlin version coherence
configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin" && requested.name.startsWith("kotlin")) {
useVersion(KOTLIN_VERSION)
because("All Kotlin modules should use the same version, and compiler uses $KOTLIN_VERSION")
}
}
}

publishOnMavenCentral {
projectDescription.set(projectDetail)
signing {
if (System.getenv()["CI"].equals("true", ignoreCase = true)) {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
}
}

/*
* Publication on Maven Central and the Plugin portal
*/
publishOnCentral {
projectLongName.set(info.longName)
projectDescription.set(description ?: TODO("Missing description"))
projectUrl.set(info.website)
scmConnection.set(info.scm)
publishing {
publications {
withType<MavenPublication> {
pom {
scm {
connection.set("git:[email protected]:nicolasfara/${rootProject.name}")
developerConnection.set("git:[email protected]:nicolasfara/${rootProject.name}")
url.set("https://github.com/nicolasfara/${rootProject.name}")
}
developers {
developer {
name.set("Nicolas Farabegoli")
email.set("[email protected]")
url.set("https://github.com/nicolasfara")
url.set("https://www.nicolasfarabegoli.it/")
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
publish = { id = "com.gradle.plugin-publish", version = "1.2.0" }
publish-central = { id = "it.nicolasfarabegoli.publish-to-maven-central", version = "1.1.4" }
conventional-commits = { id = "it.nicolasfarabegoli.conventional-commits", version = "3.1.0" }
publishOnCentral = "org.danilopianini.publish-on-central:5.0.5"
gitSemVer = "org.danilopianini.git-sensitive-semantic-versioning:1.1.9"
conventional-commits = { id = "it.nicolasfarabegoli.conventional-commits", version = "3.1.0" }
taskTree = "com.dorongold.task-tree:2.1.1"
Loading

0 comments on commit 93032ff

Please sign in to comment.