Skip to content

Commit

Permalink
fixed release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
krrishnaaaa committed Oct 13, 2024
1 parent 8927276 commit 4087ee2
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,26 @@ jobs:
- name: ☕ Set up Zulu JDK 17
uses: actions/setup-java@v4
with:
java-version: '17' # Specify the JDK version
java-version: '17'
distribution: 'zulu'

# Step 3: Build the project and create shadowJar
- name: 🚧 Build with Gradle
run: ./gradlew shadowJar --no-daemon

# Step 4: Create a new release
# Step 4: Get the JAR file name
- name: Get JAR file name
id: jar-name
run: |
JAR_FILE=$(ls build/libs/*.jar)
echo "jar_file=$JAR_FILE" >> $GITHUB_ENV
# Step 5: Create a new release
- name: 📦 Create Release
id: create_release
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const { exec } = require('child_process');
const { promises: fs } = require('fs');
// Get the latest tag
Expand All @@ -51,21 +57,19 @@ jobs:
prerelease: false,
});
return release.data;
core.setOutput('release_id', release.data.id);
# Step 5: Upload the shadowJar artifact to the release
- name: 🎁 Upload shadowJar to Release
id: upload_jar
# Step 6: Install `ghr` (GitHub release tool)
- name: Install ghr
run: |
# Find the generated JAR file name
jar_file=$(ls build/libs/*.jar | grep -v '\-javadoc' | grep -v '\-sources' | head -n 1)
echo "Found JAR file: $jar_file"
echo "jar_file_name=$jar_file" >> $GITHUB_ENV
sudo apt-get update && sudo apt-get install -y ghr
- name: 🎁 Upload shadowJar to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.jar_file_name }}
asset_name: ${{ env.jar_file_name }} # Use the dynamic name here
asset_content_type: application/java-archive
# Step 7: Upload the JAR file to the release
- name: Upload JAR to Release
run: |
ghr -u "${GITHUB_REPOSITORY%/*}" \
-r "${GITHUB_REPOSITORY#*/}" \
"${GITHUB_REF#refs/tags/}" \
"${{ env.jar_file }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 4087ee2

Please sign in to comment.