From 17a290af965256103667ea4f210964f7782e28d8 Mon Sep 17 00:00:00 2001 From: Oleksii PELYKH Date: Wed, 19 Jun 2024 14:36:44 +0200 Subject: [PATCH] (chore) ci: publish only after all builds --- .github/workflows/push.yaml | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 33c87e4..a9001a7 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -25,10 +25,6 @@ jobs: runs-on: ${{ matrix.os }} - permissions: - contents: read - packages: write - steps: - name: Checkout code uses: actions/checkout@v4 @@ -54,14 +50,42 @@ jobs: - name: Build with Gradle (Ubuntu) if: ${{ matrix.os == 'ubuntu-latest' }} - run: ./gradlew build -Dpcre4j.version=main-SNAPSHOT -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu + run: ./gradlew build -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu - name: Run tests (Ubuntu) if: ${{ matrix.os == 'ubuntu-latest' }} run: ./gradlew test -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu - - name: Publish + - name: Upload artifacts + uses: actions/upload-artifact@v4 if: ${{ matrix.os == 'ubuntu-latest' && matrix.java-distribution == 'temurin' }} + with: + path: ./*/build/libs/*.jar + + publish: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + needs: + - build + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Download artifacts + uses: actions/download-artifact@v4 + + - name: Publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew publishAllPublicationsToGitHubPackagesRepository + run: ./gradlew publishAllPublicationsToGitHubPackagesRepository -Dpcre4j.version=main-SNAPSHOT