From 357714db1ede59fe7af8d3c4bfb74aa7d0c743ff Mon Sep 17 00:00:00 2001 From: "lukasz.gryzbon" Date: Fri, 7 Jan 2022 18:12:16 +0000 Subject: [PATCH 1/4] fix: #4 Some initial changes to enable automated release --- .githooks/commit-msg | 51 +++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++++++++ .github/workflows/nightly.yml | 16 +++++++++++ .releaserc.yaml | 9 +++++++ build.gradle.kts | 12 ++++++++- hooks.gradle | 8 ++++++ 6 files changed, 142 insertions(+), 1 deletion(-) create mode 100755 .githooks/commit-msg create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/nightly.yml create mode 100644 .releaserc.yaml create mode 100644 hooks.gradle diff --git a/.githooks/commit-msg b/.githooks/commit-msg new file mode 100755 index 0000000..a1be4f8 --- /dev/null +++ b/.githooks/commit-msg @@ -0,0 +1,51 @@ +#!/bin/bash + +# +# This hook checks the commit message (header only) to ensure that the expected format is used. +# +# Commits with breaking changes should include 'BREAKING CHANGE: ' in the commit body with a description (Note: this is not validated by the hook). +# + +commit_regex='^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-zA-Z0-9 /_,.-]+?\))?: .{1,79}\w|Merge .+|(fixup|squash)! .+)$' + +error_msg=' +---------------------------------------------------- +ABORTING commit - Expecting a conventional commit message header: + + [(optional scope)]: +---------------------------------------------------- +Examples: +1. + fix(cache): Fix nasty caching bug (#123) +2. + feat: Enable awesome feature (#456) +3. + chore: Cleanup code to reduce maintenance cost + + BREAKING CHANGE: Deprecated feature xyz finally removed + + [optional footer] +---------------------------------------------------- +Accepted Types: + build - for changes that affect the build or external dependencies + chore - for general maintenance changes + ci - for changes related to the ci pipeline + docs - for documentation changes + feat - for features [* triggers a MINOR release when pushed] + fix - for fixes [* triggers a PATCH release when pushed] + perf - for performance related changes + refactor - for refactoring + revert - for revert commits + style - for style changes + test - for adding or updating tests +---------------------------------------------------- +Exceptions: + fixup! ... + squash! ... + Merge ... +' + +if ! grep -iqE "${commit_regex}" "$1"; then + echo "${error_msg}" >&2 + exit 1 +fi \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..59248ef --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +# This workflow will build a Java project with Gradle then perform an automated release +# For more information see: +# https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle +# https://github.com/marketplace/actions/action-for-semantic-release + +name: CI +on: [ push, pull_request ] +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - name: Build with Gradle + run: ./gradlew build + - uses: actions/upload-artifact@v2 + with: + name: build-directory + path: build + - uses: codecov/codecov-action@v1 + with: + files: build/reports/jacoco/test/jacocoTestReport.xml + verbose: true + release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v2 + id: semantic + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish to Sonatype + if: steps.semantic.outputs.new_release_published == 'true' + 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 }} + run: | + ./gradlew publishToSonatype closeAndReleaseStagingRepository \ No newline at end of file diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..4bc32eb --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,16 @@ +name: Nightly Build +on: + schedule: + - cron: '0 2 * * *' # run at 2 AM UTC +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - name: Build with Gradle + run: ./gradlew build \ No newline at end of file diff --git a/.releaserc.yaml b/.releaserc.yaml new file mode 100644 index 0000000..e28d9b9 --- /dev/null +++ b/.releaserc.yaml @@ -0,0 +1,9 @@ +# See: +# https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration +# https://github.com/marketplace/actions/action-for-semantic-release + +branches: ["master", "main"] +plugins: + - "@semantic-release/commit-analyzer" + - "@semantic-release/release-notes-generator" + - "@semantic-release/github" \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 620b5ed..c8a2204 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { java `maven-publish` id("io.github.gradle-nexus.publish-plugin") version "1.1.0" - id("pl.allegro.tech.build.axion-release") version "1.13.4" + id("com.palantir.git-version") version "0.12.3" } nexusPublishing.repositories.sonatype { @@ -17,7 +17,17 @@ nexusPublishing.repositories.sonatype { snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) } +tasks.create("installGitHooks") { + shouldRunAfter("clean") + println("-- Configuring git to use .githooks --") + project.exec { + commandLine("git", "config", "core.hooksPath", ".githooks") + } +} + group = "io.github.lsd-consulting" +version = gitVersion().replaceAll("^v", "") + rootProject.version = scmVersion.version println("Build Version = ${project.version}") diff --git a/hooks.gradle b/hooks.gradle new file mode 100644 index 0000000..3aae85e --- /dev/null +++ b/hooks.gradle @@ -0,0 +1,8 @@ + +task installGitHooks() { + shouldRunAfter("clean") + println "-- Configuring git to use .githooks --" + project.exec { + commandLine('git', 'config', 'core.hooksPath', '.githooks') + } +} \ No newline at end of file From c9b6177835ce9d9fb285ed7313bf13333980d381 Mon Sep 17 00:00:00 2001 From: Lukasz Gryzbon Date: Fri, 7 Jan 2022 23:30:32 +0000 Subject: [PATCH 2/4] fix: #4 More changes to enable automated release --- .github/workflows/macos-build.yml | 25 ------------------------- README.md | 2 ++ build.gradle.kts | 7 +++---- release.sh | 11 ----------- service/build.gradle.kts | 16 +++++++++++++--- 5 files changed, 18 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/macos-build.yml delete mode 100755 release.sh diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml deleted file mode 100644 index d00ab78..0000000 --- a/.github/workflows/macos-build.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Build - -on: [ push, pull_request ] - -jobs: - build: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - name: Build with Gradle - run: ./gradlew build - - uses: actions/upload-artifact@v2 - with: - name: lsd-distributed-generator-ui - path: service/build/libs - - uses: codecov/codecov-action@v1 - with: - files: service/build/reports/jacoco/test/jacocoTestReport.xml - verbose: true diff --git a/README.md b/README.md index 1fdcacc..80fe816 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![semantic-release](https://img.shields.io/badge/semantic-release-e10079.svg?logo=semantic-release)](https://github.com/semantic-release/semantic-release) + # lsd-distributed-generator-ui ![GitHub](https://img.shields.io/github/license/lsd-consulting/lsd-distributed-generator-ui) [![Build](https://github.com/lsd-consulting/lsd-distributed-generator-ui/actions/workflows/macos-build.yml/badge.svg)](https://github.com/lsd-consulting/lsd-distributed-generator-ui/actions/workflows/macos-build.yml) diff --git a/build.gradle.kts b/build.gradle.kts index c8a2204..635b501 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,11 +25,10 @@ tasks.create("installGitHooks") { } } +// TODO Not sure all this is needed here or only in the file one level below group = "io.github.lsd-consulting" -version = gitVersion().replaceAll("^v", "") - -rootProject.version = scmVersion.version -println("Build Version = ${project.version}") +val gitVersion: groovy.lang.Closure by extra +version = gitVersion().replace(Regex("^v"), "") configurations { compileOnly { diff --git a/release.sh b/release.sh deleted file mode 100755 index 5ac3e20..0000000 --- a/release.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e - -# To bump the minor version use: -# ./gradlew marNextVersion -Prelease.incrementer=incrementMinor - -# Bump patch version for release version by default -./gradlew release - -# Publish to sonatype and then release to maven central -./gradlew publishToSonatype closeAndReleaseStagingRepository diff --git a/service/build.gradle.kts b/service/build.gradle.kts index 484d789..df0363a 100644 --- a/service/build.gradle.kts +++ b/service/build.gradle.kts @@ -8,7 +8,7 @@ plugins { id("java-library") id("signing") id("jacoco") - id("pl.allegro.tech.build.axion-release") + id("com.palantir.git-version") } ////////////////////////// @@ -155,7 +155,8 @@ publishing { create("mavenJava") { groupId = "$group" artifactId = "lsd-distributed-generator-ui" - version = scmVersion.version + val gitVersion: groovy.lang.Closure by extra + version = gitVersion().replace(Regex("^v"), "") artifact(project.tasks.bootJar) @@ -202,5 +203,14 @@ publishing { } signing { - sign(publishing.publications["mavenJava"]) + project.findProperty("signingKey")?.let { + // Use in-memory ascii-armored keys + val signingKey: String? by project + val signingPassword: String? by project + useInMemoryPgpKeys(signingKey, signingPassword) + sign(tasks["stuffZip"]) + sign(publishing.publications["mavenJava"]) + } ?: run { + sign(publishing.publications["mavenJava"]) + } } From 0a0ac92fcceb2b550946e3d9f57422f56535dcb0 Mon Sep 17 00:00:00 2001 From: Lukasz Gryzbon Date: Sun, 16 Jan 2022 10:35:47 +0000 Subject: [PATCH 3/4] ci: #4 Update Gradle to 7.3.3 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a2..2e6e589 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From b238c9088f69ccfecae1d7b57edb670194e430db Mon Sep 17 00:00:00 2001 From: "lukasz.gryzbon" Date: Sun, 16 Jan 2022 10:57:27 +0000 Subject: [PATCH 4/4] ci: #4 Small improvements - removing duplications --- build.gradle.kts | 4 ++-- service/build.gradle.kts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 635b501..c6937b8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,9 +26,9 @@ tasks.create("installGitHooks") { } // TODO Not sure all this is needed here or only in the file one level below -group = "io.github.lsd-consulting" val gitVersion: groovy.lang.Closure by extra version = gitVersion().replace(Regex("^v"), "") +group = "io.github.lsd-consulting" configurations { compileOnly { @@ -37,7 +37,7 @@ configurations { } allprojects { - group = "io.github.lsd-consulting" + group = rootProject.group version = rootProject.version apply(plugin = "io.spring.dependency-management") diff --git a/service/build.gradle.kts b/service/build.gradle.kts index df0363a..55856aa 100644 --- a/service/build.gradle.kts +++ b/service/build.gradle.kts @@ -155,8 +155,8 @@ publishing { create("mavenJava") { groupId = "$group" artifactId = "lsd-distributed-generator-ui" - val gitVersion: groovy.lang.Closure by extra - version = gitVersion().replace(Regex("^v"), "") + version = rootProject.version.toString() + artifact(project.tasks.bootJar)