Skip to content

Commit d346991

Browse files
committed
Deploy with Maven Central Portal
Signed-off-by: Chris Bono <[email protected]> (cherry picked from commit 5f6cfd1)
1 parent 136fb12 commit d346991

File tree

7 files changed

+35
-110
lines changed

7 files changed

+35
-110
lines changed

.github/workflows/central-release.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
runjobs: ${{ steps.continue.outputs.runjobs }}
3636
project_version: ${{ steps.continue.outputs.project_version }}
3737
boot_version: ${{ steps.continue.outputs.boot_version }}
38+
should_deploy_artifacts: ${{ steps.should-deploy-artifacts.outputs.result }}
3839
steps:
3940
- uses: actions/checkout@v4
4041
- id: continue
@@ -47,6 +48,15 @@ jobs:
4748
echo "project_version=$version" >>$GITHUB_OUTPUT
4849
bootVersion=$(cat gradle/libs.versions.toml | grep "spring-boot = \"" | cut -d '"' -f2)
4950
echo "boot_version=$bootVersion" >>$GITHUB_OUTPUT
51+
- id: should-deploy-artifacts
52+
name: Check Deploy Artifacts using Secrets
53+
if: ${{ runner.os == 'Linux' }}
54+
run: |
55+
if [[ -z "$ARTIFACTORY_PASSWORD" ]] ; then
56+
echo "result=false" >> $GITHUB_OUTPUT
57+
else
58+
echo "result=true" >> $GITHUB_OUTPUT
59+
fi
5060
build_jdk_17:
5161
name: Build (JDK 17)
5262
needs: [prerequisites]
@@ -97,28 +107,20 @@ jobs:
97107
-PspringBootVersion="$BOOT_VERSION" \
98108
-PsampleTests \
99109
:runAllSampleTests
110+
100111
scan:
101112
needs: [prerequisites]
102113
if: ${{ needs.prerequisites.outputs.runjobs && !contains(inputs.run-trivy-scan, 'false') }}
103114
uses: ./.github/workflows/trivy-scan.yml
104115
deploy_artifacts:
105116
name: Deploy Artifacts
106117
needs: [build_jdk_17, check_samples, scan]
107-
runs-on: ubuntu-latest
108-
steps:
109-
- uses: actions/checkout@v4
110-
- uses: spring-io/spring-gradle-build-action@v2
111-
- name: Deploy artifacts
112-
env:
113-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
114-
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
115-
OSSRH_TOKEN_USERNAME: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
116-
OSSRH_TOKEN_PASSWORD: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
117-
run: |
118-
./gradlew publishArtifacts finalizeDeployArtifacts \
119-
--stacktrace \
120-
-PossrhUsername="$OSSRH_TOKEN_USERNAME" -PossrhPassword="$OSSRH_TOKEN_PASSWORD" \
121-
-PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD"
118+
uses: spring-io/spring-security-release-tools/.github/workflows/deploy-artifacts.yml@v1
119+
with:
120+
should-deploy-artifacts: ${{ needs.prerequisites.outputs.should_deploy_artifacts }}
121+
default-publish-milestones-central: true
122+
secrets: inherit
123+
122124
deploy_docs_antora:
123125
name: Deploy Antora Docs
124126
needs: [build_jdk_17, check_samples, scan]
@@ -155,31 +157,39 @@ jobs:
155157
REPO: ${{ github.repository }}
156158
BRANCH: ${{ github.ref_name }}
157159
VERSION: ${{ needs.prerequisites.outputs.project_version }}
160+
TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
161+
MILESTONE_REPO: https://repo1.maven.org/maven2
162+
RELEASE_REPO: https://repo1.maven.org/maven2
163+
ARTIFACT_PATH: org/springframework/pulsar/spring-pulsar
158164
steps:
159165
- uses: actions/checkout@v4
160166
with:
161167
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
162168
- uses: spring-io/spring-gradle-build-action@v2
163-
- name: Wait for Artifactory artifacts (milestone)
169+
- name: Wait for Milestone Artifacts
164170
if: ${{ contains(needs.prerequisites.outputs.project_version, '-RC') || contains(needs.prerequisites.outputs.project_version, '-M') }}
171+
env:
172+
VERSION: ${{ needs.prerequisites.outputs.project_version }}
165173
run: |
166-
echo "Wait for artifacts of $REPO@$VERSION to appear on Artifactory."
167-
until curl -f -s https://repo.spring.io/artifactory/milestone/org/springframework/pulsar/spring-pulsar/$VERSION/ > /dev/null
174+
echo "Wait for artifacts of $REPO@$VERSION to appear on milestone repository ($MILESTONE_REPO)."
175+
until curl -f -s $MILESTONE_REPO/$ARTIFACT_PATH/$VERSION/ > /dev/null
168176
do
169177
sleep 30
170178
echo "."
171179
done
172-
echo "Artifacts for $REPO@$VERSION have been released to Artifactory."
173-
- name: Wait for Maven Central artifacts (GA)
174-
if: ${{ !contains(needs.prerequisites.outputs.project_version, '-SNAPSHOT') && !contains(needs.prerequisites.outputs.project_version, '-RC') && !contains(needs.prerequisites.outputs.project_version, '-M') }}
180+
echo "Artifacts for $REPO@$VERSION have been released to milestone repository ($MILESTONE_REPO)."
181+
- name: Wait for Release Artifacts
182+
if: ${{ !contains(needs.prerequisites.outputs.project_version.version, '-RC') && !contains(needs.prerequisites.outputs.project_version, '-M') }}
183+
env:
184+
VERSION: ${{ needs.prerequisites.outputs.project_version }}
175185
run: |
176-
echo "Wait for artifacts of $REPO@$VERSION to appear on Maven Central."
177-
until curl -f -s https://repo1.maven.org/maven2/org/springframework/pulsar/spring-pulsar/$VERSION/ > /dev/null
186+
echo "Wait for artifacts of $REPO@$VERSION to appear on release repository ($RELEASE_REPO)."
187+
until curl -f -s $RELEASE_REPO/$ARTIFACT_PATH/$VERSION/ > /dev/null
178188
do
179189
sleep 30
180190
echo "."
181191
done
182-
echo "Artifacts for $REPO@$VERSION have been released to Maven Central."
192+
echo "Artifacts for $REPO@$VERSION have been released to release repository ($RELEASE_REPO)."
183193
- name: Setup git for release tagging
184194
run: |
185195
git config user.name 'github-actions[bot]'

buildSrc/src/main/java/org/springframework/pulsar/gradle/RootProjectPlugin.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818

1919
import org.gradle.api.Plugin;
2020
import org.gradle.api.Project;
21-
import org.gradle.api.Task;
2221
import org.gradle.api.plugins.BasePlugin;
2322
import org.gradle.api.plugins.PluginManager;
2423

2524
import org.springframework.pulsar.gradle.check.SonarQubeConventionsPlugin;
26-
import org.springframework.pulsar.gradle.publish.SpringNexusPublishPlugin;
2725

2826
import io.spring.gradle.convention.ArtifactoryPlugin;
2927

@@ -37,15 +35,9 @@ public class RootProjectPlugin implements Plugin<Project> {
3735
public void apply(final Project project) {
3836
PluginManager pluginManager = project.getPluginManager();
3937
pluginManager.apply(BasePlugin.class);
40-
pluginManager.apply(SpringNexusPublishPlugin.class);
4138
pluginManager.apply(ArtifactoryPlugin.class);
4239
pluginManager.apply(SonarQubeConventionsPlugin.class);
4340
project.getRepositories().mavenCentral();
44-
45-
Task finalizeDeployArtifacts = project.task("finalizeDeployArtifacts");
46-
if (ProjectUtils.isRelease(project) && project.hasProperty("ossrhUsername")) {
47-
finalizeDeployArtifacts.dependsOn(project.getTasks().findByName("closeOssrhStagingRepository"));
48-
}
4941
}
5042

5143
}

buildSrc/src/main/java/org/springframework/pulsar/gradle/publish/PublishArtifactsPlugin.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

buildSrc/src/main/java/org/springframework/pulsar/gradle/publish/SpringMavenPlugin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public void apply(Project project) {
1515
pluginManager.apply(SpringSigningPlugin.class);
1616
pluginManager.apply(MavenPublishingConventionsPlugin.class);
1717
pluginManager.apply(PublishLocalPlugin.class);
18-
pluginManager.apply(PublishArtifactsPlugin.class);
1918
pluginManager.apply(ArtifactoryPlugin.class);
2019
}
2120
}

buildSrc/src/main/java/org/springframework/pulsar/gradle/publish/SpringNexusPublishPlugin.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

buildSrc/src/main/java/org/springframework/pulsar/gradle/publish/SpringSigningPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void apply(Project project) {
4040

4141
private void sign(Project project) {
4242
SigningExtension signing = project.getExtensions().findByType(SigningExtension.class);
43-
signing.setRequired((Callable<Boolean>) () -> project.getGradle().getTaskGraph().hasTask("publishArtifacts"));
43+
signing.setRequired((Callable<Boolean>) () -> project.getGradle().getTaskGraph().hasTask("artifactoryPublish"));
4444
String signingKeyId = (String) project.findProperty("signingKeyId");
4545
String signingKey = (String) project.findProperty("signingKey");
4646
String signingPassword = (String) project.findProperty("signingPassword");

0 commit comments

Comments
 (0)