52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
name: Java Maven Build & Upload Artifact
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
jobs:
|
|
build_test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- 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
|
|
- 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 staging/packaged-jar.zip -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: Rename artifact directory with run ID
|
|
run: mv extracted-artifact ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }}
|
|
|
|
- name: Upload extracted artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: extracted-artifact-${{ steps.timestamp.outputs.timestamp }}
|
|
path: ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }}
|