From f250eaccf3ae3b9968c7ad3565e3336a5c693e7f Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:01:22 +0100 Subject: [PATCH] Update maven.yml --- .github/workflows/maven.yml | 46 +++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0875b18..8e73395 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,4 +1,4 @@ -name: Java CI with Maven and Release +name: Java Maven Build & Upload Artifact on: push: @@ -7,40 +7,46 @@ on: branches: [ "main" ] jobs: - build: + build_test: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - + - uses: actions/checkout@v3 - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' distribution: 'temurin' cache: maven - - name: Build with Maven - run: | - mvn -B package --file pom.xml - mkdir -p target + run: mvn -B package --file pom.xml + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: packaged-jar + path: target/*.jar + extract-artifact: + runs-on: ubuntu-latest + needs: build_test + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: packaged-jar + path: staging - name: Extract artifact - run: unzip target/*.zip -d target/artifact + run: unzip staging/*.jar -d extracted-artifact + # Rename the directory to include the run ID - name: Get current timestamp id: timestamp run: echo "::set-output name=timestamp::$(date +%Y-%m-%d-%H-%M-%S)" - - name: Create directory with run ID - run: mkdir -p ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} + - name: Rename artifact directory with run ID + run: mv extracted-artifact ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }} - - name: Move artifact to directory with run ID - run: mv target/artifact/* ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} - - - name: Upload artifact - uses: actions/upload-artifact@v2 + - name: Upload extracted artifact + uses: actions/upload-artifact@v3 with: - name: artifact_${{ steps.timestamp.outputs.timestamp }} - path: ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} + name: extracted-artifact-${{ steps.timestamp.outputs.timestamp }} + path: ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }}