Skip to content

Commit d94d0c0

Browse files
committed
Extract reusable GHA workflows
1 parent ff2eff4 commit d94d0c0

11 files changed

+278
-189
lines changed

.github/release-files-spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"@build.name": "${buildname}",
99
"@build.number": "${buildnumber}",
10-
"path": {"$match": "org*"}
10+
"path": {"$match": "org.springframework*"}
1111
},
1212
{
1313
"$or": [

.github/workflows/ci-snapshot.yml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,11 @@ name: CI SNAPSHOT
22

33
on:
44
workflow_dispatch:
5-
workflow_call:
65
push:
76
branches:
87
- main
98

10-
env:
11-
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
12-
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
13-
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
14-
159
jobs:
1610
build_snapshot:
17-
runs-on: ubuntu-latest
18-
if: github.repository_owner == 'spring-projects'
19-
name: CI Build SNAPSHOT for ${{ github.ref_name }}
20-
steps:
21-
22-
- uses: actions/checkout@v3
23-
with:
24-
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
25-
26-
- name: Set up Gradle
27-
uses: spring-io/spring-gradle-build-action@v2
28-
29-
- uses: jfrog/setup-jfrog-cli@v3
30-
with:
31-
version: 2.50.2
32-
env:
33-
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
34-
35-
- name: Configure JFrog Cli
36-
run: |
37-
jf gradlec \
38-
--use-wrapper \
39-
--uses-plugin \
40-
--deploy-ivy-desc=false \
41-
--server-id-resolve repo.spring.io \
42-
--server-id-deploy repo.spring.io \
43-
--repo-resolve snapshot \
44-
--repo-deploy libs-snapshot-local
45-
echo JFROG_CLI_BUILD_NAME=${{ github.event.repository.name }}-${{ github.ref_name }} >> $GITHUB_ENV
46-
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
47-
48-
- name: Build and Publish
49-
run: |
50-
jf gradle build dist artifactoryPublish
51-
jf rt build-publish
52-
11+
uses: .github/workflows/spring-artifactory-gradle-snapshot.yml
12+
secrets: inherit

.github/workflows/pr-build.yml

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,9 @@ name: Pull Request Build
22

33
on:
44
pull_request:
5-
branches: [ main ]
5+
branches:
6+
- main
67

78
jobs:
89
build:
9-
10-
runs-on: ubuntu-latest
11-
12-
steps:
13-
14-
- uses: actions/checkout@v3
15-
16-
- name: Set up JDK
17-
uses: actions/setup-java@v3
18-
with:
19-
distribution: adopt
20-
java-version: 17
21-
cache: gradle
22-
23-
- name: Run Gradle
24-
uses: burrunan/gradle-cache-action@v1
25-
with:
26-
debug: false
27-
concurrent: true
28-
gradle-build-scan-report: false
29-
arguments: check
30-
31-
- name: Capture Test Results
32-
if: failure()
33-
uses: actions/upload-artifact@v3
34-
with:
35-
name: test-results
36-
path: '*/build/reports/tests/**/*.*'
37-
retention-days: 3
10+
uses: .github/workflows/spring-gradle-pull-request-build.yml

.github/workflows/promote-ga-to-central.yml

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,8 @@ on:
1212

1313
jobs:
1414
release_to_central:
15-
runs-on: ubuntu-latest
16-
if: github.repository_owner == 'spring-projects'
17-
steps:
18-
19-
- uses: actions/checkout@v3
20-
with:
21-
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
22-
23-
- uses: jfrog/setup-jfrog-cli@v3
24-
with:
25-
version: 2.50.2
26-
env:
27-
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
28-
29-
- name: Promote Build
30-
run: |
31-
jfrog rt build-promote ${{ inputs.buildName }} ${{ inputs.buildNumber }} libs-release-local
32-
33-
# Download released files
34-
- name: Download Release Files
35-
run: |
36-
jfrog rt download \
37-
--spec .github/release-files-spec.json \
38-
--spec-vars "buildname=${{ inputs.buildName }};buildnumber=${{ inputs.buildNumber }}"
39-
40-
# Create checksums, signatures and create staging repo on central and upload
41-
- uses: jvalkeal/nexus-sync@v0.0.2
42-
id: nexus
43-
with:
44-
url: ${{ secrets.OSSRH_URL }}
45-
username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
46-
password: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
47-
staging-profile-name: ${{ secrets.OSSRH_STAGING_PROFILE_NAME }}
48-
create: true
49-
upload: true
50-
generate-checksums: true
51-
pgp-sign: true
52-
upload-parallel: 10
53-
pgp-sign-passphrase: ${{ secrets.GPG_PASSPHRASE }}
54-
pgp-sign-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
55-
close: true
56-
release: true
15+
uses: .github/workflows/spring-artifactory-promote-central.yml
16+
with:
17+
buildName: ${{ inputs.buildName }}
18+
buildNumber: ${{ inputs.buildNumber }}
19+
secrets: inherit

.github/workflows/promote-milestone.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@ on:
66
buildName:
77
description: 'The Artifactory Build Name'
88
required: true
9+
type: string
910
buildNumber:
1011
description: 'The Artifactory Build'
1112
required: true
13+
type: number
1214

1315
jobs:
1416
promote_milestone:
15-
runs-on: ubuntu-latest
16-
if: github.repository_owner == 'spring-projects'
17-
steps:
18-
19-
- uses: jfrog/setup-jfrog-cli@v3
20-
with:
21-
version: 2.50.2
22-
env:
23-
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
24-
25-
- name: Promote Build
26-
run: |
27-
jfrog rt build-promote ${{ inputs.buildName }} ${{ inputs.buildNumber }} libs-milestone-local
17+
uses: .github/workflows/spring-artifactory-promote-milestone.yml
18+
with:
19+
buildName: ${{ inputs.buildName }}
20+
buildNumber: ${{ inputs.buildNumber }}
21+
secrets: inherit

.github/workflows/release-staging.yml

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,66 +10,10 @@ on:
1010
description: 'Next development version like 3.1.1-SNAPSHOT'
1111
required: true
1212

13-
run-name: Release version ${{ inputs.releaseVersion }}
14-
15-
env:
16-
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
17-
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
18-
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
19-
2013
jobs:
2114
staging:
22-
runs-on: ubuntu-latest
23-
if: github.repository_owner == 'spring-projects'
24-
steps:
25-
26-
- uses: actions/checkout@v3
27-
with:
28-
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
29-
30-
- name: Set up Gradle
31-
uses: spring-io/spring-gradle-build-action@v2
32-
33-
- uses: jfrog/setup-jfrog-cli@v3
34-
with:
35-
version: 2.50.2
36-
env:
37-
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
38-
39-
- name: Configure JFrog Cli
40-
run: |
41-
jf gradlec \
42-
--use-wrapper \
43-
--uses-plugin \
44-
--deploy-ivy-desc=false \
45-
--server-id-resolve repo.spring.io \
46-
--server-id-deploy repo.spring.io \
47-
--repo-resolve ${{ (contains(inputs.releaseVersion, 'M') || contains(inputs.releaseVersion, 'RC')) && 'milestone' || 'release' }} \
48-
--repo-deploy libs-staging-local
49-
echo JFROG_CLI_BUILD_NAME=${{ github.event.repository.name }}-${{ inputs.releaseVersion }} >> $GITHUB_ENV
50-
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
51-
52-
- name: Set Release Version
53-
run: |
54-
sed -i "s/version=.*/version=${{ inputs.releaseVersion }}/" gradle.properties
55-
56-
- name: Build and Publish
57-
run: |
58-
jf gradle build dist artifactoryPublish
59-
jf rt build-publish
60-
61-
- name: Tag Release and Next Development Version
62-
run: |
63-
git config --global user.name 'Spring Builds'
64-
git config --global user.email 'builds@springframework.org'
65-
git commit -a -m "[artifactory-release] Release version ${{ inputs.releaseVersion }}"
66-
git tag "v${{ inputs.releaseVersion }}"
67-
git push --tags origin
68-
sed -i "s/version=.*/version=${{ inputs.nextDevelopmentVersion }}/" gradle.properties
69-
git commit -a -m "[artifactory-release] Next development version"
70-
git push origin
71-
72-
- name: Print Build Info
73-
run: |
74-
echo "::notice ::Artifactory Build Name=$JFROG_CLI_BUILD_NAME"
75-
echo "::notice ::Artifactory Build Number=$JFROG_CLI_BUILD_NUMBER"
15+
uses: .github/workflows/spring-artifactory-gradle-release-staging.yml
16+
with:
17+
releaseVersion: ${{ inputs.releaseVersion }}
18+
nextDevelopmentVersion: ${{ inputs.nextDevelopmentVersion }}
19+
secrets: inherit
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
nextDevelopmentVersion:
11+
description: 'Next development version like 3.1.1-SNAPSHOT'
12+
required: true
13+
type: string
14+
gradleTasks:
15+
description: 'Additional Gradle tasks. The `build` and `artifactoryPublish` are included.'
16+
required: false
17+
default: 'dist'
18+
type: string
19+
20+
run-name: Release version ${{ inputs.releaseVersion }}
21+
22+
env:
23+
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
24+
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
25+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
26+
27+
jobs:
28+
staging:
29+
runs-on: ubuntu-latest
30+
if: github.repository_owner == 'spring-projects'
31+
steps:
32+
33+
- uses: actions/checkout@v3
34+
with:
35+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
36+
37+
- name: Set up Gradle
38+
uses: spring-io/spring-gradle-build-action@v2
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+
--uses-plugin \
51+
--deploy-ivy-desc=false \
52+
--server-id-resolve repo.spring.io \
53+
--server-id-deploy repo.spring.io \
54+
--repo-resolve ${{ (contains(inputs.releaseVersion, 'M') || contains(inputs.releaseVersion, 'RC')) && 'milestone' || 'release' }} \
55+
--repo-deploy libs-staging-local
56+
echo JFROG_CLI_BUILD_NAME=${{ github.event.repository.name }}-${{ inputs.releaseVersion }} >> $GITHUB_ENV
57+
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
58+
59+
- name: Set Release Version
60+
run: |
61+
sed -i "s/version=.*/version=${{ inputs.releaseVersion }}/" gradle.properties
62+
63+
- name: Build and Publish
64+
run: |
65+
jf gradle build ${{ inputs.gradleTasks }} artifactoryPublish
66+
jf rt build-publish
67+
68+
- name: Tag Release and Next Development Version
69+
run: |
70+
git config --global user.name 'Spring Builds'
71+
git config --global user.email 'builds@springframework.org'
72+
git commit -a -m "[artifactory-release] Release version ${{ inputs.releaseVersion }}"
73+
git tag "v${{ inputs.releaseVersion }}"
74+
git push --tags origin
75+
sed -i "s/version=.*/version=${{ inputs.nextDevelopmentVersion }}/" gradle.properties
76+
git commit -a -m "[artifactory-release] Next development version"
77+
git push origin
78+
79+
- name: Print Build Info
80+
run: |
81+
echo "::notice ::Artifactory Build Name=$JFROG_CLI_BUILD_NAME"
82+
echo "::notice ::Artifactory Build Number=$JFROG_CLI_BUILD_NUMBER"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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:
19+
runs-on: ubuntu-latest
20+
if: github.repository_owner == 'spring-projects'
21+
name: CI Build SNAPSHOT for ${{ github.ref_name }}
22+
steps:
23+
24+
- uses: actions/checkout@v3
25+
26+
- name: Set up Gradle
27+
uses: spring-io/spring-gradle-build-action@v2
28+
29+
- uses: jfrog/setup-jfrog-cli@v3
30+
with:
31+
version: 2.50.4
32+
env:
33+
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
34+
35+
- name: Configure JFrog Cli
36+
run: |
37+
jf gradlec \
38+
--use-wrapper \
39+
--uses-plugin \
40+
--deploy-ivy-desc=false \
41+
--server-id-resolve repo.spring.io \
42+
--server-id-deploy repo.spring.io \
43+
--repo-resolve snapshot \
44+
--repo-deploy libs-snapshot-local
45+
echo JFROG_CLI_BUILD_NAME=${{ github.event.repository.name }}-${{ github.ref_name }} >> $GITHUB_ENV
46+
echo JFROG_CLI_BUILD_NUMBER=$GITHUB_RUN_NUMBER >> $GITHUB_ENV
47+
48+
- name: Build and Publish
49+
run: |
50+
jf gradle build ${{ inputs.gradleTasks }} artifactoryPublish
51+
jf rt build-publish
52+

0 commit comments

Comments
 (0)