From cd159f5374e5ecbd7e780009d25c3c596197cd48 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 13:54:11 +0100 Subject: [PATCH 1/9] Update maven.yml --- .github/workflows/maven.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 765a5fe..f531caf 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -50,12 +50,6 @@ jobs: draft: false prerelease: false - - name: Find Jar files - id: find_jars - run: | - jars=$(find target -name '*.jar') - echo "::set-output name=jars::$jars" - - name: Upload Jar as Release Asset id: upload-release-asset uses: actions/upload-release-asset@v1 @@ -63,6 +57,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ steps.find_jars.outputs.jars }} + asset_path: builds asset_name: my-java-app.jar asset_content_type: application/java-archive From 3790ad0c819786e93e66788e64b53ba9bcf273a9 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 13:55:47 +0100 Subject: [PATCH 2/9] Update maven.yml --- .github/workflows/maven.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f531caf..5a06bfa 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -50,6 +50,12 @@ jobs: draft: false prerelease: false + - name: Find Jar file + id: find_jar + run: | + jar_path=$(find target -name '*.jar' -type f) + echo "::set-output name=jar_path::$jar_path" + - name: Upload Jar as Release Asset id: upload-release-asset uses: actions/upload-release-asset@v1 @@ -57,6 +63,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: builds + asset_path: ${{ steps.find_jar.outputs.jar_path }} asset_name: my-java-app.jar asset_content_type: application/java-archive From 925ef98593b6fff232af3f5b9c7f446037d03d33 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 13:58:47 +0100 Subject: [PATCH 3/9] Update maven.yml --- .github/workflows/maven.yml | 58 ++++++++++++------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5a06bfa..0875b18 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -11,8 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: @@ -23,46 +24,23 @@ jobs: - name: Build with Maven run: | mvn -B package --file pom.xml - # Create target directory if not exists mkdir -p target - create_release: - needs: build - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Generate tag - id: tag - run: echo "::set-output name=tag::$(date +'%Y%m%d%H%M%S')" + - name: Extract artifact + run: unzip target/*.zip -d target/artifact - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.tag.outputs.tag }} - release_name: Release ${{ steps.tag.outputs.tag }} - draft: false - prerelease: false + - name: Get current timestamp + id: timestamp + run: echo "::set-output name=timestamp::$(date +%Y-%m-%d-%H-%M-%S)" - - name: Find Jar file - id: find_jar - run: | - jar_path=$(find target -name '*.jar' -type f) - echo "::set-output name=jar_path::$jar_path" + - name: Create directory with run ID + run: mkdir -p ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} - - name: Upload Jar as Release Asset - id: upload-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: ${{ steps.find_jar.outputs.jar_path }} - asset_name: my-java-app.jar - asset_content_type: application/java-archive + - name: Move artifact to directory with run ID + run: mv target/artifact/* ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} + + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: artifact_${{ steps.timestamp.outputs.timestamp }} + path: ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} From f250eaccf3ae3b9968c7ad3565e3336a5c693e7f Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:01:22 +0100 Subject: [PATCH 4/9] Update maven.yml --- .github/workflows/maven.yml | 46 +++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0875b18..8e73395 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,4 +1,4 @@ -name: Java CI with Maven and Release +name: Java Maven Build & Upload Artifact on: push: @@ -7,40 +7,46 @@ on: branches: [ "main" ] jobs: - build: + build_test: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - + - 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 - mkdir -p target + 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: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: packaged-jar + path: staging - name: Extract artifact - run: unzip target/*.zip -d target/artifact + run: unzip staging/*.jar -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: Create directory with run ID - run: mkdir -p ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} + - name: Rename artifact directory with run ID + run: mv extracted-artifact ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }} - - name: Move artifact to directory with run ID - run: mv target/artifact/* ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} - - - name: Upload artifact - uses: actions/upload-artifact@v2 + - name: Upload extracted artifact + uses: actions/upload-artifact@v3 with: - name: artifact_${{ steps.timestamp.outputs.timestamp }} - path: ${{ github.workspace }}/target/artifact_${{ steps.timestamp.outputs.timestamp }} + name: extracted-artifact-${{ steps.timestamp.outputs.timestamp }} + path: ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }} From 6384fcde9c656c1ec6d98457f9d8eecf02a9af8b Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:03:46 +0100 Subject: [PATCH 5/9] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 8e73395..8928561 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -35,7 +35,7 @@ jobs: name: packaged-jar path: staging - name: Extract artifact - run: unzip staging/*.jar -d extracted-artifact + run: unzip staging/packaged-jar.zip -d extracted-artifact # Rename the directory to include the run ID - name: Get current timestamp From 37f6db6074a206fc06c2b5964ca64e2b070915a6 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:05:14 +0100 Subject: [PATCH 6/9] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 8928561..ea27c6a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -35,7 +35,7 @@ jobs: name: packaged-jar path: staging - name: Extract artifact - run: unzip staging/packaged-jar.zip -d extracted-artifact + run: unzip target/packaged-jar -d extracted-artifact # Rename the directory to include the run ID - name: Get current timestamp From 6d859bee36c4b8311b3d0ad011bb97645a4e17b5 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:07:51 +0100 Subject: [PATCH 7/9] Update maven.yml --- .github/workflows/maven.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ea27c6a..4d80d83 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -29,13 +29,15 @@ jobs: runs-on: ubuntu-latest needs: build_test steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 - with: - name: packaged-jar - path: staging - - name: Extract artifact - run: unzip target/packaged-jar -d extracted-artifact + - 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 From 93d3f687e2bc674420840bdb6ac2975fec418ad4 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:11:46 +0100 Subject: [PATCH 8/9] Update maven.yml --- .github/workflows/maven.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4d80d83..46e33d3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,12 +31,12 @@ jobs: 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" + 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 ${{ steps.get_artifact_url.outputs.download_url }} + 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 From 54d2123f5badb5c8e6093245080a4efc1157deb4 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Sun, 3 Mar 2024 14:14:34 +0100 Subject: [PATCH 9/9] Update maven.yml --- .github/workflows/maven.yml | 51 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 46e33d3..80ee6d5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,4 +1,4 @@ -name: Java Maven Build & Upload Artifact +name: Java Maven Build & Publish Artifact on: push: @@ -25,30 +25,33 @@ jobs: name: packaged-jar path: target/*.jar - extract-artifact: + publish-job: 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 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: - name: extracted-artifact-${{ steps.timestamp.outputs.timestamp }} - path: ${{ github.workspace }}/extracted-artifact_${{ steps.timestamp.outputs.timestamp }} + name: packaged-jar + path: staging + + create_release: + needs: publish-job + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Extract Artifact + run: | + unzip -o staging/packaged-jar/*.jar -d extracted-jar + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + files: | + extracted-jar/*