Skip to content

Merge pull request #1613 from microsoft/release-please--branches--main #355

Merge pull request #1613 from microsoft/release-please--branches--main

Merge pull request #1613 from microsoft/release-please--branches--main #355

Workflow file for this run

name: Gradle Build and Publish
on:
workflow_dispatch:
push:
tags: ['v*']
branches: ['main']
permissions:
contents: write
env:
PREVIEW_TASK: publishToSonatype
PUBLISH_TASK: publishToSonatype closeAndReleaseSonatypeStagingRepository
JAVA_VERSION: 21
JAVA_DIST: 'temurin'
jobs:
release-to-maven-central-snapshot:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: maven_central_snapshot
needs: validate-package-contents
defaults:
run:
working-directory: ./
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST }}
cache: gradle
- name: Detect secrets
run: |
pip install detect-secrets
git ls-files -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline
- name: Download file
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
shell: pwsh
env:
ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }}
OUTPUT_PATH: 'local.properties'
- name: Download file
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
shell: pwsh
env:
ENCODED_VALUE: ${{ secrets.SECRING_GPG }}
OUTPUT_PATH: 'secring.gpg'
- name: Copy secring
run: |
Copy-Item secring.gpg components/abstractions/ -Verbose
Copy-Item secring.gpg components/authentication/azure/ -Verbose
Copy-Item secring.gpg components/serialization/form/ -Verbose
Copy-Item secring.gpg components/serialization/text/ -Verbose
Copy-Item secring.gpg components/serialization/json/ -Verbose
Copy-Item secring.gpg components/serialization/multipart/ -Verbose
Copy-Item secring.gpg components/http/okHttp/ -Verbose
Copy-Item secring.gpg components/bundle/ -Verbose
shell: pwsh
- name: Publish to Snapshot Repository
run: ./gradlew --no-daemon $PREVIEW_TASK
working-directory: ./
validate-package-contents:
runs-on: ubuntu-latest
environment: ${{ contains(github.ref, 'refs/tags/v') && 'maven_central' || 'maven_central_snapshot' }}
defaults:
run:
working-directory: ./
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST}}
cache: gradle
- name: Detect secrets
run: |
pip install detect-secrets
git ls-files -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline
- name: Download file
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
shell: pwsh
env:
ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }}
OUTPUT_PATH: 'local.properties'
- name: Download file
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
shell: pwsh
env:
ENCODED_VALUE: ${{ secrets.SECRING_GPG }}
OUTPUT_PATH: 'secring.gpg'
- name: Copy secring
run: |
Copy-Item secring.gpg components/abstractions/ -Verbose
Copy-Item secring.gpg components/authentication/azure/ -Verbose
Copy-Item secring.gpg components/serialization/form/ -Verbose
Copy-Item secring.gpg components/serialization/text/ -Verbose
Copy-Item secring.gpg components/serialization/json/ -Verbose
Copy-Item secring.gpg components/serialization/multipart/ -Verbose
Copy-Item secring.gpg components/http/okHttp/ -Verbose
Copy-Item secring.gpg components/bundle/ -Verbose
shell: pwsh
- name: Publish to local Maven cache for validation
run: ./gradlew --no-daemon publishToMavenLocal
- name: Get current SNAPSHOT version
shell: pwsh
run: |
$contents = Get-Content gradle.properties -Raw
$major = $contents | Select-String -Pattern 'mavenMajorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$minor = $contents | Select-String -Pattern 'mavenMinorVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$patch = $contents | Select-String -Pattern 'mavenPatchVersion = ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$version = "$major.$minor.$patch-SNAPSHOT"
echo "Current version is $version"
echo "PACKAGE_VERSION=$version" >> $Env:GITHUB_ENV
- name: Inspect contents of local Maven cache
shell: pwsh
run: |
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-abstractions -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-authentication-azure -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-http-okHttp -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-form -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-json -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-text -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-serialization-multipart -Version $env:PACKAGE_VERSION
.\scripts\ValidatePackageContents.ps1 -ArtifactId microsoft-kiota-bundle -Version $env:PACKAGE_VERSION
release-maven-central:
if: ${{ contains(github.ref, 'refs/tags/v') && github.actor == 'release-please[bot]' }}
runs-on: ubuntu-latest
environment: maven_central
needs: validate-package-contents
defaults:
run:
working-directory: ./
strategy:
max-parallel: 1
matrix:
component-path: [
abstractions,
authentication/azure,
http/okHttp,
serialization/form,
serialization/json,
serialization/text,
serialization/multipart,
bundle
]
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST}}
cache: gradle
- name: Download file
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
shell: pwsh
env:
ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }}
OUTPUT_PATH: 'local.properties'
- name: Download file
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
shell: pwsh
env:
ENCODED_VALUE: ${{ secrets.SECRING_GPG }}
OUTPUT_PATH: 'secring.gpg'
- name: Copy secring
run: |
Copy-Item secring.gpg components/${{ matrix.component-path }}/ -Verbose
shell: pwsh
- name: Publish Release abstractions
run: |
componentTaskPath=$(echo ${{ matrix.component-path }} | tr / :)
./gradlew -i --no-daemon :components:$componentTaskPath:$PUBLISH_TASK -PmavenCentralSnapshotArtifactSuffix=""
release-to-github:
if: contains(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST}}
cache: gradle
- name: Build with Gradle
run: ./gradlew --no-daemon build
- name: GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: true
files: |
components/**/build/libs/*.jar
components/**/**/build/libs/*.jar