Update maven.yml
This commit is contained in:
parent
3790ad0c81
commit
925ef98593
1 changed files with 18 additions and 40 deletions
58
.github/workflows/maven.yml
vendored
58
.github/workflows/maven.yml
vendored
|
@ -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
|
|
||||||
|
|
Loading…
Reference in a new issue