diff --git a/.azure-pipelines/buildAndPackage.yml b/.azure-pipelines/buildAndPackage.yml index 27f064a80..bb6fae967 100644 --- a/.azure-pipelines/buildAndPackage.yml +++ b/.azure-pipelines/buildAndPackage.yml @@ -30,10 +30,67 @@ pr: none pool: vmImage: windows-latest -steps: -- template: templates/checkout-and-credscan.yml -- template: templates/install-java.yml -- template: templates/secure-files.yml -- template: templates/build-and-coverage.yml -- template: templates/publish-artefacts.yml -- template: templates/alert-failure.yml +stages: +- stage: Build + jobs: + - job: Build + steps: + - template: templates/build/checkout-and-credscan.yml + - template: templates/build/install-java.yml + - template: templates/secure-files.yml + parameters: + stageID: 'build' + - template: templates/build/build-and-coverage.yml + - template: templates/build/publish-artefacts.yml + - template: templates/alert-failure.yml + +- stage: Maven-Preview + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev')) + jobs: + - deployment: Maven-Preview + environment: 'MSGraph SDK Development - Java' + pool: + vmImage: windows-latest + strategy: + runOnce: + deploy: + steps: + - template: templates/secure-files.yml + - template: templates/copy-and-build.yml + parameters: + task: 'publishSnapshotPublicationToSonatypeSnapshotRepository' + - template: templates/alert-failure.yml + +- stage: Maven-Release-And-Github-Release + dependsOn: [] + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + jobs: + - deployment: Maven-Release + environment: 'MSGraph SDK Development - Java' + pool: + vmImage: windows-latest + strategy: + runOnce: + deploy: + steps: + - template: templates/secure-files.yml + parameters: + stageID: 'release' + - template: templates/copy-and-build.yml + parameters: + task: 'publishMavenCentralReleasePublicationToSonatypeRepository' + - template: templates/alert-failure.yml + + - deployment: Github-Release + dependsOn: Maven-Release + environment: 'MSGraph SDK Development - Java' + pool: + vmImage: windows-latest + strategy: + runOnce: + deploy: + steps: + - template: templates/version-and-release.yml + parameters: + gitConnection: 'ramsessanchez' + - template: templates/alert-failure.yml diff --git a/.azure-pipelines/prValidate.yml b/.azure-pipelines/prValidate.yml deleted file mode 100644 index 04d26ac14..000000000 --- a/.azure-pipelines/prValidate.yml +++ /dev/null @@ -1,35 +0,0 @@ -#Copyright (c) Microsoft Corporation. All rights reserved. -#Licensed under the MIT License. -#Build and test Java Core to make sure a valid pull request is being made -#Validate that the versions dont conflict with those online in case a pull request is made to main or master - -pr: - branches: - include: - - dev - - main - - master - paths: - exclude: - - .gradle/wrapper - - .gitignore - - CONTRIBUTING.md - - LICENSE - - THIRD PARTY NOTICES - - gradle.properties - - gradlew - - gradlew.bat - - readme.md - - settings.gradle - - Scripts/* - -trigger: none # disable triggers based on commits. - -pool: - vmImage: windows-latest - -steps: -- template: templates/checkout-and-credscan.yml -- template: templates/install-java.yml -- template: templates/build-and-coverage.yml -- template: templates/alert-failure.yml diff --git a/.azure-pipelines/templates/build-and-coverage.yml b/.azure-pipelines/templates/build/build-and-coverage.yml similarity index 100% rename from .azure-pipelines/templates/build-and-coverage.yml rename to .azure-pipelines/templates/build/build-and-coverage.yml diff --git a/.azure-pipelines/templates/checkout-and-credscan.yml b/.azure-pipelines/templates/build/checkout-and-credscan.yml similarity index 100% rename from .azure-pipelines/templates/checkout-and-credscan.yml rename to .azure-pipelines/templates/build/checkout-and-credscan.yml diff --git a/.azure-pipelines/templates/install-java.yml b/.azure-pipelines/templates/build/install-java.yml similarity index 100% rename from .azure-pipelines/templates/install-java.yml rename to .azure-pipelines/templates/build/install-java.yml diff --git a/.azure-pipelines/templates/publish-artefacts.yml b/.azure-pipelines/templates/build/publish-artefacts.yml similarity index 73% rename from .azure-pipelines/templates/publish-artefacts.yml rename to .azure-pipelines/templates/build/publish-artefacts.yml index 5715208b2..fc7f7a4c3 100644 --- a/.azure-pipelines/templates/publish-artefacts.yml +++ b/.azure-pipelines/templates/build/publish-artefacts.yml @@ -15,7 +15,6 @@ steps: Scripts/** TargetFolder: '$(Build.ArtifactStagingDirectory)/' -- task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: drop' - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)' \ No newline at end of file +- publish: $(Build.ArtifactStagingDirectory) + artifact: Drop + displayName: Publish Build Artifact diff --git a/.azure-pipelines/templates/copy-and-build.yml b/.azure-pipelines/templates/copy-and-build.yml new file mode 100644 index 000000000..3617bfeaf --- /dev/null +++ b/.azure-pipelines/templates/copy-and-build.yml @@ -0,0 +1,23 @@ +parameters: +- name: task + type: string + default: '' + +steps: +- task: CopyFiles@2 + inputs: + SourceFolder: '$(Agent.TempDirectory)' + Contents: '**' + TargetFolder: '$(DROP_PATH)/' + +- task: Gradle@2 + inputs: + gradleWrapperFile: '$(DROP_PATH)/gradlew' + workingDirectory: '$(DROP_PATH)' + options: '-x jar -x javadoc -x javadocJar -x compileJava -x processResources -x classes -x sourceJar' + tasks: ${{ parameters.task }} + publishJUnitResults: true + testResultsFiles: '**/TEST-*.xml' + javaHomeOption: 'JDKVersion' + sonarQubeRunAnalysis: false + spotBugsAnalysis: false diff --git a/.azure-pipelines/templates/secure-files.yml b/.azure-pipelines/templates/secure-files.yml index 0cdeb85b9..7e5e716a5 100644 --- a/.azure-pipelines/templates/secure-files.yml +++ b/.azure-pipelines/templates/secure-files.yml @@ -1,18 +1,29 @@ +parameters: +- name: stageID + type: string + default: '' + steps: - task: DownloadSecureFile@1 inputs: secureFile: 'local.properties' + retryCount: '5' -- task: DownloadSecureFile@1 - inputs: - secureFile: 'secring.gpg' +- ${{ if or(eq(parameters.stageID, 'build'), eq(parameters.stageID, 'release') }}: + - task: DownloadSecureFile@1 + inputs: + secureFile: 'secring.gpg' + retryCount: '5' + + - task: DownloadSecureFile@1 + inputs: + secureFile: 'secring.gpg.lock' + retryCount: '5' -- task: DownloadSecureFile@1 - inputs: - secureFile: 'secring.gpg.lock' +- ${{ if eq(parameters.stageID, 'build') }}: + - task: CopyFiles@2 + inputs: + SourceFolder: '$(Agent.TempDirectory)' + Contents: '**' + TargetFolder: '$(System.DefaultWorkingDirectory)' -- task: CopyFiles@2 - inputs: - SourceFolder: '$(Agent.TempDirectory)' - Contents: '**' - TargetFolder: '$(System.DefaultWorkingDirectory)' \ No newline at end of file diff --git a/.azure-pipelines/templates/version-and-release.yml b/.azure-pipelines/templates/version-and-release.yml new file mode 100644 index 000000000..4eed424af --- /dev/null +++ b/.azure-pipelines/templates/version-and-release.yml @@ -0,0 +1,24 @@ +parameters: +- name: gitConnection + type: string + default: '' + +steps: +- task: PowerShell@2 + inputs: + filePath: '$(DROP_PATH)/Scripts/getLatestVersion.ps1' + arguments: '-propertiesPath "$(PROPERTIES_PATH)"' + +- task: GitHubRelease@1 + inputs: + gitHubConnection: ${{ parameters.gitConnection }} + repositoryName: '$(Build.Repository.Name)' + action: 'create' + target: '$(Build.SourceVersion)' + tagSource: 'userSpecifiedTag' + tag: '$(VERSION_STRING)' + assets: | + !**/** + $(Build.ArtifactStagingDirectory)/* + changeLogCompareToRelease: 'lastFullRelease' + changeLogType: 'commitBased' diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 38372fff6..87a956450 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -9,5 +9,5 @@ dependencies { implementation 'com.google.guava:guava:30.1.1-jre' implementation 'com.google.code.gson:gson:2.8.7' - api 'com.azure:azure-core:1.18.0' + api 'com.azure:azure-core:1.19.0' } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2367f3c17..3823f7259 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ com.azure azure-core - 1.18.0 + 1.19.0 org.junit.jupiter