From afa08b8f4555dd3195d1edc8efff3c5507bd42a5 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Mon, 4 Mar 2024 09:16:32 +0100 Subject: [PATCH 1/2] Update maven.yml --- .github/workflows/maven.yml | 77 +++++++++++++------------------------ 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 95726c9..b587bd5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -2,74 +2,51 @@ name: Java Maven Build & Publish Artifact on: push: - branches: - - main + branches: [main] pull_request: - branches: - - main + branches: [main] jobs: - publish: + build-and-publish: runs-on: ubuntu-latest steps: - - name: Checkout Repository + - name: Repository wird geprüft... uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Buildvorgang wird Vorbereitet... uses: actions/setup-java@v3 with: java-version: '17' distribution: 'temurin' cache: maven - - name: Build with Maven + - name: Buildvorgang gestartet run: mvn -B package --file pom.xml - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: packaged-jar - path: target/*.jar - - - name: Set release tag - id: set_release_tag - run: echo "::set-output name=RELEASE_TAG::$(date +'%Y%m%d%H%M%S')" - - - name: Create extracted-jar directory - run: mkdir extracted-jar - - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: packaged-jar - path: extracted-jar - - - name: Get commit message and description - id: get_commit_info + # 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 "::set-output name=COMMIT_MSG::$COMMIT_MSG" - echo "::set-output name=COMMIT_DESC::$COMMIT_DESC" + 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" - - name: Create Release - id: create_release - uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.set_release_tag.outputs.RELEASE_TAG }} - release_name: ${{ steps.get_commit_info.outputs.COMMIT_MSG }} - body: ${{ steps.get_commit_info.outputs.COMMIT_DESC }} - draft: false - prerelease: false - - - name: Upload Artifact as Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: extracted-jar/ExtremeDemonList-0.0.1-SNAPSHOT-jar-with-dependencies.jar - asset_name: ExtremeDemonList-0.0.1-SNAPSHOT-jar-with-dependencies.jar - asset_content_type: application/ExtremeDemonList-0.0.1-SNAPSHOT-jar-with-dependencies.jar From 932dbcb3426ff4c091204a3747fa80fe01b1efde Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Mon, 4 Mar 2024 09:18:40 +0100 Subject: [PATCH 2/2] Update maven.yml --- .github/workflows/maven.yml | 77 ++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b587bd5..95726c9 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -2,51 +2,74 @@ name: Java Maven Build & Publish Artifact on: push: - branches: [main] + branches: + - main pull_request: - branches: [main] + branches: + - main jobs: - build-and-publish: + publish: runs-on: ubuntu-latest steps: - - name: Repository wird geprüft... + - name: Checkout Repository uses: actions/checkout@v3 - - name: Buildvorgang wird Vorbereitet... + - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' distribution: 'temurin' cache: maven - - name: Buildvorgang gestartet + - name: Build with Maven 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... + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: packaged-jar + path: target/*.jar + + - name: Set release tag + id: set_release_tag + run: echo "::set-output name=RELEASE_TAG::$(date +'%Y%m%d%H%M%S')" + + - name: Create extracted-jar directory + run: mkdir extracted-jar + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: packaged-jar + path: extracted-jar + + - name: Get commit message and description + id: get_commit_info 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" + echo "::set-output name=COMMIT_MSG::$COMMIT_MSG" + echo "::set-output name=COMMIT_DESC::$COMMIT_DESC" + - name: Create Release + id: create_release + uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.set_release_tag.outputs.RELEASE_TAG }} + release_name: ${{ steps.get_commit_info.outputs.COMMIT_MSG }} + body: ${{ steps.get_commit_info.outputs.COMMIT_DESC }} + draft: false + prerelease: false + + - name: Upload Artifact as Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: extracted-jar/ExtremeDemonList-0.0.1-SNAPSHOT-jar-with-dependencies.jar + asset_name: ExtremeDemonList-0.0.1-SNAPSHOT-jar-with-dependencies.jar + asset_content_type: application/ExtremeDemonList-0.0.1-SNAPSHOT-jar-with-dependencies.jar