Skip to content

Commit 913b826

Browse files
feat: add github building action
1 parent a34f3ed commit 913b826

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed

.github/workflows/release-dev.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Create Release with ShadowJars
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
name: Build ShadowJars and Create Release
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
with:
15+
ref: develop # Ensure it works from the develop branch
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v3
19+
with:
20+
distribution: 'adopt'
21+
java-version: '21'
22+
23+
- name: Cache Gradle packages
24+
uses: actions/cache@v3
25+
with:
26+
path: |
27+
~/.gradle/caches
28+
~/.gradle/wrapper
29+
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
30+
restore-keys: |
31+
gradle-${{ runner.os }}
32+
33+
- name: Make gradlew executable
34+
run: chmod +x ./gradlew
35+
36+
- name: Build ShadowJars
37+
run: ./gradlew clean build shadowJar
38+
39+
- name: Get Gradle Version
40+
id: gradle_version
41+
run: echo "GRADLE_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV
42+
43+
- name: Get Commit Hash
44+
id: commit_hash
45+
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
46+
47+
# - name: Publish to SimpleCloud Repository
48+
# run: ./gradlew publishMavenJavaPublicationToSimplecloudRepository
49+
# env:
50+
# COMMIT_HASH: ${{ env.COMMIT_HASH }}
51+
# SIMPLECLOUD_USERNAME: ${{ secrets.SIMPLECLOUD_USERNAME }}
52+
# SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }}
53+
54+
- name: Create Release
55+
id: create_release
56+
uses: actions/create-release@v1
57+
with:
58+
tag_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }}
59+
release_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }}
60+
draft: false
61+
prerelease: true
62+
commitish: develop
63+
body: |
64+
This release contains dev builds for all Gradle modules.
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Upload ShadowJars to Release
69+
run: |
70+
# Find JAR files in any submodule's build/libs directory
71+
for jar in $(find . -type f -name "*.jar" -path "*/build/libs/*.jar" -not -path "./build/libs/*"); do
72+
# Check if the filename contains a version number (e.g., a dash followed by numbers)
73+
if [[ $(basename "$jar") =~ -[0-9]+\.[0-9]+ ]]; then
74+
echo "Skipping $jar due to version number"
75+
else
76+
echo "Uploading $jar"
77+
gh release upload v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }} "$jar"
78+
fi
79+
done
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ plugins {
66
alias(libs.plugins.shadow)
77
}
88

9-
allprojects {
9+
val baseVersion = "0.0.1"
10+
val commitHash = System.getenv("COMMIT_HASH")
11+
val snapshotversion = "${baseVersion}-dev.$commitHash"
1012

13+
allprojects {
1114
group = "app.simplecloud.plugin.proxy"
12-
version = "1.0.0"
15+
version = if (commitHash != null) snapshotversion else baseVersion
1316

1417
repositories {
1518
mavenCentral()

0 commit comments

Comments
 (0)