release: v0.12.5 #276
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gradle Build | |
on: | |
push: | |
branches: | |
- master | |
- release/** | |
- feature/** | |
- bugfix/** | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
build: | |
env: | |
TERM: dumb | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Disabling shallow clone is recommended for improving relevancy of reporting | |
fetch-depth: 0 | |
- name: Get version from commit message | |
id: commitversion | |
run: | | |
commit_message="${{github.event.head_commit.message}}" | |
if [[ $commit_message == release:* && $commit_message =~ ([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.]+)?) ]]; then | |
release_version="v${BASH_REMATCH[1]}" | |
echo "release_version=$release_version" >> $GITHUB_OUTPUT | |
echo "is_release=True" >> $GITHUB_OUTPUT | |
git tag ${release_version} | |
else | |
echo "is_release=False" >> $GITHUB_OUTPUT | |
fi | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 8 | |
distribution: adopt | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradlew-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | |
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 | |
- run: git status | |
- name: Publish gradle plugin | |
if: steps.commitversion.outputs.is_release == 'True' | |
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: Create GitHub release | |
if: steps.commitversion.outputs.is_release == 'True' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
tag="${{ steps.commitversion.outputs.release_version }}" | |
git push origin $tag | |
version=$(./gradlew -q printVersion) | |
./gradlew -q printChangeLog | gh release create $tag -t "Git Semver Plugin $version" -F - |