Skip to content

Commit d76c321

Browse files
author
Steve Riesenberg
committed
Backport release automation and github actions
Closes gh-11500
1 parent 37d856d commit d76c321

39 files changed

+3299
-590
lines changed

.github/workflows/antora-generate.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ jobs:
1616
steps:
1717
- name: Checkout Source
1818
uses: actions/checkout@v2
19+
- name: Set up JDK
20+
uses: actions/setup-java@v1
21+
with:
22+
java-version: '11'
23+
- name: Setup Gradle
24+
uses: gradle/gradle-build-action@v2
25+
env:
26+
GRADLE_USER_HOME: ~/.gradle
1927
- name: Generate antora.yml
2028
run: ./gradlew :spring-security-docs:generateAntora
2129
- name: Extract Branch Name

.github/workflows/continuous-integration-workflow.yml

Lines changed: 144 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ jobs:
2424
runs-on: ubuntu-latest
2525
outputs:
2626
runjobs: ${{ steps.continue.outputs.runjobs }}
27+
project_version: ${{ steps.continue.outputs.project_version }}
2728
steps:
29+
- uses: actions/checkout@v2
2830
- id: continue
2931
name: Determine if should continue
3032
if: env.RUN_JOBS == 'true'
31-
run: echo "::set-output name=runjobs::true"
33+
run: |
34+
echo "::set-output name=runjobs::true"
35+
# Extract version from gradle.properties
36+
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
37+
echo "::set-output name=project_version::$version"
3238
build_jdk_11:
3339
name: Build JDK 11
3440
needs: [prerequisites]
@@ -47,11 +53,10 @@ jobs:
4753
run: |
4854
mkdir -p ~/.gradle
4955
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
50-
- name: Cache Gradle packages
51-
uses: actions/cache@v2
52-
with:
53-
path: ~/.gradle/caches
54-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
56+
- name: Setup Gradle
57+
uses: gradle/gradle-build-action@v2
58+
env:
59+
GRADLE_USER_HOME: ~/.gradle
5560
- name: Build with Gradle
5661
env:
5762
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
@@ -73,6 +78,10 @@ jobs:
7378
run: |
7479
mkdir -p ~/.gradle
7580
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
81+
- name: Setup Gradle
82+
uses: gradle/gradle-build-action@v2
83+
env:
84+
GRADLE_USER_HOME: ~/.gradle
7685
- name: Snapshot Tests
7786
run: |
7887
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
@@ -94,6 +103,10 @@ jobs:
94103
run: |
95104
mkdir -p ~/.gradle
96105
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
106+
- name: Setup Gradle
107+
uses: gradle/gradle-build-action@v2
108+
env:
109+
GRADLE_USER_HOME: ~/.gradle
97110
- name: Check samples project
98111
env:
99112
LOCAL_REPOSITORY_PATH: ${{ github.workspace }}/build/publications/repos
@@ -119,6 +132,10 @@ jobs:
119132
run: |
120133
mkdir -p ~/.gradle
121134
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
135+
- name: Setup Gradle
136+
uses: gradle/gradle-build-action@v2
137+
env:
138+
GRADLE_USER_HOME: ~/.gradle
122139
- name: Check for package tangles
123140
run: |
124141
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
@@ -139,6 +156,10 @@ jobs:
139156
run: |
140157
mkdir -p ~/.gradle
141158
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
159+
- name: Setup Gradle
160+
uses: gradle/gradle-build-action@v2
161+
env:
162+
GRADLE_USER_HOME: ~/.gradle
142163
- name: Deploy artifacts
143164
run: |
144165
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
@@ -166,6 +187,10 @@ jobs:
166187
run: |
167188
mkdir -p ~/.gradle
168189
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
190+
- name: Setup Gradle
191+
uses: gradle/gradle-build-action@v2
192+
env:
193+
GRADLE_USER_HOME: ~/.gradle
169194
- name: Deploy Docs
170195
run: |
171196
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
@@ -190,6 +215,10 @@ jobs:
190215
run: |
191216
mkdir -p ~/.gradle
192217
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
218+
- name: Setup Gradle
219+
uses: gradle/gradle-build-action@v2
220+
env:
221+
GRADLE_USER_HOME: ~/.gradle
193222
- name: Deploy Schema
194223
run: |
195224
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
@@ -200,14 +229,121 @@ jobs:
200229
DOCS_USERNAME: ${{ secrets.DOCS_USERNAME }}
201230
DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }}
202231
DOCS_HOST: ${{ secrets.DOCS_HOST }}
232+
perform_release:
233+
name: Perform release
234+
needs: [prerequisites, deploy_artifacts, deploy_docs, deploy_schema]
235+
runs-on: ubuntu-latest
236+
timeout-minutes: 90
237+
if: ${{ !endsWith(needs.prerequisites.outputs.project_version, '-SNAPSHOT') }}
238+
env:
239+
REPO: ${{ github.repository }}
240+
BRANCH: ${{ github.ref_name }}
241+
TOKEN: ${{ github.token }}
242+
VERSION: ${{ needs.prerequisites.outputs.project_version }}
243+
steps:
244+
- uses: actions/checkout@v2
245+
with:
246+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
247+
- name: Set up JDK
248+
uses: actions/setup-java@v1
249+
with:
250+
java-version: '11'
251+
- name: Setup gradle user name
252+
run: |
253+
mkdir -p ~/.gradle
254+
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
255+
- name: Setup Gradle
256+
uses: gradle/gradle-build-action@v2
257+
env:
258+
GRADLE_USER_HOME: ~/.gradle
259+
- name: Wait for Artifactory Artifacts
260+
if: ${{ contains(needs.prerequisites.outputs.project_version, '-RC') || contains(needs.prerequisites.outputs.project_version, '-M') }}
261+
run: |
262+
echo "Wait for artifacts of $REPO@$VERSION to appear on Artifactory."
263+
until curl -f -s https://repo.spring.io/artifactory/milestone/org/springframework/security/spring-security-core/$VERSION/ > /dev/null
264+
do
265+
sleep 30
266+
echo "."
267+
done
268+
echo "Artifacts for $REPO@$VERSION have been released to Artifactory."
269+
- name: Wait for Maven Central Artifacts
270+
if: ${{ !contains(needs.prerequisites.outputs.project_version, '-RC') && !contains(needs.prerequisites.outputs.project_version, '-M') }}
271+
run: |
272+
echo "Wait for artifacts of $REPO@$VERSION to appear on Maven Central."
273+
until curl -f -s https://repo1.maven.org/maven2/org/springframework/security/spring-security-core/$VERSION/ > /dev/null
274+
do
275+
sleep 30
276+
echo "."
277+
done
278+
echo "Artifacts for $REPO@$VERSION have been released to Maven Central."
279+
- name: Create GitHub Release
280+
run: |
281+
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
282+
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
283+
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
284+
echo "Tagging and publishing $REPO@$VERSION release on GitHub."
285+
./gradlew createGitHubRelease -PnextVersion=$VERSION -Pbranch=$BRANCH -PcreateRelease=true -PgitHubAccessToken=$TOKEN
286+
- name: Announce Release on Slack
287+
id: spring-security-announcing
288+
uses: slackapi/[email protected]
289+
with:
290+
payload: |
291+
{
292+
"text": "spring-security-announcing `${{ env.VERSION }}` is available now",
293+
"blocks": [
294+
{
295+
"type": "section",
296+
"text": {
297+
"type": "mrkdwn",
298+
"text": "spring-security-announcing `${{ env.VERSION }}` is available now"
299+
}
300+
}
301+
]
302+
}
303+
env:
304+
SLACK_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_SLACK_WEBHOOK_URL }}
305+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
306+
- name: Setup git config
307+
run: |
308+
git config user.name 'github-actions[bot]'
309+
git config user.email 'github-actions[bot]@users.noreply.github.com'
310+
- name: Update to next Snapshot Version
311+
run: |
312+
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
313+
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
314+
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
315+
echo "Updating $REPO@$VERSION to next snapshot version."
316+
./gradlew :updateToSnapshotVersion
317+
./gradlew :spring-security-docs:antoraUpdateVersion
318+
git commit -am "Next development version"
319+
git push
320+
perform_post_release:
321+
name: Perform post-release
322+
needs: [prerequisites, deploy_artifacts, deploy_docs, deploy_schema]
323+
runs-on: ubuntu-latest
324+
timeout-minutes: 90
325+
if: ${{ endsWith(needs.prerequisites.outputs.project_version, '-SNAPSHOT') }}
326+
env:
327+
TOKEN: ${{ github.token }}
328+
VERSION: ${{ needs.prerequisites.outputs.project_version }}
329+
steps:
330+
- uses: actions/checkout@v2
331+
- uses: spring-io/spring-gradle-build-action@v1
332+
with:
333+
java-version: '11'
334+
distribution: 'adopt'
335+
- name: Schedule next release (if not already scheduled)
336+
run: ./gradlew scheduleNextRelease -PnextVersion=$VERSION -PgitHubAccessToken=$TOKEN
203337
notify_result:
204338
name: Check for failures
205-
needs: [build_jdk_11, snapshot_tests, check_samples, check_tangles, deploy_artifacts, deploy_docs, deploy_schema]
339+
needs: [build_jdk_11, snapshot_tests, check_samples, check_tangles, deploy_artifacts, deploy_docs, deploy_schema, perform_release, perform_post_release]
206340
if: failure()
207341
runs-on: ubuntu-latest
208342
steps:
209343
- name: Send Slack message
210-
uses: Gamesight/[email protected]
344+
# Workaround while waiting for Gamesight/slack-workflow-status#38 to be fixed
345+
# See https://github.com/Gamesight/slack-workflow-status/issues/38
346+
uses: sjohnr/slack-workflow-status@v1-beta
211347
with:
212348
repo_token: ${{ secrets.GITHUB_TOKEN }}
213349
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/deploy-reference.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ jobs:
1818
with:
1919
java-version: '11'
2020
distribution: 'adopt'
21-
cache: gradle
2221
- name: Validate Gradle wrapper
2322
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
23+
- name: Setup Gradle
24+
uses: gradle/gradle-build-action@v2
25+
env:
26+
GRADLE_USER_HOME: ~/.gradle
27+
with:
28+
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
29+
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
30+
gradle-home-cache-excludes: |
31+
caches/modules-2/modules-2.lock
32+
caches/modules-2/gc.properties
2433
- name: Build with Gradle
2534
run: ./gradlew :spring-security-docs:antora --stacktrace
26-
- name: Cleanup Gradle Cache
27-
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
28-
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
29-
run: |
30-
rm -f ~/.gradle/caches/modules-2/modules-2.lock
31-
rm -f ~/.gradle/caches/modules-2/gc.properties
3235
- name: Deploy
3336
run: ${GITHUB_WORKSPACE}/.github/actions/algolia-deploy.sh "${{ secrets.DOCS_USERNAME }}@${{ secrets.DOCS_HOST }}" "/opt/www/domains/spring.io/docs/htdocs/spring-security/reference/" "${{ secrets.DOCS_SSH_KEY }}" "${{ secrets.DOCS_SSH_HOST_KEY }}"

.github/workflows/pr-build-workflow.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ jobs:
1717
uses: actions/setup-java@v1
1818
with:
1919
java-version: '11'
20-
- name: Cache Gradle packages
20+
- name: Setup Gradle
2121
if: env.RUN_JOBS == 'true'
22-
uses: actions/cache@v2
22+
uses: gradle/gradle-build-action@v2
2323
with:
24-
path: ~/.gradle/caches
25-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
24+
cache-read-only: true
25+
env:
26+
GRADLE_USER_HOME: ~/.gradle
2627
- name: Build with Gradle
2728
if: env.RUN_JOBS == 'true'
2829
run: ./gradlew clean build --continue --scan
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Update Scheduled Release Version
2+
3+
on:
4+
workflow_dispatch: # Manual trigger only. Triggered by release-scheduler.yml on main.
5+
6+
env:
7+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
8+
GRADLE_ENTERPRISE_CACHE_USER: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
9+
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
10+
GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
11+
12+
jobs:
13+
update_scheduled_release_version:
14+
name: Initiate Release If Scheduled
15+
if: ${{ github.repository == 'spring-projects/spring-security' }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- id: checkout-source
19+
name: Checkout Source Code
20+
uses: actions/checkout@v2
21+
with:
22+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
23+
- id: setup-jdk
24+
name: Set up JDK 11
25+
uses: actions/setup-java@v1
26+
with:
27+
java-version: '11'
28+
- name: Setup gradle user name
29+
run: |
30+
mkdir -p ~/.gradle
31+
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
32+
- name: Setup Gradle
33+
uses: gradle/gradle-build-action@v2
34+
env:
35+
GRADLE_USER_HOME: ~/.gradle
36+
- id: check-release-due
37+
name: Check Release Due
38+
run: |
39+
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
40+
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
41+
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
42+
./gradlew gitHubCheckNextVersionDueToday
43+
echo "::set-output name=is_due_today::$(cat build/github/milestones/is-due-today)"
44+
- id: check-open-issues
45+
name: Check for open issues
46+
if: steps.check-release-due.outputs.is_due_today == 'true'
47+
run: |
48+
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
49+
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
50+
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
51+
./gradlew gitHubCheckMilestoneHasNoOpenIssues
52+
echo "::set-output name=is_open_issues::$(cat build/github/milestones/is-open-issues)"
53+
- id: validate-release-state
54+
name: Validate State of Release
55+
if: steps.check-release-due.outputs.is_due_today == 'true' && steps.check-open-issues.outputs.is_open_issues == 'true'
56+
run: |
57+
echo "The release is due today but there are open issues"
58+
exit 1
59+
- id: update-version-and-push
60+
name: Update version and push
61+
if: steps.check-release-due.outputs.is_due_today == 'true' && steps.check-open-issues.outputs.is_open_issues == 'false'
62+
run: |
63+
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
64+
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
65+
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
66+
git config user.name 'github-actions[bot]'
67+
git config user.email 'github-actions[bot]@users.noreply.github.com'
68+
./gradlew :updateProjectVersion
69+
./gradlew :spring-security-docs:antoraUpdateVersion
70+
updatedVersion=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
71+
git commit -am "Release $updatedVersion"
72+
git tag $updatedVersion
73+
git push
74+
git push origin $updatedVersion
75+
- id: send-slack-notification
76+
name: Send Slack message
77+
if: failure()
78+
uses: Gamesight/[email protected]
79+
with:
80+
repo_token: ${{ secrets.GITHUB_TOKEN }}
81+
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
82+
channel: '#spring-security-ci'
83+
name: 'CI Notifier'

0 commit comments

Comments
 (0)