Skip to content

Commit 0d17410

Browse files
committed
ci: migrate Maven Central release workflow to OSS Exit Gate
1 parent 056a0ac commit 0d17410

2 files changed

Lines changed: 92 additions & 5 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ on:
2121
description: "version number for this release."
2222
required: true
2323

24+
permissions: {}
25+
2426
jobs:
2527
build-maven-jars:
2628
runs-on: ubuntu-latest
2729
permissions:
2830
contents: write
31+
id-token: write
2932
steps:
3033
- name: Checkout
3134
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -59,15 +62,46 @@ jobs:
5962
env:
6063
GITHUB_EVENT_INPUTS_VERSION: ${{ github.event.inputs.version }}
6164

62-
- name: Deploy to Sonatype staging
65+
- name: Authenticate to Google Cloud
66+
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
67+
with:
68+
workload_identity_provider: "projects/305452601764/locations/global/workloadIdentityPools/builders/providers/github"
69+
70+
- name: Set up Cloud SDK
71+
uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1
72+
73+
- name: Clean up stale releases from staging repo
74+
run: |
75+
# clean up stale releases from staging repo
76+
packages=$(gcloud artifacts packages list \
77+
--project="oss-exit-gate-prod" \
78+
--location="us" \
79+
--repository="google-java-fmt--mavencentral" \
80+
--format="value(name)" 2>/dev/null)
81+
echo "${packages}" | xargs -r -I {} sh -c '
82+
package_name=$(basename "{}")
83+
echo "Deleting package: $package_name..."
84+
gcloud artifacts packages delete "{}" \
85+
--project="'"oss-exit-gate-prod"'" \
86+
--location="'"us"'" \
87+
--repository="'"google-java-fmt--mavencentral"'" \
88+
--quiet
89+
'
90+
91+
- name: Deploy to OSS Exit Gate staging and trigger release
6392
env:
64-
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
65-
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
6693
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
67-
run: mvn --no-transfer-progress -pl '!eclipse_plugin' -P sonatype-oss-release clean deploy -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}"
94+
RUN_ID: ${{ github.run_id }}
95+
RUN_ATTEMPT: ${{ github.run_attempt }}
96+
run: |
97+
mvn --no-transfer-progress -pl '!eclipse_plugin' -P sonatype-oss-release,oss-exit-gate clean deploy -Dgpg.passphrase="${GPG_PASSPHRASE}"
98+
echo '{"publish_all": true}' > manifest.json
99+
gcloud storage cp manifest.json "gs://oss-exit-gate-prod-projects-bucket/google-java-fmt/mavencentral/manifests/manifest-${RUN_ID}-${RUN_ATTEMPT}.json"
68100
69101
- name: Build Eclipse plugin
70-
run: mvn --no-transfer-progress -pl 'eclipse_plugin' verify gpg:sign -DskipTests=true -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}"
102+
env:
103+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
104+
run: mvn --no-transfer-progress -pl 'eclipse_plugin' verify gpg:sign -DskipTests=true -Dgpg.passphrase="${GPG_PASSPHRASE}"
71105

72106
- name: Push tag
73107
run: |

‎pom.xml‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,5 +373,58 @@
373373
<module>eclipse_plugin</module>
374374
</modules>
375375
</profile>
376+
<!-- OSS Exit Gate publishing profile (mvn deploy -P sonatype-oss-release,oss-exit-gate) -->
377+
<profile>
378+
<id>oss-exit-gate</id>
379+
<build>
380+
<extensions>
381+
<extension>
382+
<groupId>com.google.cloud.artifactregistry</groupId>
383+
<artifactId>artifactregistry-maven-wagon</artifactId>
384+
<version>2.2.5</version>
385+
</extension>
386+
</extensions>
387+
<plugins>
388+
<plugin>
389+
<groupId>org.sonatype.central</groupId>
390+
<artifactId>central-publishing-maven-plugin</artifactId>
391+
<configuration>
392+
<skipPublishing>true</skipPublishing>
393+
</configuration>
394+
</plugin>
395+
<plugin>
396+
<groupId>org.apache.maven.plugins</groupId>
397+
<artifactId>maven-deploy-plugin</artifactId>
398+
<executions>
399+
<execution>
400+
<id>oss-exit-gate-deploy</id>
401+
<phase>deploy</phase>
402+
<goals>
403+
<goal>deploy</goal>
404+
</goals>
405+
</execution>
406+
</executions>
407+
</plugin>
408+
</plugins>
409+
</build>
410+
<distributionManagement>
411+
<repository>
412+
<id>oss-exit-gate</id>
413+
<url>artifactregistry://us-maven.pkg.dev/oss-exit-gate-prod/google-java-fmt--mavencentral</url>
414+
</repository>
415+
</distributionManagement>
416+
<repositories>
417+
<repository>
418+
<id>oss-exit-gate</id>
419+
<url>artifactregistry://us-maven.pkg.dev/oss-exit-gate-prod/google-java-fmt--mavencentral</url>
420+
<releases>
421+
<enabled>true</enabled>
422+
</releases>
423+
<snapshots>
424+
<enabled>true</enabled>
425+
</snapshots>
426+
</repository>
427+
</repositories>
428+
</profile>
376429
</profiles>
377430
</project>

0 commit comments

Comments
 (0)