diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/ci.yml similarity index 53% rename from .github/workflows/pipeline.yaml rename to .github/workflows/ci.yml index 25652ad..9893cb9 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Pipeline +name: CI on: push: @@ -8,30 +8,10 @@ on: branches: - main -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: - linting: - name: Lint Code - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v5 - - - name: Install ktlint - shell: bash - run: | - curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.3.0/ktlint - chmod a+x ktlint - ./ktlint "**/*.kt" - - test: - needs: - - linting - name: Run Unit Tests + check: + name: Lint & Test runs-on: ubuntu-22.04 - steps: - uses: actions/checkout@v5 @@ -42,11 +22,11 @@ jobs: distribution: 'temurin' cache: 'gradle' - - name: Gradle Build - uses: gradle/actions/setup-gradle@v5 - with: - gradle-version: '9.2.1' - cache-disabled: false + - name: Run Lint + run: | + curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.3.0/ktlint + chmod a+x ktlint + ./ktlint "**/*.kt" - name: Run Tests run: ./gradlew test -PskipReports diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a8d2363 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,80 @@ +name: Release + +on: + workflow_dispatch: + inputs: + bump_type: + description: 'Type of version bump (major, minor, patch)' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + +jobs: + release: + runs-on: ubuntu-22.04 + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + with: + token: '${{ secrets.RELEASE_TOKEN }}' + fetch-depth: 0 + + - name: Setup Java + uses: actions/setup-java@v5 + with: + java-version: '17' + distribution: 'temurin' + cache: 'gradle' + + - name: Bump Version + id: bump + run: | + VERSION=$(grep 'version=' gradle.properties | cut -d'=' -f2) + IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" + + if [ "${{ github.event.inputs.bump_type }}" == "major" ]; then + MAJOR=$((MAJOR + 1)) + MINOR=0 + PATCH=0 + elif [ "${{ github.event.inputs.bump_type }}" == "minor" ]; then + MINOR=$((MINOR + 1)) + PATCH=0 + else + PATCH=$((PATCH + 1)) + fi + + NEW_VERSION="$MAJOR.$MINOR.$PATCH" + echo "Bumping to $NEW_VERSION" + + sed -i "s/^version=.*/version=$NEW_VERSION/" gradle.properties + + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + + - name: Run Tests + run: ./gradlew test -PskipReports + + - name: Commit & Tag + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add gradle.properties + git commit -m "Release $NEW_VERSION" + git push + + - name: Build Artifacts + run: ./gradlew clean publish + + - name: JReleaser Full Release + run: ./gradlew jreleaserFullRelease --no-configuration-cache + env: + JRELEASER_GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }} + JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/build.gradle.kts b/build.gradle.kts index 36fa712..385b832 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1 +1,41 @@ +import org.jreleaser.model.Active + +plugins { + id("org.jreleaser") version "1.22.0" +} + group = "io.github.kronst" + +jreleaser { + project { + copyright.set("Roman Konstantynovskyi") + name.set("murphy") + description.set("Chaos Engineering library for JVM") + + links { + homepage.set("https://github.com/kronst/murphy") + } + } + signing { + active.set(Active.ALWAYS) + pgp { + armored.set(true) + } + } + deploy { + maven { + mavenCentral { + create("sonatype") { + active.set(Active.ALWAYS) + url.set("https://central.sonatype.com/api/v1/publisher/") + namespace.set("io.github.kronst") + stagingRepository("build/staging-deploy") + } + } + } + } +} + +tasks.register("clean") { + delete(layout.buildDirectory) +} diff --git a/buildSrc/src/main/kotlin/murphy.kotlin-library.gradle.kts b/buildSrc/src/main/kotlin/murphy.kotlin-library.gradle.kts index dc6c591..5b6079e 100644 --- a/buildSrc/src/main/kotlin/murphy.kotlin-library.gradle.kts +++ b/buildSrc/src/main/kotlin/murphy.kotlin-library.gradle.kts @@ -1,7 +1,10 @@ plugins { kotlin("jvm") + `maven-publish` } +group = rootProject.group + val libs: VersionCatalog = extensions.getByType().named("libs") repositories { @@ -18,6 +21,51 @@ kotlin { jvmToolchain(17) } +java { + withSourcesJar() + withJavadocJar() +} + tasks.test { useJUnitPlatform() } + +publishing { + publications { + create("maven") { + from(components["java"]) + + pom { + name.set(project.name) + description.set("Chaos Engineering library for JVM - ${project.name}") + url.set("https://github.com/kronst/murphy") + + licenses { + license { + name.set("MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("kronst") + name.set("Roman Konstantynovskyi") + } + } + + scm { + connection.set("scm:git:git://github.com/kronst/murphy.git") + developerConnection.set("scm:git:ssh://github.com/kronst/murphy.git") + url.set("https://github.com/kronst/murphy") + } + } + } + } + + repositories { + maven { + url = uri(rootProject.layout.buildDirectory.dir("staging-deploy")) + } + } +}