From 478ad7161c2318d852aa7b53af42632514811d74 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Mon, 5 Jul 2021 09:03:22 +0100 Subject: [PATCH] Publish from workflows --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++++++++ build.gradle | 24 ++++++++++++++++++----- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87552e03..bee86e9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,3 +38,44 @@ jobs: with: name: buildlogs path: build/buildlogs.tar.gz + + # if build job succeed, build without tests and publish + publish: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - uses: jfrog/setup-jfrog-cli@v1 + with: + version: 1.50.0 + env: + JF_ARTIFACTORY_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} + + # setup non persistent config for jfrog gradle to use server defined in + # secret which points via virtual repo into spring local repo. + # modify default build name and number as we don't like how those + # gets used from action defaults. + - name: Configure JFrog Cli + run: | + jfrog rt gradlec \ + --use-wrapper \ + --deploy-ivy-desc=false \ + --server-id-resolve=repo.spring.io \ + --server-id-deploy=repo.spring.io \ + --repo-resolve=snapshot \ + --repo-deploy=snapshot + echo JFROG_CLI_BUILD_NAME=spring-statemachine-22x >> $GITHUB_ENV + echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV + + # as we already tested just build and publish + - name: Build and Publish Snapshot + run: | + jfrog rt gradle clean build -x test artifactoryPublish + + # publish build info so that we can see it in artifactory "builds" + - name: Publish Build Info + run: | + jfrog rt build-publish diff --git a/build.gradle b/build.gradle index 21f48e04..e566d647 100644 --- a/build.gradle +++ b/build.gradle @@ -499,6 +499,20 @@ project('spring-statemachine-samples-common') { configure(rootProject) { description = 'Spring State Machine' + pluginManager.withPlugin('com.jfrog.artifactory') { + artifactory { + publish { + defaults { + properties { + archives '*:*:*:*@zip', 'zip.deployed': false, 'zip.name': 'spring-statemachine', 'zip.displayname': 'Spring Statemachine' + archives '*:*:*:docs@zip', 'zip.type': 'docs' + archives '*:*:*:dist@zip', 'zip.type': 'dist' + } + } + } + } + } + dependencies { // just used to get version into docs compile "org.springframework:spring-core" @@ -701,13 +715,13 @@ configure(rootProject) { def file = new File('gradle.properties') properties.load(file.newDataInputStream()) def currentVersion = properties.getProperty('version') - if (currentVersion.indexOf('-SNAPSHOT') < 0) { + if (currentVersion.indexOf('.BUILD-SNAPSHOT') < 0) { throw new GradleException('Version is a non SNAPSHOT version') } else { def (major, minor, patch) = version.tokenize('.') - patch = patch.replace('-SNAPSHOT', '') + patch = patch.replace('.BUILD-SNAPSHOT', '') patch = String.valueOf(patch.toInteger() + 1) - def nextVersion = major + '.' + minor + '.' + patch + '-SNAPSHOT' + def nextVersion = major + '.' + minor + '.' + patch + '.BUILD-SNAPSHOT' properties.setProperty('version', nextVersion) properties.store(file.newWriter(), null) } @@ -725,7 +739,7 @@ configure(rootProject) { properties.load(file.newDataInputStream()) def currentVersion = properties.getProperty('version') if (currentVersion.indexOf('.BUILD-SNAPSHOT') > 0) { - def nextVersion = currentVersion - '.BUILD-SNAPSHOT' + '-' + postfix + def nextVersion = currentVersion - '.BUILD-SNAPSHOT' + '.' + postfix properties.setProperty('version', nextVersion) properties.store(file.newWriter(), null) } else { @@ -741,7 +755,7 @@ configure(rootProject) { properties.load(file.newDataInputStream()) def currentVersion = properties.getProperty('version') if (currentVersion.indexOf('.BUILD-SNAPSHOT') > 0) { - def nextVersion = currentVersion - '.BUILD-SNAPSHOT' + def nextVersion = currentVersion - '.BUILD-SNAPSHOT' + '.RELEASE' properties.setProperty('version', nextVersion) properties.store(file.newWriter(), null) } else {