From cf2f5da76afa2b331a5281e705660b58cda5ebe1 Mon Sep 17 00:00:00 2001 From: Chris Bono Date: Sat, 9 Jul 2022 14:55:07 -0500 Subject: [PATCH] Add initial CI workflow * Will build and publish snapshot to Artifactory on push to main --- .github/workflows/ci-pr.yml | 23 ++++++-- .github/workflows/ci.yml | 54 +++++++++++++++++++ build.gradle | 17 +++++- .../publish-artifactory.gradle | 15 ++++-- settings.gradle | 2 +- 5 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/ci.yml rename publish-maven.gradle => gradle/publish-artifactory.gradle (77%) diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 2fe6dee9..334da2cd 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -4,6 +4,10 @@ on: pull_request: branches: [ main ] +env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + jobs: build: if: github.repository == 'spring-projects-experimental/spring-pulsar' @@ -15,11 +19,22 @@ jobs: uses: actions/setup-java@v2 with: java-version: 17 - distribution: 'temurin' - - name: Run Gradle build + distribution: temurin + - name: Setup Gradle user name + run: | + mkdir -p ~/.gradle + echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties + - name: Setup Gradle uses: gradle/gradle-build-action@v2 - with: - arguments: clean build + env: + GRADLE_USER_HOME: ~/.gradle + - name: Run Gradle build + # env: + # GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }} + # GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }} + # GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} + run: | + ./gradlew clean build -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" - name: Capture Test Results if: failure() uses: actions/upload-artifact@v3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..4eb1db6a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + branches: + - main + paths-ignore: + - '.github/**' + workflow_dispatch: + +env: +# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} +# GRADLE_ENTERPRISE_CACHE_USER: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }} +# GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }} +# GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} + COMMIT_OWNER: ${{ github.event.pusher.name }} + COMMIT_SHA: ${{ github.sha }} + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + +jobs: + build: + if: github.repository == 'spring-projects-experimental/spring-pulsar' + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Set up Java 17 + uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: temurin + - name: Setup Gradle user name + run: | + mkdir -p ~/.gradle + echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + env: + GRADLE_USER_HOME: ~/.gradle + - name: Run Gradle build +# env: +# GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }} +# GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }} +# GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} + run: | + ./gradlew clean build --refresh-dependencies --stacktrace -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" + - name: Deploy artifacts +# env: +# GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }} +# GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }} +# GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} + run: | + ./gradlew artifactoryPublish --stacktrace -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" diff --git a/build.gradle b/build.gradle index 301a5836..6310300b 100644 --- a/build.gradle +++ b/build.gradle @@ -109,7 +109,7 @@ allprojects { subprojects { subproject -> apply plugin: 'java-library' apply plugin: 'java' - apply from: "${rootProject.projectDir}/publish-maven.gradle" + apply from: "${rootProject.projectDir}/gradle/publish-artifactory.gradle" apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'jacoco' @@ -361,4 +361,19 @@ sonarqube { } } +// skip publishing the root module +artifactoryPublish.skip = true +artifactory { + contextUrl = 'https://repo.spring.io' + publish { + repository { + repoKey = 'libs-snapshot-local' + username = "${artifactoryUsername}" + password = "${artifactoryPassword}" + } + defaults { + publications('mavenJava') + } + } +} diff --git a/publish-maven.gradle b/gradle/publish-artifactory.gradle similarity index 77% rename from publish-maven.gradle rename to gradle/publish-artifactory.gradle index 28af4270..a2bbdf08 100644 --- a/publish-maven.gradle +++ b/gradle/publish-artifactory.gradle @@ -26,9 +26,18 @@ publishing { connection = linkScmConnection developerConnection = linkScmDevConnection } -// developers { -// -// } + developers { + developer { + id = "schacko" + name = "Soby Chacko" + email = "chackos@vmware.com" + } + developer { + id = "onobc" + name = "Chris Bono" + email = "cbono@vmware.com" + } + } issueManagement { system = 'GitHub' url = linkIssue diff --git a/settings.gradle b/settings.gradle index ea9e2618..4b6e4065 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,7 +6,7 @@ pluginManagement { } plugins { - id 'com.gradle.enterprise' version '3.5' + id "com.gradle.enterprise" version "3.5" id "io.spring.ge.conventions" version "0.0.7" }