continuous-integration-workflow.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. name: CI
  2. on:
  3. push:
  4. schedule:
  5. - cron: '0 10 * * *' # Once per day at 10am UTC
  6. workflow_dispatch: # Manual trigger
  7. env:
  8. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  9. GRADLE_ENTERPRISE_CACHE_USER: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
  10. GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
  11. GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
  12. COMMIT_OWNER: ${{ github.event.pusher.name }}
  13. COMMIT_SHA: ${{ github.sha }}
  14. STRUCTURE101_LICENSEID: ${{ secrets.STRUCTURE101_LICENSEID }}
  15. ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
  16. ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
  17. RUN_JOBS: ${{ github.repository == 'spring-projects/spring-security' }}
  18. jobs:
  19. prerequisites:
  20. name: Pre-requisites for building
  21. runs-on: ubuntu-latest
  22. outputs:
  23. runjobs: ${{ steps.continue.outputs.runjobs }}
  24. steps:
  25. - id: continue
  26. name: Determine if should continue
  27. if: env.RUN_JOBS == 'true'
  28. run: |
  29. # Run jobs if in upstream repository
  30. echo "::set-output name=runjobs::true"
  31. # Extract version from gradle.properties
  32. version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
  33. echo "::set-output name=project_version::$version"
  34. build_jdk_17:
  35. name: Build JDK 17
  36. needs: [prerequisites]
  37. strategy:
  38. matrix:
  39. os: [ubuntu-latest, windows-latest]
  40. runs-on: ${{ matrix.os }}
  41. if: needs.prerequisites.outputs.runjobs
  42. steps:
  43. - uses: actions/checkout@v2
  44. - name: Set up JDK 17
  45. uses: actions/setup-java@v1
  46. with:
  47. java-version: '17'
  48. - name: Setup gradle user name
  49. run: |
  50. mkdir -p ~/.gradle
  51. echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
  52. - name: Cache Gradle packages
  53. uses: actions/cache@v2
  54. with:
  55. path: ~/.gradle/caches
  56. key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
  57. - name: Build with Gradle
  58. env:
  59. GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
  60. GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
  61. GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
  62. run: ./gradlew clean build --continue -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD"
  63. snapshot_tests:
  64. name: Test against snapshots
  65. needs: [prerequisites]
  66. runs-on: ubuntu-latest
  67. if: needs.prerequisites.outputs.runjobs
  68. steps:
  69. - uses: actions/checkout@v2
  70. - name: Set up JDK
  71. uses: actions/setup-java@v1
  72. with:
  73. java-version: '17'
  74. - name: Setup gradle user name
  75. run: |
  76. mkdir -p ~/.gradle
  77. echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
  78. - name: Snapshot Tests
  79. run: |
  80. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  81. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  82. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  83. ./gradlew test --refresh-dependencies -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" -PforceMavenRepositories=snapshot -PspringVersion='5.+' -PreactorVersion='20+' -PspringDataVersion='Neumann-BUILD-SNAPSHOT' -PrsocketVersion=1.1.0-SNAPSHOT -PspringBootVersion=2.4.0-SNAPSHOT -PlocksDisabled --stacktrace
  84. check_samples:
  85. name: Check Samples project
  86. needs: [prerequisites]
  87. runs-on: ubuntu-latest
  88. if: needs.prerequisites.outputs.runjobs
  89. steps:
  90. - uses: actions/checkout@v2
  91. - name: Set up JDK
  92. uses: actions/setup-java@v1
  93. with:
  94. java-version: '17'
  95. - name: Setup gradle user name
  96. run: |
  97. mkdir -p ~/.gradle
  98. echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
  99. - name: Check samples project
  100. run: |
  101. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  102. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  103. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  104. ./gradlew checkSamples --stacktrace
  105. check_tangles:
  106. name: Check for Package Tangles
  107. needs: [ prerequisites ]
  108. runs-on: ubuntu-latest
  109. if: needs.prerequisites.outputs.runjobs
  110. steps:
  111. - uses: actions/checkout@v2
  112. - name: Set up JDK
  113. uses: actions/setup-java@v1
  114. with:
  115. java-version: '17'
  116. - name: Setup gradle user name
  117. run: |
  118. mkdir -p ~/.gradle
  119. echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
  120. - name: Check for package tangles
  121. run: |
  122. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  123. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  124. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  125. ./gradlew check s101 -Ps101.licenseId="$STRUCTURE101_LICENSEID" --stacktrace
  126. deploy_artifacts:
  127. name: Deploy Artifacts
  128. needs: [build_jdk_17, snapshot_tests, check_samples, check_tangles]
  129. runs-on: ubuntu-latest
  130. steps:
  131. - uses: actions/checkout@v2
  132. - name: Set up JDK
  133. uses: actions/setup-java@v1
  134. with:
  135. java-version: '17'
  136. - name: Setup gradle user name
  137. run: |
  138. mkdir -p ~/.gradle
  139. echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
  140. - name: Deploy artifacts
  141. run: |
  142. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  143. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  144. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  145. ./gradlew publishArtifacts finalizeDeployArtifacts -PossrhUsername="$OSSRH_TOKEN_USERNAME" -PossrhPassword="$OSSRH_TOKEN_PASSWORD" -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" --stacktrace
  146. env:
  147. ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
  148. ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
  149. OSSRH_TOKEN_USERNAME: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
  150. OSSRH_TOKEN_PASSWORD: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
  151. ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
  152. ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
  153. deploy_docs:
  154. name: Deploy Docs
  155. needs: [build_jdk_17, snapshot_tests, check_samples, check_tangles]
  156. runs-on: ubuntu-latest
  157. steps:
  158. - uses: actions/checkout@v2
  159. - name: Set up JDK
  160. uses: actions/setup-java@v1
  161. with:
  162. java-version: '17'
  163. - name: Setup gradle user name
  164. run: |
  165. mkdir -p ~/.gradle
  166. echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
  167. - name: Deploy Docs
  168. run: |
  169. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  170. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  171. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  172. ./gradlew deployDocs -PdeployDocsSshKey="$DOCS_SSH_KEY" -PdeployDocsSshUsername="$DOCS_USERNAME" -PdeployDocsHost="$DOCS_HOST" --stacktrace
  173. env:
  174. DOCS_USERNAME: ${{ secrets.DOCS_USERNAME }}
  175. DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }}
  176. DOCS_HOST: ${{ secrets.DOCS_HOST }}
  177. deploy_schema:
  178. name: Deploy Schema
  179. needs: [build_jdk_17, snapshot_tests, check_samples, check_tangles]
  180. runs-on: ubuntu-latest
  181. steps:
  182. - uses: actions/checkout@v2
  183. - name: Set up JDK
  184. uses: actions/setup-java@v1
  185. with:
  186. java-version: '17'
  187. - name: Setup gradle user name
  188. run: |
  189. mkdir -p ~/.gradle
  190. echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
  191. - name: Deploy Schema
  192. run: |
  193. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  194. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  195. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  196. ./gradlew deploySchema -PdeployDocsSshKey="$DOCS_SSH_KEY" -PdeployDocsSshUsername="$DOCS_USERNAME" -PdeployDocsHost="$DOCS_HOST" --stacktrace --info
  197. env:
  198. DOCS_USERNAME: ${{ secrets.DOCS_USERNAME }}
  199. DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }}
  200. DOCS_HOST: ${{ secrets.DOCS_HOST }}
  201. create_release:
  202. name: Create GitHub Release
  203. needs: [prerequisites, deploy_artifacts, deploy_docs, deploy_schema]
  204. runs-on: ubuntu-latest
  205. timeout-minutes: 90
  206. if: ${{ !endsWith(needs.prerequisites.outputs.project_version, '-SNAPSHOT') }}
  207. env:
  208. REPO: ${{ github.repository }}
  209. BRANCH: ${{ github.ref_name }}
  210. TOKEN: ${{ github.token }}
  211. VERSION: ${{ needs.prerequisites.outputs.project_version }}
  212. steps:
  213. - uses: actions/checkout@v2
  214. - name: Set up JDK
  215. uses: actions/setup-java@v1
  216. with:
  217. java-version: '17'
  218. - name: Setup gradle user name
  219. run: |
  220. mkdir -p ~/.gradle
  221. echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
  222. - name: Wait for Artifactory Artifacts
  223. if: ${{ contains(needs.prerequisites.outputs.project_version, '-RC') || contains(needs.prerequisites.outputs.project_version, '-M') }}
  224. run: |
  225. echo "Wait for artifacts of $REPO@$VERSION to appear on Artifactory."
  226. until curl -f -s https://repo.spring.io/artifactory/milestone/org/springframework/security/spring-security-core/$VERSION/ > /dev/null
  227. do
  228. sleep 30
  229. echo "."
  230. done
  231. echo "Artifacts for $REPO@$VERSION have been released to Artifactory."
  232. - name: Wait for Maven Central Artifacts
  233. if: ${{ !contains(needs.prerequisites.outputs.project_version, '-RC') && !contains(needs.prerequisites.outputs.project_version, '-M') }}
  234. run: |
  235. echo "Wait for artifacts of $REPO@$VERSION to appear on Maven Central."
  236. until curl -f -s https://repo1.maven.org/maven2/org/springframework/security/spring-security-core/$VERSION/ > /dev/null
  237. do
  238. sleep 30
  239. echo "."
  240. done
  241. echo "Artifacts for $REPO@$VERSION have been released to Maven Central."
  242. - name: Create GitHub Release
  243. run: |
  244. export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
  245. export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
  246. export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
  247. echo "Tagging and publishing $REPO@$VERSION release on GitHub."
  248. ./gradlew createGitHubRelease -PnextVersion=$VERSION -Pbranch=$BRANCH -PcreateRelease=true -PgitHubAccessToken=$TOKEN
  249. notify_result:
  250. name: Check for failures
  251. needs: [build_jdk_17, snapshot_tests, check_samples, check_tangles, deploy_artifacts, deploy_docs, deploy_schema, create_release]
  252. if: failure()
  253. runs-on: ubuntu-latest
  254. steps:
  255. - name: Send Slack message
  256. uses: Gamesight/slack-workflow-status@v1.0.1
  257. with:
  258. repo_token: ${{ secrets.GITHUB_TOKEN }}
  259. slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
  260. channel: '#spring-security-ci'
  261. name: 'CI Notifier'