52 lines
1.7 KiB
YAML
52 lines
1.7 KiB
YAML
name: Java Maven Build & Publish Artifact
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Repository wird geprüft...
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Buildvorgang wird Vorbereitet...
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: '17'
|
|
distribution: 'temurin'
|
|
cache: maven
|
|
|
|
- name: Buildvorgang gestartet
|
|
run: mvn -B package --file pom.xml
|
|
|
|
# Conditional steps for the main branch only
|
|
- if: github.ref == 'refs/heads/main'
|
|
name: Buildvorgang abgeschlossen, Release wird erstellt...
|
|
run: |
|
|
# Upload artifact
|
|
ARTIFACT_PATH=target/*.jar
|
|
echo "Uploading artifact located at $ARTIFACT_PATH"
|
|
# Placeholder for artifact upload command, as GitHub Actions does not support direct CLI uploads within run script
|
|
|
|
# Set release tag
|
|
RELEASE_TAG=$(date +'%Y%m%d%H%M%S')
|
|
echo "Release Tag: $RELEASE_TAG"
|
|
|
|
# Get commit message and description
|
|
COMMIT_MSG=$(git log --format=%B -n 1 ${{ github.sha }})
|
|
COMMIT_DESC=$(git show -s --format=%b ${{ github.sha }})
|
|
echo "Commit Message: $COMMIT_MSG"
|
|
echo "Commit Description: $COMMIT_DESC"
|
|
|
|
# Create Release - Placeholder for GitHub CLI command or API call to create release
|
|
echo "Creating release $RELEASE_TAG"
|
|
|
|
# Upload Artifact as Release Asset - Placeholder for GitHub CLI command or API call to upload release asset
|
|
echo "Uploading $ARTIFACT_PATH as release asset"
|
|
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|