CI #930
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/**' | |
schedule: | |
- cron: '0 10 * * *' # Once per day at 10am UTC | |
workflow_dispatch: | |
env: | |
COMMIT_OWNER: ${{ github.event.pusher.name }} | |
COMMIT_SHA: ${{ github.sha }} | |
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} | |
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
jobs: | |
build_and_deploy: | |
name: Build and Deploy | |
if: github.repository == 'spring-projects/spring-pulsar' | |
runs-on: ubuntu-latest | |
outputs: | |
project_version: ${{ steps.extract_version.outputs.project_version }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Set up Java 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 17 | |
distribution: temurin | |
- name: Setup Gradle user name | |
run: | | |
mkdir -p ~/.gradle | |
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
env: | |
GRADLE_USER_HOME: ~/.gradle | |
- 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@v3 | |
with: | |
name: test-results | |
path: '*/build/reports/tests/**/*.*' | |
retention-days: 3 | |
- name: Deploy artifacts | |
run: | | |
./gradlew publishArtifacts finalizeDeployArtifacts --stacktrace --info -PossrhUsername="$OSSRH_TOKEN_USERNAME" -PossrhPassword="$OSSRH_TOKEN_PASSWORD" -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" | |
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 }} | |
- id: extract_version | |
name: Extract current version | |
run: | | |
version=$(cat gradle.properties | grep "version=" | awk -F'=' '{print $2}') | |
echo "::set-output name=project_version::$version" | |
perform_release: | |
name: Perform Release | |
needs: [build_and_deploy] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
timeout-minutes: 90 | |
if: ${{ !endsWith(needs.build_and_deploy.outputs.project_version, '-SNAPSHOT') }} | |
env: | |
REPO: ${{ github.repository }} | |
BRANCH: ${{ github.ref_name }} | |
TOKEN: ${{ github.token }} | |
VERSION: ${{ needs.build_and_deploy.outputs.project_version }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} | |
- name: Set up gradle | |
uses: spring-io/spring-gradle-build-action@v1 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Wait for Artifactory artifacts (milestone) | |
if: ${{ contains(needs.build_and_deploy.outputs.project_version, '-RC') || contains(needs.build_and_deploy.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.build_and_deploy.outputs.project_version, '-SNAPSHOT') && !contains(needs.build_and_deploy.outputs.project_version, '-RC') && !contains(needs.build_and_deploy.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 (milestone) | |
if: ${{ startsWith(needs.build_and_deploy.outputs.project_version, '0.') || contains(needs.build_and_deploy.outputs.project_version, '-RC') || contains(needs.build_and_deploy.outputs.project_version, '-M') }} | |
run: | | |
echo "Tagging $REPO@$VERSION release." | |
git tag v$VERSION | |
git push --tags origin | |
- name: Create branch and tag release (GA) | |
if: ${{ !startsWith(needs.build_and_deploy.outputs.project_version, '0.') && !contains(needs.build_and_deploy.outputs.project_version, '-RC') && !contains(needs.build_and_deploy.outputs.project_version, '-M') }} | |
run: | | |
echo "Tagging $REPO@$VERSION and creating release branch." | |
git checkout -b $VERSION | |
git push --set-upstream origin $VERSION | |
git tag v$VERSION | |
git push --tags origin | |
- name: Install tooling for Github release | |
run: | | |
curl -sSL https://github.com/cbroglie/mustache/releases/download/v1.2.2/mustache_1.2.2_linux_amd64.tar.gz | sudo tar -C /usr/local/bin/ --no-same-owner -xzv mustache | |
- name: Create Github release | |
env: | |
RELEASE_NOTES_ISSUES: ${{runner.temp}}/release_notes_issues.json | |
RELEASE_NOTES_FILE: ${{runner.temp}}/release_notes.md5 | |
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} | |
run: | | |
gh issue list \ | |
--repo spring-projects/spring-pulsar \ | |
--state all --json number,title,labels \ | |
--search milestone:$VERSION \ | |
--jq '{issues:map(select((.labels | length == 0) or (any(.labels[].name; startswith("automation/rlnotes")|not))) + {repo:"spring-projects/spring-pulsar"})}' \ | |
> $RELEASE_NOTES_ISSUES | |
mustache $RELEASE_NOTES_ISSUES .github/rlnotes.mustache > $RELEASE_NOTES_FILE | |
gh release create $VERSION \ | |
--draft \ | |
--title "Spring Pulsar $VERSION" \ | |
--generate-notes \ | |
--notes-file $RELEASE_NOTES_FILE | |
- 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 |