1414 workflow_dispatch :
1515
1616env :
17- PREVIEW_TASK : publishSnapshotPublicationToSonatypeSnapshotRepository
18- PUBLISH_TASK : publishMavenCentralReleasePublicationToSonatypeRepository
17+ PREVIEW_TASK : publishToSonatype
18+ PUBLISH_TASK : publishToSonatype closeAndReleaseSonatypeStagingRepository
19+ JAVA_VERSION : 21
20+ JAVA_DISTRIBUTION : ' temurin'
1921
2022permissions :
2123 contents : write
2628 environment :
2729 name : maven_central_snapshot
2830 runs-on : ubuntu-latest
31+ needs : validate-package-contents
2932 steps :
3033 - uses : actions/checkout@v4
3134 - name : Detect secrets
3538 - name : Set up JDK
3639 uses : actions/setup-java@v4
3740 with :
38- java-version : 21
39- distribution : ' temurin '
41+ java-version : ${{ env.JAVA_VERSION }}
42+ distribution : ${{ env.JAVA_DISTRIBUTION }}
4043 cache : gradle
4144 - name : Download File
4245 run : .\Scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
@@ -60,13 +63,14 @@ jobs:
6063 environment :
6164 name : maven_central_release
6265 runs-on : ubuntu-latest
66+ needs : validate-package-contents
6367 steps :
6468 - uses : actions/checkout@v4
6569 - name : Set up JDK
6670 uses : actions/setup-java@v4
6771 with :
68- java-version : 21
69- distribution : ' temurin '
72+ java-version : ${{ env.JAVA_VERSION }}
73+ distribution : ${{ env.JAVA_DISTRIBUTION }}
7074 cache : gradle
7175 - name : Detect secrets
7276 run : |
8791 - name : Grant execute permission for gradlew
8892 run : chmod +x gradlew
8993 - name : Publish
90- run : ./gradlew $PUBLISH_TASK
94+ run : ./gradlew $PUBLISH_TASK -PmavenCentralSnapshotArtifactSuffix=""
9195 - name : Upload Build Artifact
9296 uses : actions/upload-artifact@v4
9397 with :
@@ -110,3 +114,46 @@ jobs:
110114 fail_on_unmatched_files : true
111115 files : |
112116 build/**/*.jar
117+
118+ validate-package-contents :
119+ runs-on : ubuntu-latest
120+ environment : ${{ contains(github.ref, 'refs/tags/v') && 'maven_central_release' || 'maven_central_snapshot' }}
121+ defaults :
122+ run :
123+ working-directory : ./
124+ steps :
125+ - uses : actions/checkout@v4
126+ - name : Setup JDK
127+ uses : actions/setup-java@v4
128+ with :
129+ java-version : ${{ env.JAVA_VERSION }}
130+ distribution : ${{ env.JAVA_DISTRIBUTION}}
131+ cache : gradle
132+ - name : Download file
133+ run : .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
134+ shell : pwsh
135+ env :
136+ ENCODED_VALUE : ${{ secrets.LOCAL_PROPERTIES }}
137+ OUTPUT_PATH : ' local.properties'
138+ - name : Download file
139+ run : .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
140+ shell : pwsh
141+ env :
142+ ENCODED_VALUE : ${{ secrets.SECRING_GPG }}
143+ OUTPUT_PATH : ' .\secring.gpg'
144+ - name : Publish to local Maven cache for validation
145+ run : ./gradlew --no-daemon publishToMavenLocal
146+ - name : Get current SNAPSHOT version
147+ shell : pwsh
148+ run : |
149+ $contents = Get-Content gradle.properties -Raw
150+ $major = $contents | Select-String -Pattern 'mavenMajorVersion\s+= ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
151+ $minor = $contents | Select-String -Pattern 'mavenMinorVersion\s+= ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
152+ $patch = $contents | Select-String -Pattern 'mavenPatchVersion\s+= ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
153+ $version = "$major.$minor.$patch-SNAPSHOT"
154+ echo "Current version is $version"
155+ echo "PACKAGE_VERSION=$version" >> $Env:GITHUB_ENV
156+ - name : Inspect contents of local Maven cache
157+ shell : pwsh
158+ run : |
159+ .\scripts\validatePackageContents.ps1 -ArtifactId msgraph-beta-sdk-java -Version $env:PACKAGE_VERSION
0 commit comments