Skip to content

Commit bda49f3

Browse files
committed
Final fix for release asset
1 parent 99c941c commit bda49f3

File tree

2 files changed

+64
-54
lines changed

2 files changed

+64
-54
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -80,57 +80,4 @@ jobs:
8080
if: always()
8181
run: |
8282
echo "Stopping Docker containers..."
83-
docker compose -f infra/docker-compose.yml down -v # -v removes volumes too
84-
create-release:
85-
needs: build-and-test-infra
86-
if: startsWith(github.ref, 'refs/tags/')
87-
runs-on: ubuntu-latest
88-
permissions:
89-
contents: write # Needed to create releases and upload assets
90-
91-
steps:
92-
# 1. Checkout Repository code - Needed to access build files/scripts
93-
- name: Checkout Repository
94-
uses: actions/checkout@v4
95-
96-
# 2. Set up JDK (Must match the version used for building)
97-
- name: Set up JDK 21
98-
uses: actions/setup-java@v4
99-
with:
100-
java-version: '21'
101-
distribution: 'temurin'
102-
103-
# 3. Grant permissions to gradle to execute commands
104-
- name: Grant execute permission for gradlew
105-
run: chmod +x gradlew
106-
107-
# Setup Gradle and Build the Shadow Jar
108-
- name: Setup Gradle and Build Shadow Jar
109-
uses: gradle/actions/setup-gradle@v4
110-
111-
# Build the jar
112-
- name: Build jar
113-
run: ./gradlew shadowJar
114-
115-
# 4. Find the specific Shadow Jar file
116-
# Adjust the pattern if your shadowJar output has a different name convention
117-
- name: Find Shadow Jar
118-
id: find_jar
119-
run: |
120-
# Common patterns: *-all.jar, *-shadow.jar, or just your plugin name + version.jar
121-
# This finds the largest JAR in build/libs, usually the shadowJar
122-
JAR_FILE=$(find plugin/build/libs -maxdepth 1 -name '*.jar' -printf "%s %p\n" | sort -nr | head -n 1 | awk '{print $2}')
123-
if [ -z "$JAR_FILE" ]; then
124-
echo "Error: Could not find the shadow JAR file in plugin/build/libs/"
125-
exit 1
126-
fi
127-
echo "Found JAR for release: $JAR_FILE"
128-
echo "path=$JAR_FILE" >> $GITHUB_OUTPUT
129-
130-
# 5. Create GitHub Release and Upload the Shadow Jar
131-
- name: Create Release and Upload JAR
132-
uses: softprops/action-gh-release@v2
133-
with:
134-
name: Release ${{ github.ref_name }}
135-
draft: true
136-
files: ${{ steps.find_jar.outputs.path }} # Upload the specific JAR found earlier
83+
docker compose -f infra/docker-compose.yml down -v # -v removes volumes too

.github/workflows/create_release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Create Release Asset
2+
3+
# Trigger the workflow only when a release is published
4+
on:
5+
release:
6+
types: [published] # Only run when a release goes from draft/pre-release to published, or is created as published
7+
8+
permissions:
9+
contents: write # Allow workflow to write release assets
10+
11+
jobs:
12+
build-and-upload:
13+
runs-on: ubuntu-latest
14+
steps:
15+
# 1. Checkout Repository code
16+
- name: Checkout code at release tag
17+
uses: actions/checkout@v4
18+
19+
# 2. Set up JDK (Must match the version used for building)
20+
- name: Set up JDK 21
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '21'
24+
distribution: 'temurin'
25+
26+
# 3. Give permission to gradle to execute commands
27+
- name: Grant execute permission for gradlew
28+
run: chmod +x gradlew
29+
30+
# Setup Gradle - This action handles caching and executing gradle tasks
31+
# It automatically finds and uses ./gradlew
32+
- name: Setup Gradle and Build Plugin Jar
33+
uses: gradle/actions/setup-gradle@v4 # Use v4 or latest stable version
34+
35+
# Gradle with the new updates doesn't support arguments
36+
- name: Build jar
37+
run: ./gradlew shadowJar
38+
39+
# 5. Find the specific Shadow Jar file and extract its name
40+
- name: Find Shadow Jar and Extract Name
41+
id: find_jar
42+
run: |
43+
JAR_PATH=$(find plugin/build/libs -maxdepth 1 -name '*.jar' -printf "%s %p\n" | sort -nr | head -n 1 | awk '{print $2}')
44+
if [ -z "$JAR_PATH" ]; then
45+
echo "Error: Could not find the shadow JAR file in plugin/build/libs/"
46+
exit 1
47+
fi
48+
JAR_FILENAME=$(basename "$JAR_PATH")
49+
echo "Found JAR path: $JAR_PATH"
50+
echo "Found JAR filename: $JAR_FILENAME"
51+
echo "path=$JAR_PATH" >> $GITHUB_OUTPUT
52+
echo "filename=$JAR_FILENAME" >> $GITHUB_OUTPUT
53+
shell: bash
54+
55+
# 6. Upload the Shadow Jar as a release asset
56+
- name: Upload Release Asset
57+
uses: svenstaro/upload-release-action@v2
58+
with:
59+
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
62+
tag: ${{ github.ref }} # The git tag associated with the release that triggered the workflow
63+
overwrite: true # Optional: Replace asset with the same name if it already exists

0 commit comments

Comments
 (0)