Skip to content

Commit

Permalink
Refactor build and release pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermocalvo committed Feb 15, 2024
1 parent 18f154d commit 760a1a4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
45 changes: 25 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
build:

name: Build on JDK${{ matrix.jdk }}
name: Build ${{ github.ref_name }} on JDK${{ matrix.jdk }}
runs-on: ubuntu-latest

strategy:
Expand All @@ -27,14 +27,14 @@ jobs:
# SHALLOW CLONE
# ================================
- name: Shallow clone
if: ${{ matrix.jdk != 21 }}
if: ${{ matrix.jdk != 21 || github.event_name != 'push' }}
uses: actions/checkout@v4

# ================================
# CHECKOUT
# ================================
- name: Checkout git branch
if: ${{ matrix.jdk == 21 }}
if: ${{ matrix.jdk == 21 && github.event_name == 'push' }}
uses: actions/checkout@v4
with:
# Fetch all history for all tags and branches (recommended by SonarQube)
Expand All @@ -50,57 +50,62 @@ jobs:
java-package: jdk
java-version: ${{ matrix.jdk }}

# ================================
# CACHE SONARCLOUD PACKAGES
# ================================
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
key: ${{ runner.os }}-sonar
path: |
~/.sonar/cache
restore-keys: |
${{ runner.os }}-sonar
# ================================
# SETUP GRADLE
# ================================
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}
build-scan-publish: true
build-scan-terms-of-service-url: https://gradle.com/terms-of-service
build-scan-terms-of-service-agree: yes
cache-read-only: ${{ github.event_name != 'push' }}

# ================================
# BUILD
# ================================
- name: Build
uses: gradle/actions/setup-gradle@v3
with:
arguments: build -x check --info --scan
arguments: build -x check --info

# ================================
# CHECK
# ================================
- name: Check
uses: gradle/actions/setup-gradle@v3
with:
arguments: check --info --scan
arguments: check --info

# ================================
# COMPATIBILITY REPORT
# ================================
- name: Compatibility report
if: ${{ matrix.jdk == 21 }}
run: cat ./api-compatibility/build/report.txt >> $GITHUB_STEP_SUMMARY

# ================================
# CACHE SONARCLOUD PACKAGES
# ================================
- name: Cache SonarCloud packages
if: ${{ matrix.jdk == 21 && github.event_name == 'push' }}
uses: actions/cache@v4
with:
key: ${{ runner.os }}-sonar
path: |
~/.sonar/cache
restore-keys: |
${{ runner.os }}-sonar
# ================================
# ANALYZE
# ================================
- name: Analyze
if: ${{ matrix.jdk == 21 }}
if: ${{ matrix.jdk == 21 && github.event_name == 'push' }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
SONAR_ORGANIZATION: leakyabstractions
uses: gradle/actions/setup-gradle@v3
with:
arguments: sonarqube --info --scan
arguments: sonarqube --info
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ on:
jobs:
build:

name: Publish
name: Publish release version ${{ github.ref_name }}
runs-on: ubuntu-latest

steps:

# ================================
# CHECKOUT
# SHALLOW CLONE
# ================================
- name: Checkout git tag
- name: Shallow clone
uses: actions/checkout@v4

# ================================
Expand Down Expand Up @@ -50,4 +50,7 @@ jobs:
ORG_GRADLE_PROJECT_sonatypeStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
uses: gradle/actions/setup-gradle@v3
with:
arguments: publish -Prelease --info --scan
build-scan-publish: true
build-scan-terms-of-service-url: https://gradle.com/terms-of-service
build-scan-terms-of-service-agree: yes
arguments: publish -Prelease --info
7 changes: 0 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePass
}
}

if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}

/**
* Print project property by key
* - Usage: `./gradlew -q printProperty -Pkey=description`
Expand Down

0 comments on commit 760a1a4

Please sign in to comment.