diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 2d34b62..411c08f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,65 +1,46 @@ -name: Build und Veröffentlichen des Java-Projekts +name: Java Build and File Update on: push: branches: - main - pull_request: - branches: - - main - -permissions: - contents: write jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout des Codes + - name: Checkout code uses: actions/checkout@v2 - - name: Setze JDK 17 ein + - name: Set up JDK uses: actions/setup-java@v2 with: java-version: '17' - distribution: 'temurin' + distribution: 'adopt' + server-id: 'github' + server-username: ${{ github.actor }} + server-password: ${{ secrets.GITHUB_TOKEN }} - - name: Konfiguriere Git-Benutzer + - name: Build Java project with Maven + run: mvn clean package + + - name: Check if JAR files exist run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" + if [ ! -d "target" ] || [ -z "$(ls -A target/*.jar)" ]; then + echo "No JAR files found in target directory or target directory does not exist." + exit 1 + fi - - name: Bestimme Versionsnummer - id: version - run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV + - name: Create builds directory + run: mkdir -p builds + + - name: Copy built JAR files + run: cp -r target/*.jar builds/ - - name: Erstelle Git-Tag - run: git tag v${{ steps.version.outputs.VERSION }} -a -m "Generierter Tag von GitHub Actions" - - - name: Sende Tags - run: git push --tags --quiet - - - name: Baue mit Maven - run: mvn clean install - - - name: Erstelle Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ steps.version.outputs.VERSION }} - release_name: Release v${{ steps.version.outputs.VERSION }} - draft: false - prerelease: false - - - name: Lade Artefakt zur Veröffentlichung hoch - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./builds/ExtremeDemonList-${{ steps.version.outputs.VERSION }}-SNAPSHOT.jar - asset_name: ExtremeDemonList-${{ steps.version.outputs.VERSION }}-SNAPSHOT.jar - asset_content_type: application/java-archive + - name: Update version.txt + run: | + sed -i 's/old_text/new_text/g' ver/version.txt + git add ver/version.txt builds/*.jar + git commit -m "Updated version and built JAR files" + git push