diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d11126c218..57d023d308 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,12 +78,21 @@ jobs: exit 1 fi + #Deployment - name: Deploy if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' + env: + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVENCENTRAL_SIGNINGKEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVENCENTRAL_SIGNINGPASS }} + ORG_GRADLE_PROJECT_user: ${{ secrets.MAVENCENTRAL_USER }} + ORG_GRADLE_PROJECT_password: ${{ secrets.MAVENCENTRAL_PASS }} run: | - ./gradlew publish\ - -Puser=${{ secrets.MAVENCENTRAL_USER }} \ - -Ppassword=${{ secrets.MAVENCENTRAL_PASS }} \ - -Psigning.keyId=${{ secrets.MAVENCENTRAL_SIGNINGKEYID }} \ - -Psigning.password=${{ secrets.MAVENCENTRAL_SIGNINGPASS }} \ - -Psigning.secretKeyRingFile=${{ secrets.MAVENCENTRAL_SIGNINGKEY }} + if [ "${GITHUB_REF}" == "refs/heads/main" ]; then + currentVersion=$(./gradlew -q currentVersion) + else + currentVersion=$(./gradlew -q devVersion) + fi + + echo "currentVersion=$currentVersion" + + ./gradlew publish -PdeployVersion=$currentVersion diff --git a/CHANGELOG.md b/CHANGELOG.md index c5e8f10c65..f8795209c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added weatherData HowTo for Copernicus ERA5 data [#967](https://github.com/ie3-institute/simona/issues/967) - Add some quote to 'printGoodbye' [#997](https://github.com/ie3-institute/simona/issues/997) - Add unapply method for ThermalHouseResults [#934](https://github.com/ie3-institute/simona/issues/934) +- Implemented GitHub Actions Pipeline [#939](https://github.com/ie3-institute/simona/issues/939) - Added `ApparentPower` to differentiate between different power types [#794](https://github.com/ie3-institute/simona/issues/794) - Update/enhance config documentation [#1013](https://github.com/ie3-institute/simona/issues/1013) - Create `CITATION.cff` [#1035](https://github.com/ie3-institute/simona/issues/1035) @@ -149,6 +150,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix initialisation freezing on empty primary data [#981](https://github.com/ie3-institute/simona/issues/981) - Shallow fetch in CI [#1041](https://github.com/ie3-institute/simona/issues/1041) - Correct wrong use of term "wall clock time" [#727](https://github.com/ie3-institute/simona/issues/727) +- Fixed Deployment of `simona` to `Maven Central` in new GHA Pipeline [#1029](https://github.com/ie3-institute/simona/issues/1029) ## [3.0.0] - 2023-08-07 diff --git a/build.gradle b/build.gradle index 54c2bf0b95..bfb0d52427 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ apply from: scriptsLocation + 'scoverage.gradle' // scoverage scala code coverag apply from: scriptsLocation + 'deploy.gradle' apply from: scriptsLocation + 'semVer.gradle' apply from: scriptsLocation + 'mavenCentralPublish.gradle' -apply from: scriptsLocation + 'branchName.gradle' +apply from: scriptsLocation + 'branchName.gradle' // checks naming scheme of branches configurations { scalaCompilerPlugin diff --git a/gradle/scripts/branchName.gradle b/gradle/scripts/branchName.gradle index b1357b16f1..99ba2c5097 100644 --- a/gradle/scripts/branchName.gradle +++ b/gradle/scripts/branchName.gradle @@ -18,7 +18,7 @@ tasks.register('checkBranchName') { def isValid = patterns.any { pattern -> branchName ==~ pattern } if (!isValid) { - throw new GradleException("Error: Check Branch name format (e.g., ps/#1337-FeatureName).") + throw new GradleException("Error: Check Branch name format (e.g., ps/#1337-FeatureName). Current branch name is $branchName.") } println "Branch name is $branchName" diff --git a/gradle/scripts/mavenCentralPublish.gradle b/gradle/scripts/mavenCentralPublish.gradle index c006100df7..9003d01c4c 100644 --- a/gradle/scripts/mavenCentralPublish.gradle +++ b/gradle/scripts/mavenCentralPublish.gradle @@ -10,17 +10,11 @@ task javadocJar(type: Jar, dependsOn: javadoc) { from javadoc.destinationDir } - if (project.hasProperty('user') && project.hasProperty('password') && project.hasProperty('deployVersion')) { // snapshot version differs from normal version String versionString = project.getProperty('deployVersion') - signing { - required { !versionString.endsWith('SNAPSHOT') } - if (required) - sign(publishing.publications) - } publishing { publications { @@ -87,9 +81,15 @@ if (project.hasProperty('user') && project.hasProperty('password') && project.ha } } } + signing { + useInMemoryPgpKeys( + findProperty('signingKey'), + findProperty('signingPassword') + ) + sign publishing.publications.mavenJava + } } - model { tasks.generatePomFileForMavenJavaPublication { destination = file("$buildDir/generated-pom.xml") @@ -98,7 +98,6 @@ if (project.hasProperty('user') && project.hasProperty('password') && project.ha } def removeTestDependenciesFromPom(pom) { - pom.withXml { def root = asNode() // eliminate test-scoped dependencies (no need in maven central POMs) diff --git a/gradle/scripts/semVer.gradle b/gradle/scripts/semVer.gradle index ec680a487b..c330089323 100644 --- a/gradle/scripts/semVer.gradle +++ b/gradle/scripts/semVer.gradle @@ -1,13 +1,13 @@ // tasks for semantic versioning using semver-gradle https://github.com/ethauvin/semver-gradle -task currentVersion { - doFirst{ +tasks.register('currentVersion') { + doFirst { println semver.semver } } -task devVersion { - doFirst{ +tasks.register('devVersion') { + doFirst { println "${semver.major}.${semver.minor}-SNAPSHOT" } }