-
Notifications
You must be signed in to change notification settings - Fork 59
215 lines (212 loc) · 8.85 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: CI
on:
push:
branches:
- '1.1.x'
paths-ignore:
- '.github/**'
workflow_dispatch:
env:
GCHAT_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_GCHAT_WEBHOOK_URL }}
GRADLE_ENTERPRISE_CACHE_USER: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
GRADLE_ENTERPRISE_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:
prerequisites:
name: Pre-requisites for building
runs-on: ubuntu-latest
if: github.repository == 'spring-projects/spring-pulsar'
outputs:
runjobs: ${{ steps.continue.outputs.runjobs }}
project_version: ${{ steps.continue.outputs.project_version }}
boot_version: ${{ steps.continue.outputs.boot_version }}
steps:
- uses: actions/checkout@v4
- id: continue
name: Determine if should continue
run: |
# Run jobs if in upstream repository
echo "runjobs=true" >>$GITHUB_OUTPUT
# Extract version from gradle.properties
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
echo "project_version=$version" >>$GITHUB_OUTPUT
bootVersion=$(cat gradle/libs.versions.toml | grep "spring-boot = \"" | cut -d '"' -f2)
echo "boot_version=$bootVersion" >>$GITHUB_OUTPUT
build_jdk_17:
name: Build (JDK 17)
needs: [prerequisites]
runs-on: ubuntu-latest
if: needs.prerequisites.outputs.runjobs
steps:
- uses: actions/checkout@v4
- uses: spring-io/spring-gradle-build-action@v2
- name: Build and run unit tests
run: |
./gradlew clean build -x integrationTest \
--continue --scan \
-PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD"
- name: Run integration tests
run: |
./gradlew integrationTest --rerun-tasks -DdownloadRabbitConnector=true --scan
- name: Capture test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: '*/build/reports/tests/**/*.*'
retention-days: 3
check_samples:
name: Check Sample Apps
needs: [prerequisites]
strategy:
matrix:
springBootVersion: [ "${{ needs.prerequisites.outputs.boot_version }}" ]
runs-on: ubuntu-latest
if: needs.prerequisites.outputs.runjobs
steps:
- uses: actions/checkout@v4
- uses: spring-io/spring-gradle-build-action@v2
- name: Run all sample app tests
env:
LOCAL_REPOSITORY_PATH: ${{ github.workspace }}/build/publications/repos
VERSION: ${{ needs.prerequisites.outputs.project_version }}
BOOT_VERSION: ${{ matrix.springBootVersion }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
run: |
./gradlew publishMavenJavaPublicationToLocalRepository
./gradlew \
--init-script ./spring-pulsar-sample-apps/sample-apps-check-ci.gradle \
-PlocalRepositoryPath="$LOCAL_REPOSITORY_PATH" \
-PspringPulsarVersion="$VERSION" \
-PspringBootVersion="$BOOT_VERSION" \
-PsampleTests \
:runAllSampleTests
scan:
needs: [prerequisites]
if: needs.prerequisites.outputs.runjobs
uses: ./.github/workflows/trivy-scan.yml
with:
config-path: .github/trivy-to-sarif.yaml
upload-results: true
deploy_artifacts:
name: Deploy Artifacts
needs: [build_jdk_17, check_samples, scan]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: spring-io/spring-gradle-build-action@v2
- name: Deploy artifacts
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
OSSRH_TOKEN_USERNAME: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
OSSRH_TOKEN_PASSWORD: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
run: |
./gradlew publishArtifacts finalizeDeployArtifacts \
--stacktrace \
-PossrhUsername="$OSSRH_TOKEN_USERNAME" -PossrhPassword="$OSSRH_TOKEN_PASSWORD" \
-PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD"
deploy_docs_antora:
name: Deploy Antora Docs
needs: [build_jdk_17, check_samples, scan]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: spring-io/spring-gradle-build-action@v2
- name: Run Antora
run: |
./gradlew antora
- name: Publish Docs
uses: spring-io/spring-doc-actions/rsync-antora-reference@v0.0.18
with:
docs-username: ${{ secrets.DOCS_USERNAME }}
docs-host: ${{ secrets.DOCS_HOST }}
docs-ssh-key: ${{ secrets.DOCS_SSH_KEY }}
docs-ssh-host-key: ${{ secrets.DOCS_SSH_HOST_KEY }}
site-path: spring-pulsar-docs/build/site
- name: Bust Clouflare Cache
uses: spring-io/spring-doc-actions/bust-cloudflare-antora-cache@v0.0.18
with:
context-root: spring-pulsar
cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }}
cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }}
perform_release:
name: Perform Release
needs: [prerequisites, deploy_artifacts, deploy_docs_antora]
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 120
if: ${{ !endsWith(needs.prerequisites.outputs.project_version, '-SNAPSHOT') }}
env:
REPO: ${{ github.repository }}
BRANCH: ${{ github.ref_name }}
VERSION: ${{ needs.prerequisites.outputs.project_version }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
- uses: spring-io/spring-gradle-build-action@v2
- name: Wait for Artifactory artifacts (milestone)
if: ${{ contains(needs.prerequisites.outputs.project_version, '-RC') || contains(needs.prerequisites.outputs.project_version, '-M') }}
run: |
echo "Wait for artifacts of $REPO@$VERSION to appear on Artifactory."
until curl -f -s https://repo.spring.io/artifactory/milestone/org/springframework/pulsar/spring-pulsar/$VERSION/ > /dev/null
do
sleep 30
echo "."
done
echo "Artifacts for $REPO@$VERSION have been released to Artifactory."
- name: Wait for Maven Central artifacts (GA)
if: ${{ !contains(needs.prerequisites.outputs.project_version, '-SNAPSHOT') && !contains(needs.prerequisites.outputs.project_version, '-RC') && !contains(needs.prerequisites.outputs.project_version, '-M') }}
run: |
echo "Wait for artifacts of $REPO@$VERSION to appear on Maven Central."
until curl -f -s https://repo1.maven.org/maven2/org/springframework/pulsar/spring-pulsar/$VERSION/ > /dev/null
do
sleep 30
echo "."
done
echo "Artifacts for $REPO@$VERSION have been released to Maven Central."
- name: Setup git for release tagging
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Tag release
run: |
echo "Tagging $REPO@$VERSION release."
git tag v$VERSION
git push --tags origin
- name: Install tooling for Github release
run: |
curl -sSL -O https://github.com/spring-io/github-changelog-generator/releases/download/v0.0.10/github-changelog-generator.jar
- name: Create Github release
env:
RELEASE_NOTES_FILE: ${{runner.temp}}/release_notes.md5
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
run: |
java -jar github-changelog-generator.jar \
--spring.config.location=.github/changelog-generator.yml \
$VERSION $RELEASE_NOTES_FILE
cat $RELEASE_NOTES_FILE
gh release create v$VERSION \
--draft \
--title "Spring Pulsar $VERSION" \
--generate-notes \
--notes-file $RELEASE_NOTES_FILE
- name: Announce Release in Chat
uses: julb/action-post-googlechat-message@v1
if: env.GCHAT_WEBHOOK_URL
with:
message: "spring-pulsar-announcing `${{ env.VERSION }}`"
gchat_webhook_url: ${{ env.GCHAT_WEBHOOK_URL }}
- name: Update next snapshot version
run: |
echo "Updating $REPO@$VERSION to next snapshot version."
./gradlew :updateToSnapshotVersion
git commit -am "[Release $VERSION] Next development version"
git push