Skip to content

Merge pull request #1 from krrishnaaaa/update #1

Merge pull request #1 from krrishnaaaa/update

Merge pull request #1 from krrishnaaaa/update #1

Workflow file for this run

name: Create Release 🎉
on:
push:
tags:
- 'v*' # Trigger on version tag pushes (e.g., v1.0, v2.0)
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: 🛎️ Checkout code
uses: actions/checkout@v4
# Step 2: Set up JDK (using Zulu)
- name: ☕ Set up Zulu JDK 17
uses: actions/setup-java@v4
with:
java-version: '17' # Specify the JDK version
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
- name: 📦 Create Release
id: create_release
uses: actions/github-script@v6
with:
script: |
const { exec } = require('child_process');
const { promises: fs } = require('fs');
// Get the latest tag
const tag = context.ref.replace('refs/tags/', '');
// Read the release notes if available
const releaseNotes = await fs.readFile('CHANGELOG.md', 'utf-8').catch(() => 'No release notes.');
// Create the release
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: tag,
body: releaseNotes,
draft: false,
prerelease: false,
});
return release.data;
# Step 5: Upload the shadowJar artifact to the release
- name: 🎁 Upload shadowJar to Release
id: upload_jar
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
- 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