54 lines
1.7 KiB
YAML
54 lines
1.7 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:
|
|
- name: Download artifact
|
|
run: |
|
|
URL="https://github.com/potzplitz/ExtremeDemonList/actions/runs/${{ github.run_id }}/artifacts/${{ job.outputs.artifact_id }}"
|
|
echo "::set-output name=download_url::$URL"
|
|
id: get_artifact_url
|
|
- name: Download and extract artifact
|
|
run: |
|
|
wget -O artifact.zip ${{ steps.get_artifact_url.outputs.download_url }}
|
|
unzip artifact.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 }}
|