From eb1fcfcbe291a972d6cf401c80abe07f8105e8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Mong=C3=A5rd?= Date: Tue, 24 Oct 2023 20:30:46 +0200 Subject: [PATCH] build: Update CI build --- .github/workflows/gradle-push.yml | 92 +++++++++++++++++++------------ 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/.github/workflows/gradle-push.yml b/.github/workflows/gradle-push.yml index 34c53bf..158190c 100644 --- a/.github/workflows/gradle-push.yml +++ b/.github/workflows/gradle-push.yml @@ -17,6 +17,24 @@ jobs: runs-on: ubuntu-latest steps: + - name: Get version from commit message + id: commitversion + run: | + if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then + commit_message="${GITHUB_EVENT_HEAD_COMMIT_MESSAGE}" + if [[ $commit_message == release:* && $commit_message =~ ([0-9]+\.[0-9]+\.[0-9]+(-[\w\.]+)?) ]]; then + commit_version="${BASH_REMATCH[1]}" + informational_version="${BASH_REMATCH[0]}" + echo "commit_version=$commit_version" >> $GITHUB_ENV + echo "informational_version=$informational_version" >> $GITHUB_ENV + echo "is_release=True" >> $GITHUB_ENV + else + echo "commit_version=1.0.0" >> $GITHUB_ENV + echo "informational_version=1.0.0" >> $GITHUB_ENV + echo "is_release=False" >> $GITHUB_ENV + fi + fi + - uses: actions/checkout@v3 with: # Disabling shallow clone is recommended for improving relevancy of reporting @@ -42,47 +60,49 @@ jobs: restore-keys: | ${{ runner.os }}-gradlew- - - name: Compile and check with Gradle - run: ./gradlew check jacocoTestReport - - - name: Publish Test Report - if: failure() - uses: scacap/action-surefire-report@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - report_paths: '**/build/test-results/*/TEST-*.xml' - - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master - env: - JAVA_HOME: "" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: > - -Dsonar.projectKey=jmongard_Git.SemVersioning.Gradle - -Dsonar.organization=jmongard - -Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml - -Dsonar.tests=src/test,src/functionalTest - -Dsonar.sources=src/main - - - name: Build with Gradle - run: ./gradlew build +# - name: Compile and check with Gradle +# run: ./gradlew check jacocoTestReport +# +# - name: Publish Test Report +# if: failure() +# uses: scacap/action-surefire-report@v1 +# with: +# github_token: ${{ secrets.GITHUB_TOKEN }} +# report_paths: '**/build/test-results/*/TEST-*.xml' +# +# - name: SonarCloud Scan +# uses: sonarsource/sonarcloud-github-action@master +# env: +# JAVA_HOME: "" +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} +# with: +# args: > +# -Dsonar.projectKey=jmongard_Git.SemVersioning.Gradle +# -Dsonar.organization=jmongard +# -Dsonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml +# -Dsonar.tests=src/test,src/functionalTest +# -Dsonar.sources=src/main +# +# - name: Build with Gradle +# run: ./gradlew build - run: git status - - - name: Publish gradle plugin - if: startsWith(github.ref, 'refs/tags/v') - run: | - echo "gradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}" > ~/.gradle/gradle.properties - echo "gradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}" >> ~/.gradle/gradle.properties - ./gradlew publishPlugins - +# +# - name: Publish gradle plugin +# if: startsWith(github.ref, 'refs/tags/v') +# run: | +# echo "gradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}" > ~/.gradle/gradle.properties +# echo "gradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}" >> ~/.gradle/gradle.properties + - name: Create GitHub release if: "startsWith(github.ref, 'refs/tags/')" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - tag=$(git describe --tags --abbrev=0) + tag="v${{ steps.commitversion.outputs.informational_version }}" + git tag $tag +# git push origin $tag +# tag=$(git describe --tags --abbrev=0) version=$(./gradlew -q printVersion) - ./gradlew -q printChangeLog | gh release create $tag -t "Git Semver Plugin $version" -F - \ No newline at end of file +# ./gradlew -q printChangeLog | gh release create $tag -t "Git Semver Plugin $version" -F - \ No newline at end of file