Skip to content

Commit

Permalink
Update and cleanup build and CI workflows (#115)
Browse files Browse the repository at this point in the history
* build: Update and cleanup build

* ci: Update and cleanup Github workflows

* chore(build): Cleanup

* ci: Add build cache auth env vars
  • Loading branch information
matrei authored Oct 11, 2024
1 parent d898904 commit 0f87c54
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 155 deletions.
69 changes: 30 additions & 39 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Java CI
name: "Java CI"
on:
push:
branches:
Expand All @@ -11,52 +11,43 @@ jobs:
build:
runs-on: ubuntu-latest
env:
WORKSPACE: ${{ github.workspace }}
GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8
GIT_USER_NAME: grails-build
GIT_USER_EMAIL: [email protected]
steps:
- uses: actions/checkout@v4
- name: Set up JDK
- name: "📥 Checkout repository"
uses: actions/checkout@v4
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: 'liberica'
java-version: '11'
- name: Run Build
uses: gradle/gradle-build-action@v3
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
with:
arguments: build -Dgeb.env=chromeHeadless
publish:
if: github.event_name == 'push'
needs: ['build']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
distribution: liberica
java-version: 11
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
distribution: 'liberica'
java-version: '11'
- name: Publish Artifacts (repo.grails.org)
id: publish
uses: gradle/gradle-build-action@v3
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "🔨 Run Build"
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: ./gradlew build
- name: "📤 Publish Snapshot to repo.grails.org"
if: success() && github.event_name == 'push'
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
with:
arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish
- name: Publish to Github Pages
if: success()
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: >
./gradlew
-Dorg.gradle.internal.publish.checksums.insecure=true
publish
- name: "📖 Publish Groovydoc to Github Pages"
if: success() && github.event_name == 'push'
uses: micronaut-projects/github-pages-deploy-action@grails
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
BRANCH: gh-pages
FOLDER: build/docs
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }}
COMMIT_NAME: ${{ env.GIT_USER_NAME }}
DOC_FOLDER: gh-pages
COMMIT_EMAIL: [email protected]
COMMIT_NAME: Puneet Behl
FOLDER: build/docs
GH_TOKEN: ${{ secrets.GH_TOKEN }}
37 changes: 3 additions & 34 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Changelog
name: "Changelog"
on:
issues:
types: [closed,reopened]
Expand All @@ -11,38 +11,7 @@ jobs:
release_notes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- 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@v6
if: steps.check_release_drafter.outputs.has_release_drafter == 'true'
- name: "📝 Update release notes 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,63 +1,61 @@
name: Release
name: "Release"
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['11']
env:
GIT_USER_NAME: puneetbehl
GIT_USER_EMAIL: behlp@objectcomputing.com
GIT_USER_NAME: grails-build
GIT_USER_EMAIL: [email protected].com
steps:
- name: Checkout repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set up JDK
- 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
distribution: liberica
java-version: 11
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "🔢 Set the current release version"
id: release_version
run: echo ::set-output name=release_version::${GITHUB_REF:11}
- name: Run pre-release
run: echo "release_version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
- name: "⚙️ Run pre-release"
uses: micronaut-projects/github-actions/pre-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate secring file
- name: "🔐 Generate secring file"
env:
SECRING_FILE: ${{ secrets.SECRING_FILE }}
run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg
- name: Publish to Sonatype OSSRH
- name: "📤 Publish to Sonatype"
id: publish
uses: gradle/gradle-build-action@v3
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_NEXUS_URL: ${{ secrets.SONATYPE_NEXUS_URL }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
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: Run Assemble
run: >
./gradlew
-Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
publishToSonatype
closeAndReleaseSonatypeStagingRepository
- name: "📦 Run Assemble"
id: assemble
if: steps.publish.outcome == 'success'
uses: gradle/gradle-build-action@v3
with:
arguments: assemble
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
- name: Export Gradle Properties
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: ./gradlew assemble
- name: "✈️ Export Gradle Properties"
uses: micronaut-projects/github-actions/export-gradle-properties@master
- name: Publish to Github Pages
- name: "📖 Publish Groovydoc to Github Pages"
if: steps.assemble.outcome == 'success'
uses: micronaut-projects/github-pages-deploy-action@master
env:
Expand All @@ -67,13 +65,9 @@ jobs:
BRANCH: gh-pages
FOLDER: build/docs
DOC_FOLDER: gh-pages
COMMIT_EMAIL: [email protected]
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: success()
uses: micronaut-projects/github-actions/post-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
env:
SNAPSHOT_SUFFIX: -SNAPSHOT
uses: micronaut-projects/github-actions/post-release@master
26 changes: 13 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'org.grails.grails-plugin'
id 'org.grails.grails-gsp'
id 'org.grails.internal.grails-plugin-publish'
}

version project.projectVersion
group "org.grails.plugins"
version = project.projectVersion
group = 'org.grails.plugins'

repositories {
maven { url "https://repo.grails.org/grails/core" }
maven { url = 'https://repo.grails.org/grails/core' }
}

sourceCompatibility = 1.11
targetCompatibility = 1.11
java {
sourceCompatibility = JavaVersion.VERSION_11
}

dependencyManagement {
imports {
Expand All @@ -25,18 +24,19 @@ dependencyManagement {
}

dependencies {
compileOnly "org.codehaus.groovy:groovy"
compileOnly "org.grails:grails-plugin-rest"
api "org.grails.plugins:fields:$fieldsVersion"

compileOnly 'org.codehaus.groovy:groovy'
compileOnly 'org.grails:grails-plugin-rest'
}

grailsPublish {
userOrg = "grails"
userOrg = 'grails'
githubSlug = 'grails/scaffolding'
license {
name = 'Apache-2.0'
}
title = "Grails Scaffolding Plugin"
desc = "Provides scaffolding for Grails applications"
developers = [puneetbehl: "Puneet Behl"]
title = 'Grails Scaffolding Plugin'
desc = 'Provides scaffolding for Grails applications'
developers = [puneetbehl: 'Puneet Behl']
}
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repositories {
mavenCentral()
maven { url "https://repo.grails.org/grails/core/" }
maven { url = 'https://repo.grails.org/grails/core' }
}
dependencies {
implementation("org.grails:grails-gradle-plugin:6.1.1")
runtimeOnly 'org.grails:grails-gradle-plugin:6.1.1'
}
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ groovyVersion=3.0.22

org.gradle.caching=true
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1536M -XX:MaxMetaspaceSize=512M
org.gradle.parallel=true
46 changes: 21 additions & 25 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}

plugins {
id "com.gradle.enterprise" version "3.17.1"
id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.13'
id 'com.gradle.develocity' version '3.18.1'
id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2'
}

gradleEnterprise {
def isCI = System.getenv('CI') != null
def isLocal = !isCI
def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null
def isBuildCacheAuthenticated =
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null &&
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null

develocity {
server = 'https://ge.grails.org'
buildScan {
publishAlways()
publishIfAuthenticated()
uploadInBackground = System.getenv("CI") == null
capture {
taskInputFiles = true
}
publishing.onlyIf { isAuthenticated }
uploadInBackground = isLocal
}
}

buildCache {
local { enabled = System.getenv('CI') != 'true' }
remote(HttpBuildCache) {
push = System.getenv('CI') == 'true'
local { enabled = isLocal }
remote(develocity.buildCache) {
push = isCI && isBuildCacheAuthenticated
enabled = true
url = 'https://ge.grails.org/cache/'
credentials {
username = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER')
password = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY')
}
}}
usernameAndPassword(
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: '',
System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: ''
)
}
}

rootProject.name='scaffolding'

0 comments on commit 0f87c54

Please sign in to comment.