Update maven.yml

This commit is contained in:
potzplitz 2024-03-03 13:58:47 +01:00 committed by GitHub
parent 3790ad0c81
commit 925ef98593
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,8 +11,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
@ -23,46 +24,23 @@ jobs:
- name: Build with Maven - name: Build with Maven
run: | run: |
mvn -B package --file pom.xml mvn -B package --file pom.xml
# Create target directory if not exists
mkdir -p target mkdir -p target
create_release: - name: Extract artifact
needs: build run: unzip target/*.zip -d target/artifact
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Generate tag
id: tag
run: echo "::set-output name=tag::$(date +'%Y%m%d%H%M%S')"
- name: Create Release - name: Get current timestamp
id: create_release id: timestamp
uses: actions/create-release@v1 run: echo "::set-output name=timestamp::$(date +%Y-%m-%d-%H-%M-%S)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.tag }}
release_name: Release ${{ steps.tag.outputs.tag }}
draft: false
prerelease: false
- name: Find Jar file - name: Create directory with run ID
id: find_jar run: mkdir -p ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }}
run: |
jar_path=$(find target -name '*.jar' -type f)
echo "::set-output name=jar_path::$jar_path"
- name: Upload Jar as Release Asset - name: Move artifact to directory with run ID
id: upload-release-asset run: mv target/artifact/* ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }}
uses: actions/upload-release-asset@v1
env: - name: Upload artifact
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: actions/upload-artifact@v2
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} name: artifact_${{ steps.timestamp.outputs.timestamp }}
asset_path: ${{ steps.find_jar.outputs.jar_path }} path: ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }}
asset_name: my-java-app.jar
asset_content_type: application/java-archive