Update maven.yml
This commit is contained in:
parent
925ef98593
commit
f250eaccf3
1 changed files with 26 additions and 20 deletions
46
.github/workflows/maven.yml
vendored
46
.github/workflows/maven.yml
vendored
|
@ -1,4 +1,4 @@
|
||||||
name: Java CI with Maven and Release
|
name: Java Maven Build & Upload Artifact
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -7,40 +7,46 @@ on:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build_test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v3
|
||||||
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:
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
cache: maven
|
cache: maven
|
||||||
|
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: |
|
run: mvn -B package --file pom.xml
|
||||||
mvn -B package --file pom.xml
|
- name: Upload artifact
|
||||||
mkdir -p target
|
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
|
- 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
|
- name: Get current timestamp
|
||||||
id: timestamp
|
id: timestamp
|
||||||
run: echo "::set-output name=timestamp::$(date +%Y-%m-%d-%H-%M-%S)"
|
run: echo "::set-output name=timestamp::$(date +%Y-%m-%d-%H-%M-%S)"
|
||||||
|
|
||||||
- name: Create directory with run ID
|
- name: Rename artifact directory with run ID
|
||||||
run: mkdir -p ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }}
|
run: mv extracted-artifact ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }}
|
||||||
|
|
||||||
- name: Move artifact to directory with run ID
|
- name: Upload extracted artifact
|
||||||
run: mv target/artifact/* ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }}
|
uses: actions/upload-artifact@v3
|
||||||
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
with:
|
||||||
name: artifact_${{ steps.timestamp.outputs.timestamp }}
|
name: extracted-artifact-${{ steps.timestamp.outputs.timestamp }}
|
||||||
path: ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }}
|
path: ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }}
|
||||||
|
|
Loading…
Reference in a new issue