Merge pull request #2 from krrishnaaaa/update #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🚀✨ Create Fun Release with JAR Upload 🎉 | |
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 17 (using Zulu) ☕ | |
- name: ☕🧙♂️ Set up Zulu JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'zulu' | |
# Step 3: Build the project and create shadowJar 🏗️ | |
- name: 🏗️✨ Build with Gradle and Create shadowJar | |
run: ./gradlew shadowJar --no-daemon | |
# 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 GitHub Release | |
id: create_release | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
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, | |
}); | |
core.setOutput('release_id', release.data.id); | |
# Step 6: Download and install `ghr` tool 🔧 | |
- name: 🔧⚡ Download and Install ghr tool | |
run: | | |
GHR_VERSION="v0.16.2" # Specify the version you want to install | |
wget https://github.com/tcnksm/ghr/releases/download/$GHR_VERSION/ghr_${GHR_VERSION}_linux_amd64.tar.gz | |
tar -xzf ghr_${GHR_VERSION}_linux_amd64.tar.gz | |
sudo mv ghr_${GHR_VERSION}_linux_amd64/ghr /usr/local/bin/ | |
ghr --version | |
# Step 7: Upload the JAR to the release 🏗️📦 | |
- name: 🚀📦 Upload JAR to GitHub Release | |
run: | | |
ghr -u "${GITHUB_REPOSITORY%/*}" \ | |
-r "${GITHUB_REPOSITORY#*/}" \ | |
"${GITHUB_REF#refs/tags/}" \ | |
"${{ env.jar_file }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |