ExtremeDemonList/.github/workflows/maven.yml
2024-03-03 14:11:46 +01:00

54 lines
1.8 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: |
ARTIFACT_URL=$(curl -s "https://github.com/potzplitz/ExtremeDemonList/actions/runs/${{ github.run_id }}/artifacts" | grep -oP '(?<=href=")[^"]+(?=")' | grep -m 1 -oP '\d+$')
echo "::set-output name=artifact_url::$ARTIFACT_URL"
id: get_artifact_url
- name: Download and extract artifact
run: |
wget -O artifact.zip "https://github.com/potzplitz/ExtremeDemonList/actions/runs/${{ github.run_id }}/artifacts/download/${{ steps.get_artifact_url.outputs.artifact_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 }}