Merge pull request #2220 from microsoftgraph/release-please--branches… #1957
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gradle Build and Compare Package | |
on: | |
push: | |
branches: [main, support/5.x.x] | |
pull_request: | |
branches: [main, support/5.x.x] | |
workflow_dispatch: | |
jobs: | |
build-java-latest: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: 'temurin' | |
cache: gradle | |
- name: Detect secrets | |
run: | | |
pip install detect-secrets | |
git ls-files -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline | |
- name: Grant Execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Upload Unit Test Results | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: UnitTests | |
path: | | |
build/reports/tests/test/** | |
build/test-results/** | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: drop | |
path: | | |
**/libs/* | |
build/generated-pom.xml | |
build/generated-pom.xml.asc | |
build.gradle | |
gradlew | |
gradlew.bat | |
settings.gradle | |
gradle.properties | |
**/gradle/** | |
scripts/** | |
build-java-8: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 8 | |
distribution: 'temurin' | |
cache: gradle | |
- name: Grant Execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Java 8 | |
working-directory: ./java-8 | |
run: .././gradlew build | |
build: | |
needs: [build-java-latest, build-java-8] | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
steps: | |
- name: Determine build status | |
run: | | |
if [ "${{ needs.build-java-latest.result }}" == "success" ] && [ "${{ needs.build-java-8.result }}" == "success" ]; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
compare-packages: | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
CURRENT_PKG_DIFF: ./artifacts/current/build/libs/msgraph-sdk-java.jar | |
PRIOR_PKG_DIFF: ./artifacts/previous/build/libs/msgraph-sdk-java.jar | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: 'temurin' | |
cache: gradle | |
- name: Download Current Build | |
uses: actions/download-artifact@v4 | |
with: | |
name: drop | |
path: artifacts/current/ | |
- name: Get latest release tag | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: echo "BRANCH=$(gh release list -L 1 --json tagName --jq '.[0] | .tagName')" >> $GITHUB_ENV | |
- name: Download Last Successful Build | |
uses: dawidd6/action-download-artifact@v6 | |
with: | |
workflow: preview-and-release.yml | |
workflow_conclusion: success | |
branch: ${{ env.BRANCH }} | |
event: push | |
name: drop | |
path: artifacts/previous/ | |
- name: Run PKG Diff | |
continue-on-error: true | |
run: | | |
sudo apt install pkgdiff | |
pkgdiff -hide-unchanged ${{ env.PRIOR_PKG_DIFF }} ${{ env.CURRENT_PKG_DIFF }} | |
- name: Upload Diff Artifact | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: diff | |
path: | | |
./pkgdiff_reports/** |