Skip to content

Commit

Permalink
Update release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndiritu committed Aug 13, 2024
1 parent 9b96625 commit b15252b
Showing 1 changed file with 54 additions and 7 deletions.
61 changes: 54 additions & 7 deletions .github/workflows/preview-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ on:
workflow_dispatch:

env:
PREVIEW_TASK: publishSnapshotPublicationToSonatypeSnapshotRepository
PUBLISH_TASK: publishMavenCentralReleasePublicationToSonatypeRepository
PREVIEW_TASK: publishToSonatype
PUBLISH_TASK: publishToSonatype closeAndReleaseSonatypeStagingRepository
JAVA_VERSION: 21
JAVA_DISTRIBUTION: 'temurin'

permissions:
contents: write
Expand All @@ -26,13 +28,14 @@ jobs:
environment:
name: maven_central_snapshot
runs-on: ubuntu-latest
needs: validate-package-contents
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION}}
cache: gradle
- name: Easy detect-secrets
uses: RobertFischer/[email protected]
Expand All @@ -58,13 +61,14 @@ jobs:
environment:
name: maven_central_release
runs-on: ubuntu-latest
needs: validate-package-contents
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION}}
cache: gradle
- name: Easy detect-secrets
uses: RobertFischer/[email protected]
Expand All @@ -83,7 +87,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Publish
run: ./gradlew $PUBLISH_TASK
run: ./gradlew $PUBLISH_TASK -PmavenCentralSnapshotArtifactSuffix=""
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -106,3 +110,46 @@ jobs:
fail_on_unmatched_files: true
files: |
build/**/*.jar
validate-package-contents:
runs-on: ubuntu-latest
environment: ${{ contains(github.ref, 'refs/tags/v') && 'maven_central_release' || '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_DISTRIBUTION}}
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: 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\s+= ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$minor = $contents | Select-String -Pattern 'mavenMinorVersion\s+= ([0-9]+)' | ForEach-Object { $_.Matches.Groups[1].Value }
$patch = $contents | Select-String -Pattern 'mavenPatchVersion\s+= ([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 msgraph-sdk-java -Version $env:PACKAGE_VERSION

0 comments on commit b15252b

Please sign in to comment.