Update maven.yml

This commit is contained in:
potzplitz 2024-03-03 14:01:22 +01:00 committed by GitHub
parent 925ef98593
commit f250eaccf3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 }}