From ad8bcb5198b8c0a2770e56f95a07bef1e481e254 Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Wed, 11 Dec 2024 00:26:26 -0500 Subject: [PATCH] Add github actions for artifactory staging and maven central release --- .github/workflows/artifactory-staging.yml | 38 +++++++++++++ .github/workflows/maven-central-release.yml | 62 +++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 .github/workflows/artifactory-staging.yml create mode 100644 .github/workflows/maven-central-release.yml diff --git a/.github/workflows/artifactory-staging.yml b/.github/workflows/artifactory-staging.yml new file mode 100644 index 0000000..3f0303d --- /dev/null +++ b/.github/workflows/artifactory-staging.yml @@ -0,0 +1,38 @@ +name: Artifactory Staging + +on: + workflow_dispatch: + inputs: + releaseVersion: + description: "Release version" + required: true + +jobs: + build: + name: Stage release to Artifactory + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + + - name: Capture release version + run: echo RELEASE_VERSION=${{ github.event.inputs.releaseVersion }} >> $GITHUB_ENV + + - name: Update release version + run: mvn versions:set -DgenerateBackupPoms=false -DnewVersion=$RELEASE_VERSION + + - name: Enforce release rules + run: mvn org.apache.maven.plugins:maven-enforcer-plugin:enforce -Drules=requireReleaseDeps + + - name: Build with Maven and deploy to Artifactory staging repository + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + run: mvn -P artifactory-staging -s settings.xml --batch-mode -Dmaven.test.skip=true deploy diff --git a/.github/workflows/maven-central-release.yml b/.github/workflows/maven-central-release.yml new file mode 100644 index 0000000..af3abee --- /dev/null +++ b/.github/workflows/maven-central-release.yml @@ -0,0 +1,62 @@ +name: Maven Central Release + +on: + workflow_dispatch: + inputs: + releaseVersion: + description: "Release version" + required: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - name: Capture release version + run: echo RELEASE_VERSION=${{ github.event.inputs.releaseVersion }} >> $GITHUB_ENV + + - name: Prepare directory structure + run: | + mkdir -p nexus/org/springframework/experimental/spring-ai-mcp/$RELEASE_VERSION + mkdir -p nexus/org/springframework/experimental/spring-ai-mcp-core/$RELEASE_VERSION + mkdir -p nexus/org/springframework/experimental/spring-ai-mcp-spring/$RELEASE_VERSION + + - name: Download release files from Artifactory + env: + ARTIFACTORY_URL: "https://repo.spring.io/libs-staging-local/org/springframework/experimental" + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + run: | + echo "Downloading parent POM artifacts" + cd nexus/org/springframework/experimental/spring-ai-mcp/$RELEASE_VERSION + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp/$RELEASE_VERSION/spring-ai-mcp-$RELEASE_VERSION.pom + + echo "Downloading core artifacts" + cd ../../../../../.. + cd nexus/org/springframework/experimental/spring-ai-mcp-core/$RELEASE_VERSION + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp-core/$RELEASE_VERSION/spring-ai-mcp-core-$RELEASE_VERSION.pom + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp-core/$RELEASE_VERSION/spring-ai-mcp-core-$RELEASE_VERSION.jar + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp-core/$RELEASE_VERSION/spring-ai-mcp-core-$RELEASE_VERSION-javadoc.jar + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp-core/$RELEASE_VERSION/spring-ai-mcp-core-$RELEASE_VERSION-sources.jar + + echo "Downloading spring artifacts" + cd ../../../../../.. + cd nexus/org/springframework/experimental/spring-ai-mcp-spring/$RELEASE_VERSION + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp-spring/$RELEASE_VERSION/spring-ai-mcp-spring-$RELEASE_VERSION.pom + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp-spring/$RELEASE_VERSION/spring-ai-mcp-spring-$RELEASE_VERSION.jar + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp-spring/$RELEASE_VERSION/spring-ai-mcp-spring-$RELEASE_VERSION-javadoc.jar + wget --user="$ARTIFACTORY_USERNAME" --password="$ARTIFACTORY_PASSWORD" $ARTIFACTORY_URL/spring-ai-mcp-spring/$RELEASE_VERSION/spring-ai-mcp-spring-$RELEASE_VERSION-sources.jar + + - name: Sign artifacts and release them to Maven Central + uses: spring-io/nexus-sync-action@main + id: nexus + with: + url: ${{ secrets.OSSRH_URL }} + username: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }} + password: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }} + staging-profile-name: ${{ secrets.OSSRH_STAGING_PROFILE_NAME }} + create: true + upload: true + close: true + release: true + generate-checksums: true \ No newline at end of file