Skip to content

Commit f1fe273

Browse files
committed
Create standing dev release on GitHub
1 parent 1aeb002 commit f1fe273

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

.github/workflows/dev-build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: ProtocolLib development build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- gh-action-int
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup java
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: 'temurin'
20+
java-version: '21'
21+
cache: 'gradle'
22+
23+
- name: Run gradle build lifecycle
24+
run: |
25+
COMMIT_SHA=${{ github.sha }}
26+
./gradlew build shadowJar --no-daemon
27+
28+
- name: Upload plugin file
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: ProtocolLib
32+
path: build/libs/ProtocolLib.jar
33+
34+
- name: Create or update GitHub pre-release
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
COMMIT_MSG=$(git log -1 --pretty=%B)
39+
SHORT_HASH=$(echo "${{ github.sha }}" | cut -c1-7)
40+
RELEASE_NOTES=$(gh release view dev-build --repo ${{ github.repository }} --json body -q ".body" 2>/dev/null || echo "")
41+
gh release view dev-build --repo ${{ github.repository }} || \
42+
gh release create dev-build --prerelease --title "Development Build" --notes "## Changelog" --repo ${{ github.repository }}
43+
NEW_NOTES="$RELEASE_NOTES"$'\n'"* [$SHORT_HASH] $COMMIT_MSG"
44+
gh release edit dev-build --notes "$NEW_NOTES" --repo ${{ github.repository }}
45+
gh release upload dev-build build/libs/ProtocolLib.jar#ProtocolLib.jar --clobber --repo ${{ github.repository }}

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ description = "Provides access to the Minecraft protocol"
1616

1717
val mcVersion = "1.21.8"
1818
val isSnapshot = version.toString().endsWith("-SNAPSHOT")
19-
val buildNumber = System.getenv("BUILD_NUMBER") ?: ""
20-
val isJenkins = buildNumber.isNotEmpty()
19+
val commitHash = System.getenv("COMMIT_SHA") ?: ""
20+
val isCI = commitHash.isNotEmpty()
2121

2222
repositories {
23-
if (!isJenkins) {
23+
if (!isCI) {
2424
mavenLocal()
2525
}
2626

@@ -75,7 +75,7 @@ java {
7575

7676
tasks {
7777
processResources {
78-
val fullVersion = if (isSnapshot && isJenkins) "${version}-${buildNumber}" else version
78+
val fullVersion = if (isSnapshot && isCI) "${version}-${commitHash.take(7)}" else version
7979

8080
eachFile {
8181
expand("version" to fullVersion)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=5.4.0
1+
version=5.4.1-SNAPSHOT
22
mavenCentralUsername=
33
mavenCentralPassword=
44
signing.keyId=

0 commit comments

Comments
 (0)