-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (66 loc) · 2.58 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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 }}