283 lines
12 KiB
YAML
283 lines
12 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
schedule:
|
|
- cron: '0 10 * * *' # Once per day at 10am UTC
|
|
workflow_dispatch: # Manual trigger
|
|
|
|
env:
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
GRADLE_ENTERPRISE_CACHE_USER: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
|
|
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
|
|
GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
|
|
COMMIT_OWNER: ${{ github.event.pusher.name }}
|
|
COMMIT_SHA: ${{ github.sha }}
|
|
STRUCTURE101_LICENSEID: ${{ secrets.STRUCTURE101_LICENSEID }}
|
|
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
|
|
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
|
|
RUN_JOBS: ${{ github.repository == 'spring-projects/spring-security' }}
|
|
|
|
jobs:
|
|
prerequisites:
|
|
name: Pre-requisites for building
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
runjobs: ${{ steps.continue.outputs.runjobs }}
|
|
project_version: ${{ steps.continue.outputs.project_version }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- id: continue
|
|
name: Determine if should continue
|
|
if: env.RUN_JOBS == 'true'
|
|
run: |
|
|
# Run jobs if in upstream repository
|
|
echo "::set-output name=runjobs::true"
|
|
# Extract version from gradle.properties
|
|
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}')
|
|
echo "::set-output name=project_version::$version"
|
|
build_jdk_17:
|
|
name: Build JDK 17
|
|
needs: [prerequisites]
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest]
|
|
runs-on: ${{ matrix.os }}
|
|
if: needs.prerequisites.outputs.runjobs
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '17'
|
|
- name: Setup gradle user name
|
|
run: |
|
|
mkdir -p ~/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
|
|
- name: Cache Gradle packages
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.gradle/caches
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
|
- name: Build with Gradle
|
|
env:
|
|
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USER }}
|
|
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
|
|
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
|
|
run: ./gradlew clean build --continue -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD"
|
|
snapshot_tests:
|
|
name: Test against snapshots
|
|
needs: [prerequisites]
|
|
runs-on: ubuntu-latest
|
|
if: needs.prerequisites.outputs.runjobs
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '17'
|
|
- name: Setup gradle user name
|
|
run: |
|
|
mkdir -p ~/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
|
|
- name: Snapshot Tests
|
|
run: |
|
|
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
|
|
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
|
|
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
|
|
./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
|
|
check_samples:
|
|
name: Check Samples project
|
|
needs: [prerequisites]
|
|
runs-on: ubuntu-latest
|
|
if: needs.prerequisites.outputs.runjobs
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '17'
|
|
- name: Setup gradle user name
|
|
run: |
|
|
mkdir -p ~/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
|
|
- name: Check samples project
|
|
run: |
|
|
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
|
|
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
|
|
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
|
|
./gradlew checkSamples --stacktrace
|
|
check_tangles:
|
|
name: Check for Package Tangles
|
|
needs: [ prerequisites ]
|
|
runs-on: ubuntu-latest
|
|
if: needs.prerequisites.outputs.runjobs
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '17'
|
|
- name: Setup gradle user name
|
|
run: |
|
|
mkdir -p ~/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
|
|
- name: Check for package tangles
|
|
run: |
|
|
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
|
|
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
|
|
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
|
|
./gradlew check s101 -Ps101.licenseId="$STRUCTURE101_LICENSEID" --stacktrace
|
|
deploy_artifacts:
|
|
name: Deploy Artifacts
|
|
needs: [build_jdk_17, snapshot_tests, check_samples, check_tangles]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '17'
|
|
- name: Setup gradle user name
|
|
run: |
|
|
mkdir -p ~/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
|
|
- name: Deploy artifacts
|
|
run: |
|
|
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
|
|
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
|
|
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
|
|
./gradlew publishArtifacts finalizeDeployArtifacts -PossrhUsername="$OSSRH_TOKEN_USERNAME" -PossrhPassword="$OSSRH_TOKEN_PASSWORD" -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" --stacktrace
|
|
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 }}
|
|
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
|
|
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
|
|
deploy_docs:
|
|
name: Deploy Docs
|
|
needs: [build_jdk_17, snapshot_tests, check_samples, check_tangles]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '17'
|
|
- name: Setup gradle user name
|
|
run: |
|
|
mkdir -p ~/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
|
|
- name: Deploy Docs
|
|
run: |
|
|
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
|
|
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
|
|
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
|
|
./gradlew deployDocs -PdeployDocsSshKey="$DOCS_SSH_KEY" -PdeployDocsSshUsername="$DOCS_USERNAME" -PdeployDocsHost="$DOCS_HOST" --stacktrace
|
|
env:
|
|
DOCS_USERNAME: ${{ secrets.DOCS_USERNAME }}
|
|
DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }}
|
|
DOCS_HOST: ${{ secrets.DOCS_HOST }}
|
|
deploy_schema:
|
|
name: Deploy Schema
|
|
needs: [build_jdk_17, snapshot_tests, check_samples, check_tangles]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '17'
|
|
- name: Setup gradle user name
|
|
run: |
|
|
mkdir -p ~/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
|
|
- name: Deploy Schema
|
|
run: |
|
|
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
|
|
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
|
|
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
|
|
./gradlew deploySchema -PdeployDocsSshKey="$DOCS_SSH_KEY" -PdeployDocsSshUsername="$DOCS_USERNAME" -PdeployDocsHost="$DOCS_HOST" --stacktrace --info
|
|
env:
|
|
DOCS_USERNAME: ${{ secrets.DOCS_USERNAME }}
|
|
DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }}
|
|
DOCS_HOST: ${{ secrets.DOCS_HOST }}
|
|
create_release:
|
|
name: Create GitHub Release
|
|
needs: [prerequisites, deploy_artifacts, deploy_docs, deploy_schema]
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 90
|
|
if: ${{ !endsWith(needs.prerequisites.outputs.project_version, '-SNAPSHOT') }}
|
|
env:
|
|
REPO: ${{ github.repository }}
|
|
BRANCH: ${{ github.ref_name }}
|
|
TOKEN: ${{ github.token }}
|
|
VERSION: ${{ needs.prerequisites.outputs.project_version }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '17'
|
|
- name: Setup gradle user name
|
|
run: |
|
|
mkdir -p ~/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
|
|
- name: Wait for Artifactory Artifacts
|
|
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/security/spring-security-core/$VERSION/ > /dev/null
|
|
do
|
|
sleep 30
|
|
echo "."
|
|
done
|
|
echo "Artifacts for $REPO@$VERSION have been released to Artifactory."
|
|
- name: Wait for Maven Central Artifacts
|
|
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 Maven Central."
|
|
until curl -f -s https://repo1.maven.org/maven2/org/springframework/security/spring-security-core/$VERSION/ > /dev/null
|
|
do
|
|
sleep 30
|
|
echo "."
|
|
done
|
|
echo "Artifacts for $REPO@$VERSION have been released to Maven Central."
|
|
- name: Create GitHub Release
|
|
run: |
|
|
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
|
|
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
|
|
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
|
|
echo "Tagging and publishing $REPO@$VERSION release on GitHub."
|
|
./gradlew createGitHubRelease -PnextVersion=$VERSION -Pbranch=$BRANCH -PcreateRelease=true -PgitHubAccessToken=$TOKEN
|
|
- name: Setup git config
|
|
run: |
|
|
git config user.name 'github-actions[bot]'
|
|
git config user.email 'github-actions[bot]@users.noreply.github.com'
|
|
- name: Update to next Snapshot Version
|
|
run: |
|
|
export GRADLE_ENTERPRISE_CACHE_USERNAME="$GRADLE_ENTERPRISE_CACHE_USER"
|
|
export GRADLE_ENTERPRISE_CACHE_PASSWORD="$GRADLE_ENTERPRISE_CACHE_PASSWORD"
|
|
export GRADLE_ENTERPRISE_ACCESS_KEY="$GRADLE_ENTERPRISE_SECRET_ACCESS_KEY"
|
|
echo "Updating $REPO@$VERSION to next snapshot version."
|
|
./gradlew :updateToSnapshotVersion
|
|
./gradlew :spring-security-docs:antoraUpdateVersion
|
|
git commit -am "Next development version"
|
|
git push
|
|
notify_result:
|
|
name: Check for failures
|
|
needs: [build_jdk_17, snapshot_tests, check_samples, check_tangles, deploy_artifacts, deploy_docs, deploy_schema, create_release]
|
|
if: failure()
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Send Slack message
|
|
uses: Gamesight/slack-workflow-status@v1.0.1
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
channel: '#spring-security-ci'
|
|
name: 'CI Notifier'
|