Skip to content

Commit 4e5a092

Browse files
committed
Add reusable workflows
* Add `release-files-spec.json` for promoting build from Artifactory to Maven Central using JFrog * Add `spring-project-init.gradle` for Gradle-based projects when JFrog tasks are performed
1 parent 3f8d86c commit 4e5a092

12 files changed

+676
-0
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
.vscode
3+
.project
4+
.settings

Diff for: release-files-spec.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"files": [
3+
{
4+
"aql": {
5+
"items.find": {
6+
"$and": [
7+
{
8+
"@build.name": "${buildname}",
9+
"@build.number": "${buildnumber}",
10+
"path": {"$match": "org/springframework*"}
11+
},
12+
{
13+
"$or": [
14+
{
15+
"name": {"$match": "*.pom"}
16+
},
17+
{
18+
"name": {"$match": "*.jar"}
19+
},
20+
{
21+
"name": {"$match": "*.module"}
22+
}
23+
]
24+
}
25+
]
26+
}
27+
},
28+
"target": "nexus/"
29+
}
30+
]
31+
}

Diff for: spring-artifactory-gradle-release-staging.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build with Gradle and Stage Release to Artifactory
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
releaseVersion:
7+
description: 'Release version like 3.0.0-M1, 3.1.0-RC1, 3.2.0 etc.'
8+
required: true
9+
type: string
10+
gradleTasks:
11+
description: 'Additional Gradle tasks. The `build` and `artifactoryPublish` are included.'
12+
required: false
13+
type: string
14+
15+
outputs:
16+
buildName:
17+
description: 'Artifactory Build Name'
18+
value: ${{ jobs.staging-to-artifactory-with-gradle.outputs.buildName }}
19+
buildNumber:
20+
description: 'Artifactory Build Number'
21+
value: ${{ jobs.staging-to-artifactory-with-gradle.outputs.buildNumber }}
22+
23+
env:
24+
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
25+
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
26+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
27+
28+
jobs:
29+
staging-to-artifactory-with-gradle:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
buildName: ${{ steps.configure-jfrog.outputs.buildName }}
33+
buildNumber: ${{ steps.configure-jfrog.outputs.buildNumber }}
34+
35+
steps:
36+
37+
- uses: actions/checkout@v4
38+
with:
39+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
40+
show-progress: false
41+
42+
- name: Set up Gradle
43+
uses: spring-io/spring-gradle-build-action@v2
44+
45+
- name: Checkout Common Repo
46+
uses: actions/checkout@v4
47+
with:
48+
repository: artembilan/spring-messaging-build-tools
49+
path: build
50+
show-progress: false
51+
52+
- name: Copy the spring-project-init.gradle
53+
run: rsync build/.github/spring-project-init.gradle ~/.gradle/init.d/
54+
55+
- uses: jfrog/setup-jfrog-cli@v3
56+
with:
57+
version: 2.50.4
58+
env:
59+
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
60+
61+
- name: Configure JFrog Cli
62+
id: configure-jfrog
63+
run: |
64+
jf gradlec \
65+
--use-wrapper \
66+
--repo-deploy libs-staging-local
67+
68+
buildName=${{ github.event.repository.name }}-${{ inputs.releaseVersion }}
69+
echo JFROG_CLI_BUILD_NAME=$buildName >> $GITHUB_ENV
70+
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
71+
echo buildName=$buildName >> $GITHUB_OUTPUT
72+
echo buildNumber=$JFROG_CLI_BUILD_NUMBER >> $GITHUB_OUTPUT
73+
74+
- name: Set Release Version
75+
run: sed -i "s/version=.*/version=${{ inputs.releaseVersion }}/" gradle.properties
76+
77+
- name: Build and Publish
78+
run: |
79+
jf gradle clean build ${{ inputs.gradleTasks }} artifactoryPublish
80+
jf rt build-publish
81+
82+
- name: Tag Release and Next Development Version
83+
run: |
84+
git config --global user.name 'Spring Builds'
85+
git config --global user.email '[email protected]'
86+
git commit -a -m "[artifactory-release] Release version ${{ inputs.releaseVersion }}"
87+
git tag "v${{ inputs.releaseVersion }}"
88+
git push --tags origin
89+
jf gradle nextDevelopmentVersion
90+
git commit -a -m "[artifactory-release] Next development version"
91+
git push origin

Diff for: spring-artifactory-gradle-snapshot.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI Artifactory SNAPSHOT Build for Gradle
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
gradleTasks:
7+
description: 'Additional Gradle tasks. The `build` and `artifactoryPublish` are included.'
8+
required: false
9+
default: 'dist'
10+
type: string
11+
12+
env:
13+
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
14+
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
15+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
16+
17+
jobs:
18+
build-snapshot-with-gradle:
19+
runs-on: ubuntu-latest
20+
name: CI Build SNAPSHOT for ${{ github.ref_name }}
21+
steps:
22+
23+
- uses: actions/checkout@v4
24+
with:
25+
show-progress: false
26+
27+
- name: Set up Gradle
28+
uses: spring-io/spring-gradle-build-action@v2
29+
30+
- name: Checkout Common Repo
31+
uses: actions/checkout@v4
32+
with:
33+
repository: artembilan/spring-messaging-build-tools
34+
path: build
35+
show-progress: false
36+
37+
- name: Copy the spring-project-init.gradle
38+
run: rsync build/.github/spring-project-init.gradle ~/.gradle/init.d/
39+
40+
- uses: jfrog/setup-jfrog-cli@v3
41+
with:
42+
version: 2.50.4
43+
env:
44+
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
45+
46+
- name: Configure JFrog Cli
47+
run: |
48+
jf gradlec \
49+
--use-wrapper \
50+
--repo-deploy libs-snapshot-local
51+
echo JFROG_CLI_BUILD_NAME=${{ github.event.repository.name }}-${{ github.ref_name }} >> $GITHUB_ENV
52+
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
53+
54+
- name: Build and Publish
55+
run: |
56+
jf gradle clean build ${{ inputs.gradleTasks }} artifactoryPublish
57+
jf rt build-publish
58+

Diff for: spring-artifactory-maven-release-staging.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build with Maven and Stage Release to Artifactory
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
releaseVersion:
7+
description: 'Release version like 3.0.0-M1, 3.1.0-RC1, 3.2.0 etc.'
8+
required: true
9+
type: string
10+
mavenArgs:
11+
description: 'Additional mvn command arguments: goals, plugins etc. The `install` is included.'
12+
required: false
13+
type: string
14+
15+
outputs:
16+
buildName:
17+
description: 'Artifactory Build Name'
18+
value: ${{ jobs.staging-to-artifactory-with-maven.outputs.buildName }}
19+
buildNumber:
20+
description: 'Artifactory Build Number'
21+
value: ${{ jobs.staging-to-artifactory-with-maven.outputs.buildNumber }}
22+
23+
jobs:
24+
staging-to-artifactory-with-maven:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
buildName: ${{ steps.configure-jfrog.outputs.buildName }}
28+
buildNumber: ${{ steps.configure-jfrog.outputs.buildNumber }}
29+
steps:
30+
31+
- uses: actions/checkout@v3
32+
with:
33+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
34+
show-progress: false
35+
36+
- name: Set up JDK
37+
uses: actions/setup-java@v3
38+
with:
39+
distribution: adopt
40+
java-version: 17
41+
cache: 'maven'
42+
43+
- uses: jfrog/setup-jfrog-cli@v3
44+
with:
45+
version: 2.50.4
46+
env:
47+
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
48+
49+
- name: Configure JFrog Cli
50+
id: configure-jfrog
51+
run: |
52+
jf mvnc \
53+
--use-wrapper=true \
54+
--repo-resolve-releases=libs-milestone \
55+
--repo-resolve-snapshots=snapshot \
56+
--repo-deploy-releases=libs-staging-local \
57+
--repo-deploy-snapshots=libs-snapshot-local
58+
59+
buildName=${{ github.event.repository.name }}-${{ inputs.releaseVersion }}
60+
echo JFROG_CLI_BUILD_NAME=$buildName >> $GITHUB_ENV
61+
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
62+
echo buildName=$buildName >> $GITHUB_OUTPUT
63+
echo buildNumber=$JFROG_CLI_BUILD_NUMBER >> $GITHUB_OUTPUT
64+
65+
- name: Set Release Version
66+
run: |
67+
./mvnw versions:set -DnewVersion=${{ inputs.releaseVersion }} -DgenerateBackupPoms=false -DprocessAllModules=true -B -ntp
68+
69+
- name: Build and Publish
70+
run: |
71+
jf mvn install -B -ntp ${{ inputs.mavenArgs }}
72+
jf rt build-publish
73+
74+
- name: Capture Test Results
75+
if: failure()
76+
uses: actions/upload-artifact@v3
77+
with:
78+
name: test-results
79+
path: '**/target/surefire-reports/**/*.*'
80+
retention-days: 3
81+
82+
- name: Tag Release and Next Development Version
83+
run: |
84+
git config --global user.name 'Spring Builds'
85+
git config --global user.email '[email protected]'
86+
git commit -a -m "[artifactory-release] Release version ${{ inputs.releaseVersion }}"
87+
git tag "v${{ inputs.releaseVersion }}"
88+
git push --tags origin
89+
./mvnw build-helper:parse-version versions:set \
90+
-DnewVersion='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${{ (contains(inputs.releaseVersion, '-M') || contains(inputs.releaseVersion, '-RC')) && '${parsedVersion.incrementalVersion}' || '${parsedVersion.nextIncrementalVersion}' }}'-SNAPSHOT \
91+
-DgenerateBackupPoms=false -DprocessAllModules=true -B -ntp
92+
git commit -a -m "[artifactory-release] Next development version"
93+
git push origin

Diff for: spring-artifactory-promote-central.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Promote Staged GA release from Artifactory to Maven Central
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
buildName:
7+
description: 'The Artifactory Build Name'
8+
required: true
9+
type: string
10+
buildNumber:
11+
description: 'The Artifactory Build Number'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
release-to-central:
17+
runs-on: ubuntu-latest
18+
steps:
19+
20+
- uses: actions/checkout@v4
21+
with:
22+
repository: artembilan/spring-messaging-build-tools
23+
show-progress: false
24+
25+
- uses: jfrog/setup-jfrog-cli@v3
26+
with:
27+
version: 2.50.4
28+
env:
29+
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
30+
31+
- name: Promote Build
32+
run: jfrog rt build-promote ${{ inputs.buildName }} ${{ inputs.buildNumber }} libs-release-local
33+
34+
# Download released files
35+
- name: Download Release Files
36+
run: |
37+
jfrog rt download \
38+
--spec .github/release-files-spec.json \
39+
--spec-vars "buildname=${{ inputs.buildName }};buildnumber=${{ inputs.buildNumber }}"
40+
41+
# Create checksums, signatures and create staging repo on central and upload
42+
- uses: jvalkeal/[email protected]
43+
id: nexus
44+
with:
45+
url: ${{ secrets.OSSRH_URL }}
46+
username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
47+
password: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
48+
staging-profile-name: ${{ secrets.OSSRH_STAGING_PROFILE_NAME }}
49+
create: true
50+
upload: true
51+
generate-checksums: true
52+
pgp-sign: true
53+
upload-parallel: 10
54+
pgp-sign-passphrase: ${{ secrets.GPG_PASSPHRASE }}
55+
pgp-sign-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
56+
close: true
57+
release: true

Diff for: spring-artifactory-promote-milestone.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Promote Staged Milestone in Artifactory
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
buildName:
7+
description: 'The Artifactory Build Name'
8+
required: true
9+
type: string
10+
buildNumber:
11+
description: 'The Artifactory Build Number'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
promote-milestone-with-jfrog:
17+
runs-on: ubuntu-latest
18+
steps:
19+
20+
- uses: jfrog/setup-jfrog-cli@v3
21+
with:
22+
version: 2.50.4
23+
env:
24+
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
25+
26+
- name: Promote Build
27+
run: jfrog rt build-promote ${{ inputs.buildName }} ${{ inputs.buildNumber }} libs-milestone-local

0 commit comments

Comments
 (0)