Skip to content

Commit

Permalink
ci: enhance workflows with build scans and caching
Browse files Browse the repository at this point in the history
  • Loading branch information
matrei committed Dec 21, 2024
1 parent 0776e4f commit 49fce11
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 104 deletions.
53 changes: 24 additions & 29 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,54 @@ jobs:
WORKSPACE: ${{ github.workspace }}
GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8
steps:
- name: Print Dispatch Information
- name: "📢 Print Dispatch Information"
if: github.event_name == 'workflow_dispatch'
env:
DISPATCH_INFORMATION: ${{ github.event.inputs.message }}
run: echo $DISPATCH_INFORMATION
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
- name: "📥 Checkout repository"
uses: actions/checkout@v4
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: 'liberica'
java-version: ${{ matrix.java }}
- name: Run Tests
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "🏃 Run Tests"
if: github.event_name == 'pull_request'
id: tests
uses: gradle/gradle-build-action@v2
with:
arguments: check
- name: Run Build
run: ./gradlew check
- name: "🔨 Build project"
if: github.event_name == 'push'
id: build
uses: gradle/gradle-build-action@v2
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
with:
arguments: build
- name: Publish Test Report
run: ./gradlew build
- name: "📄 Publish Test Report"
if: steps.build.outcome == 'failure' || steps.tests.outcome == 'failure'
uses: scacap/action-surefire-report@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
report_paths: '**/build/test-results/test/TEST-*.xml'
- name: Publish to repo.grails.org
uses: gradle/gradle-build-action@v2
if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '8'
- name: "📤 Publish Snapshot"
if: steps.build.outcome == 'success' && github.event_name == 'push' && matrix.java == '17'
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
with:
arguments: publish
- name: Generate Documentation
run: publish
- name: "✍️ Generate Documentation"
id: docs
uses: gradle/gradle-build-action@v2
if: success() && github.event_name == 'push' && matrix.java == '8'
with:
arguments: docs
- name: Publish to Github Pages
if: steps.publish.outcome == 'success' && github.event_name == 'push' && matrix.java == '8'
if: success() && github.event_name == 'push' && matrix.java == '17'
run: ./gradlew docs
- name: "📤 Publish to Github Pages"
if: steps.publish.outcome == 'success' && github.event_name == 'push' && matrix.java == '17'
uses: micronaut-projects/github-pages-deploy-action@grails
env:
TARGET_REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
BRANCH: gh-pages
FOLDER: build/docs
DOC_FOLDER: gh-pages
COMMIT_EMAIL: behlp@objectcomputing.com
COMMIT_NAME: Puneet Behl
COMMIT_EMAIL: grails-build@users.noreply.github.com
COMMIT_NAME: grails-build
45 changes: 10 additions & 35 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,22 @@
name: Changelog
name: "Release Drafter"
on:
issues:
types: [closed,reopened]
push:
branches:
- '[4-9]+.[0-9]+.x'
pull_request:
types: [opened, reopened, synchronize]
pull_request_target:
types: [opened, reopened, synchronize]
workflow_dispatch:
jobs:
release_notes:
update_release_draft:
permissions:
contents: read # limit to read access
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if it has release drafter config file
id: check_release_drafter
run: |
has_release_drafter=$([ -f .github/release-drafter.yml ] && echo "true" || echo "false")
echo ::set-output name=has_release_drafter::${has_release_drafter}
- name: Extract branch name
id: extract_branch
run: echo ::set-output name=value::${GITHUB_REF:11}
# If it has release drafter:
- uses: release-drafter/release-drafter@v5.24.0
if: steps.check_release_drafter.outputs.has_release_drafter == 'true'
- name: "📝 Update Release Draft"
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
commitish: ${{ steps.extract_branch.outputs.value }}
# Otherwise:
- name: Export Gradle Properties
if: steps.check_release_drafter.outputs.has_release_drafter == 'false'
uses: micronaut-projects/github-actions/export-gradle-properties@master
- uses: micronaut-projects/github-actions/release-notes@master
if: steps.check_release_drafter.outputs.has_release_drafter == 'false'
id: release_notes
with:
token: ${{ secrets.GH_TOKEN }}
- uses: ncipollo/release-action@v1
if: steps.check_release_drafter.outputs.has_release_drafter == 'false' && steps.release_notes.outputs.generated_changelog == 'true'
with:
allowUpdates: true
commit: ${{ steps.release_notes.outputs.current_branch }}
draft: true
name: ${{ env.title }} ${{ steps.release_notes.outputs.next_version }}
tag: v${{ steps.release_notes.outputs.next_version }}
bodyFile: CHANGELOG.md
token: ${{ secrets.GH_TOKEN }}
74 changes: 34 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
name: Release
name: "Release"
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['17']
env:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: behlp@objectcomputing.com
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: 'grails-build@users.noreply.github.com'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK
uses: actions/setup-java@v3
- name: "📥 Checkout repository"
uses: actions/checkout@v4
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: 'liberica'
java-version: ${{ matrix.java }}
- name: Set the current release version
id: release_version
run: echo ::set-output name=release_version::${GITHUB_REF:11}
- name: Run pre-release
uses: micronaut-projects/github-actions/pre-release@master
java-version: '17'
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate secring file
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "📝 Store the current release version"
id: release_version
run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
- name: "⚙ Run pre-release"
uses: grails/github-actions/pre-release@main
- name: "🔐 Generate key file for artifact signing"
env:
SECRING_FILE: ${{ secrets.SECRING_FILE }}
run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg
- name: Publish to Sonatype OSSRH
- name: "📤 Publish release artifacts to Sonatype"
id: publish
uses: gradle/gradle-build-action@v2
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
Expand All @@ -44,33 +39,32 @@ jobs:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
SECRING_FILE: ${{ secrets.SECRING_FILE }}
with:
arguments: -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Publish Documentation
run: >
./gradlew
-Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
publishToSonatype
closeAndReleaseSonatypeStagingRepository
- name: "✍️ Generate Documentation"
id: docs
if: steps.publish.outcome == 'success'
uses: gradle/gradle-build-action@v2
with:
arguments: docs
- name: Export Gradle Properties
uses: micronaut-projects/github-actions/export-gradle-properties@master
- name: Publish to Github Pages
run: ./gradlew docs
- name: "Export Gradle Properties"
uses: grails/github-actions/export-gradle-properties@main
- name: "📤 Publish to Github Pages"
if: steps.docs.outcome == 'success'
uses: micronaut-projects/github-pages-deploy-action@grails
uses: grails/github-pages-deploy-action@grails
env:
BETA: ${{ contains(steps.release_version.outputs.release_version, 'M') || contains(steps.release_version.outputs.release_version, 'RC') }}
TARGET_REPOSITORY: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/build/docs
DOC_FOLDER: gh-pages
COMMIT_EMAIL: behlp@objectcomputing.com
COMMIT_NAME: Puneet Behl
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }}
COMMIT_NAME: ${{ env.GIT_USER_NAME }}
VERSION: ${{ steps.release_version.outputs.release_version }}
- name: Run post-release
- name: "⚙️ Run post-release"
if: steps.publish.outcome == 'success' && steps.docs.outcome == 'success' && success()
uses: micronaut-projects/github-actions/post-release@master
uses: grails/github-actions/post-release@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
env:
SNAPSHOT_SUFFIX: -SNAPSHOT
token: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
plugins {
id 'com.gradle.develocity' version '3.19'
id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2'
}

def isCI = System.getenv('CI') == 'true'

develocity {
server = 'https://ge.grails.org'
buildScan {
publishing.onlyIf { isCI }
uploadInBackground = !isCI
}
}

buildCache {
local { enabled = !isCI }
remote(develocity.buildCache) {
enabled = true
push = isCI && System.getenv('DEVELOCITY_ACCESS_KEY')
}
}

include 'docs'

include 'examples-simple'
Expand Down

0 comments on commit 49fce11

Please sign in to comment.