Skip to content

Commit 753c706

Browse files
committed
Enhance CI workflows to build and upload both Bukkit and Velocity JARs as release assets
1 parent 4f81480 commit 753c706

File tree

2 files changed

+49
-15
lines changed

2 files changed

+49
-15
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,25 @@ jobs:
3333
- name: Setup Gradle and Build Plugin Jar
3434
uses: gradle/actions/setup-gradle@v4 # Use v4 or latest stable version
3535

36-
# Gradle with the new updates doesn't support arguments
37-
- name: Build jar
36+
# Build both Bukkit and Velocity JARs
37+
- name: Build JAR files
3838
run: ./gradlew shadowJar
3939

40-
# Upload JAR as an artifact (NEW STEP)
41-
- name: Upload JAR Artifact
40+
# Upload Bukkit JAR as an artifact
41+
- name: Upload Bukkit JAR Artifact
4242
uses: actions/upload-artifact@v4
4343
with:
44-
name: plugin-jar
45-
path: bukkit/build/libs/*.jar # Adjust this path to match your JAR location
44+
name: serverpulse-bukkit-jar
45+
path: bukkit/build/libs/serverpulse-bukkit-*.jar
46+
retention-days: 14 # Keep artifacts for 14 days
47+
if-no-files-found: error # Fail the workflow if no JARs are found
48+
49+
# Upload Velocity JAR as an artifact
50+
- name: Upload Velocity JAR Artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: serverpulse-velocity-jar
54+
path: velocity/build/libs/serverpulse-velocity-*.jar
4655
retention-days: 14 # Keep artifacts for 14 days
4756
if-no-files-found: error # Fail the workflow if no JARs are found
4857

@@ -53,7 +62,6 @@ jobs:
5362
run: sudo apt-get update && sudo apt-get install -y jq
5463

5564
# 5. Start Docker Compose services in detached mode
56-
# Replace 'path/to/your/docker-compose.yml' if it's not in the root
5765
- name: Start Docker Infrastructure
5866
run: docker compose -f infra/docker-compose.yml up -d
5967

.github/workflows/create_release.yml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create Release Asset
1+
name: Create Release Assets
22

33
# Trigger the workflow only when a release is published
44
on:
@@ -36,9 +36,9 @@ jobs:
3636
- name: Build jar
3737
run: ./gradlew shadowJar
3838

39-
# 5. Find the specific Shadow Jar file and extract its name
40-
- name: Find Shadow Jar and Extract Name
41-
id: find_jar
39+
# 5. Find the Bukkit Shadow Jar file and extract its name
40+
- name: Find Bukkit Shadow Jar and Extract Name
41+
id: find_bukkit_jar
4242
run: |
4343
JAR_PATH=$(find bukkit/build/libs -maxdepth 1 -name '*.jar' -printf "%s %p\n" | sort -nr | head -n 1 | awk '{print $2}')
4444
if [ -z "$JAR_PATH" ]; then
@@ -52,12 +52,38 @@ jobs:
5252
echo "filename=$JAR_FILENAME" >> $GITHUB_OUTPUT
5353
shell: bash
5454

55-
# 6. Upload the Shadow Jar as a release asset
56-
- name: Upload Release Asset
55+
# 6. Find the Velocity Shadow Jar file and extract its name
56+
- name: Find Velocity Shadow Jar and Extract Name
57+
id: find_velocity_jar
58+
run: |
59+
JAR_PATH=$(find velocity/build/libs -maxdepth 1 -name '*.jar' -printf "%s %p\n" | sort -nr | head -n 1 | awk '{print $2}')
60+
if [ -z "$JAR_PATH" ]; then
61+
echo "Error: Could not find the shadow JAR file in velocity/build/libs/"
62+
exit 1
63+
fi
64+
JAR_FILENAME=$(basename "$JAR_PATH")
65+
echo "Found JAR path: $JAR_PATH"
66+
echo "Found JAR filename: $JAR_FILENAME"
67+
echo "path=$JAR_PATH" >> $GITHUB_OUTPUT
68+
echo "filename=$JAR_FILENAME" >> $GITHUB_OUTPUT
69+
shell: bash
70+
71+
# 7. Upload the Bukkit Shadow Jar as a release asset
72+
- name: Upload Bukkit Release Asset
5773
uses: svenstaro/upload-release-action@v2
5874
with:
5975
repo_token: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions automatically
60-
file: ${{ steps.find_jar.outputs.path }} # The path to the JAR found in the previous step
61-
asset_name: ${{ steps.find_jar.outputs.filename }} # Use the filename extracted earlier
76+
file: ${{ steps.find_bukkit_jar.outputs.path }} # The path to the JAR found in the previous step
77+
asset_name: ${{ steps.find_bukkit_jar.outputs.filename }} # Use the filename extracted earlier
6278
tag: ${{ github.ref }} # The git tag associated with the release that triggered the workflow
6379
overwrite: true # Optional: Replace asset with the same name if it already exists
80+
81+
# 8. Upload the Velocity Shadow Jar as a release asset
82+
- name: Upload Velocity Release Asset
83+
uses: svenstaro/upload-release-action@v2
84+
with:
85+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions automatically
86+
file: ${{ steps.find_velocity_jar.outputs.path }} # The path to the JAR found in the previous step
87+
asset_name: ${{ steps.find_velocity_jar.outputs.filename }} # Use the filename extracted earlier
88+
tag: ${{ github.ref }} # The git tag associated with the release that triggered the workflow
89+
overwrite: true # Optional: Replace asset with the same name if it already exists

0 commit comments

Comments
 (0)