Skip to content

Commit fe258ab

Browse files
committed
Overengineer buildscript
1 parent f946a1c commit fe258ab

File tree

9 files changed

+203
-23
lines changed

9 files changed

+203
-23
lines changed

.github/FUNDING.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Auto‑Bump SQLite‑JDBC
2+
3+
on:
4+
schedule: # every day at 05:00 UTC
5+
- cron: '0 5 * * *'
6+
workflow_dispatch: # manual “Run workflow” button
7+
8+
permissions:
9+
contents: write # push commits, create releases
10+
pull-requests: write # open / merge PRs
11+
12+
jobs:
13+
bump:
14+
runs-on: ubuntu-latest
15+
16+
env:
17+
BOT_NAME: "Axionize (automation)"
18+
BOT_EMAIL: "[email protected]"
19+
20+
steps:
21+
# ─────────────────────────────────────────────────────────
22+
# 1) Checkout
23+
# ─────────────────────────────────────────────────────────
24+
- uses: actions/checkout@v3
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }} # writeable token
27+
28+
# ─────────────────────────────────────────────────────────
29+
# 2) Latest version on Maven Central
30+
# ─────────────────────────────────────────────────────────
31+
- name: Fetch newest sqlite‑jdbc
32+
id: maven
33+
run: |
34+
latest=$(curl -s \
35+
'https://search.maven.org/solrsearch/select?q=g:%22org.xerial%22+AND+a:%22sqlite-jdbc%22&rows=1&wt=json' \
36+
| jq -r '.response.docs[0].latestVersion')
37+
echo "latest=$latest"
38+
echo "latest=$latest" >> "$GITHUB_OUTPUT"
39+
40+
# ─────────────────────────────────────────────────────────
41+
# 3) Current version in gradle.properties
42+
# ─────────────────────────────────────────────────────────
43+
- name: Read current version
44+
id: current
45+
run: |
46+
current=$(grep '^library_version=' gradle.properties | cut -d'=' -f2)
47+
echo "current=$current"
48+
echo "current=$current" >> "$GITHUB_OUTPUT"
49+
50+
# ─────────────────────────────────────────────────────────
51+
# 4) Exit early if nothing to update
52+
# ─────────────────────────────────────────────────────────
53+
- name: Skip if up‑to‑date
54+
if: ${{ steps.maven.outputs.latest == steps.current.outputs.current }}
55+
run: echo "Nothing to bump — already on ${{ steps.current.outputs.current }}."
56+
57+
# ---------------------------------------------------------------------
58+
# 5) OPTION A → Commit directly to main (UNCOMMENT to use)
59+
# ---------------------------------------------------------------------
60+
# - name: Bump + push to main # ← uncomment block to enable option A
61+
# if: ${{ steps.maven.outputs.latest != steps.current.outputs.current }}
62+
# env:
63+
# LATEST: ${{ steps.maven.outputs.latest }}
64+
# run: |
65+
# set -e
66+
# sed -i "s/^library_version=.*/library_version=${LATEST}/" gradle.properties
67+
# git config user.name "Axionize"
68+
# git config user.email "[email protected]"
69+
# git add gradle.properties
70+
# git commit -m "chore: bump sqlite-jdbc to ${LATEST}"
71+
# git push origin HEAD:main
72+
73+
# ---------------------------------------------------------------------
74+
# 5/6) OPTION B → PR + auto‑merge (DEFAULT below)
75+
# ---------------------------------------------------------------------
76+
- name: Open PR & auto‑merge # ← default: option B
77+
if: ${{ steps.maven.outputs.latest != steps.current.outputs.current }}
78+
uses: peter-evans/create-pull-request@v5
79+
with:
80+
token: ${{ secrets.GITHUB_TOKEN }}
81+
branch: bump-sqlite-${{ steps.maven.outputs.latest }}
82+
commit-message: "chore: bump sqlite-jdbc to ${{ steps.maven.outputs.latest }}"
83+
title: "chore: bump sqlite-jdbc to ${{ steps.maven.outputs.latest }}"
84+
body: |
85+
Automated bump from **${{ steps.current.outputs.current }}**
86+
to **${{ steps.maven.outputs.latest }}**.
87+
88+
This PR will merge itself once CI passes.
89+
labels: dependencies, automated
90+
delete-branch: true
91+
# ----- auto‑merge controls -----
92+
merge: true # merge right after CI succeeds
93+
merge-method: squash
94+
author: "${{ env.BOT_NAME }} <${{ env.BOT_EMAIL }}>"
95+
committer: "${{ env.BOT_NAME }} <${{ env.BOT_EMAIL }}>"

.github/workflows/gradle.yml

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,76 @@
1-
name: Java CI
1+
name: Nightly Release
22

3-
on: [push]
3+
on:
4+
# rebuild on every push to the default branch
5+
push:
6+
branches: [ main ]
7+
8+
# …and once a day at 04:00 UTC (if uncommented)
9+
# schedule:
10+
# - cron: '0 4 * * *'
411

512
jobs:
6-
build:
13+
build-and-release:
714
runs-on: ubuntu-latest
815

16+
env:
17+
BOT_NAME: "Axionize (automation)"
18+
BOT_EMAIL: "[email protected]"
19+
920
steps:
10-
- uses: actions/checkout@v2
11-
- name: Set up JDK
12-
uses: actions/setup-java@v2
21+
# ─────────────────────────────────────────────────────────────
22+
# 1. Check out sources
23+
# ─────────────────────────────────────────────────────────────
24+
- uses: actions/checkout@v3
25+
26+
# ─────────────────────────────────────────────────────────────
27+
# 2. JDK8 + Gradle cache
28+
# ─────────────────────────────────────────────────────────────
29+
- name: Set up JDK8
30+
uses: actions/setup-java@v3
1331
with:
14-
distribution: 'temurin'
32+
distribution: temurin
1533
java-version: '8'
34+
cache: gradle
35+
36+
# ─────────────────────────────────────────────────────────────
37+
# 3. Validate wrapper (supply SHA-256 whitelist)
38+
# ─────────────────────────────────────────────────────────────
1639
- name: Validate Gradle wrapper
1740
uses: gradle/wrapper-validation-action@v1
18-
- name: Build with Gradle
19-
run: ./gradlew build
20-
- uses: actions/upload-artifact@v2
41+
42+
# ─────────────────────────────────────────────────────────────
43+
# 4. Build shaded JAR
44+
# ─────────────────────────────────────────────────────────────
45+
- name: Build
46+
uses: gradle/gradle-build-action@v2
47+
with:
48+
arguments: clean build --no-daemon --stacktrace
49+
50+
# ─────────────────────────────────────────────────────────────
51+
# 5. Find the JAR and extract its version
52+
# ─────────────────────────────────────────────────────────────
53+
- name: Locate JAR & extract version
54+
id: locate
55+
run: |
56+
set -e
57+
jar=$(ls -1 build/libs/*-all.jar | head -n1)
58+
echo "jar=$jar" >>"$GITHUB_OUTPUT"
59+
60+
# pull the version part out of the filename:
61+
# sqlite-jdbc-3.49.1.0+20250420-all.jar -> 3.49.1.0+20250420
62+
ver=$(basename "$jar" | sed -E 's/^sqlite-jdbc-([^+]+(\+[0-9]+)?)-all\.jar$/\1/')
63+
echo "ver=$ver" >>"$GITHUB_OUTPUT"
64+
65+
# ─────────────────────────────────────────────────────────────
66+
# 6. Create/update a version‑tagged release
67+
# ─────────────────────────────────────────────────────────────
68+
- name: Publish nightly release
69+
uses: ncipollo/release-action@v1
2170
with:
22-
name: Package
23-
path: build/libs/*-all.jar
71+
tag: nightly-${{ steps.locate.outputs.ver }} # ex: nightly-3.49.1.0+20250420
72+
name: Nightly ${{ steps.locate.outputs.ver }}
73+
artifacts: ${{ steps.locate.outputs.jar }}
74+
prerelease: true
75+
makeLatest: true # marks this release as “latest”
76+
token: ${{ secrets.GITHUB_TOKEN }}

build.gradle

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,43 @@ dependencies {
2222
implementation(project(":spigot")) { transitive = false }
2323
}
2424

25+
import org.apache.tools.ant.filters.ReplaceTokens
26+
2527
processResources {
26-
filesMatching(['fabric.mod.json', 'plugin.yml', 'mcmod.info', 'META-INF/mods.toml', 'pack.mcmeta']) {
27-
expand project.properties
28+
29+
/* --- 1. Collect authors ------------------------------------------------ */
30+
31+
// Comma‑separated list from gradle.properties → ["author1", "author2"]
32+
def modAuthors = project.findProperty('mod_author') ?
33+
project.mod_author.split(',').collect { it.trim() } : []
34+
35+
// Optional vendor from gradle.properties → "vendor"
36+
def vendor = project.findProperty('mod_vendor')?.trim()
37+
38+
def fullAuthorList = modAuthors + (vendor ? [vendor] : [])
39+
40+
/* --- 2. Build the replacement strings --------------------------------- */
41+
42+
// author1", "author2", "vendor <-- NO outer quotes
43+
def modAuthorListString = fullAuthorList.join('", "')
44+
45+
def expandedProps = project.properties + [
46+
// plain, human‑readable version: author1, author2, vendor
47+
mod_author_plain : fullAuthorList.join(', '),
48+
// JSON‑ready fragment (without outer quotes)
49+
mod_author_list : modAuthorListString
50+
]
51+
52+
/* --- 3. Apply the replacements ---------------------------------------- */
53+
54+
filesMatching([
55+
'mcmod.info',
56+
'plugin.yml',
57+
'fabric.mod.json',
58+
'META-INF/mods.toml',
59+
'pack.mcmeta'
60+
]) {
61+
expand expandedProps
2862
}
2963
}
3064

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ mod_slug=sqlite-jdbc
88
mod_name=SQLite JDBC
99
mod_description=SQLite JDBC Driver for Minecraft
1010
mod_vendor=xerial
11-
mod_author=Kosmolot
11+
mod_author=Axionize,Kosmolot
1212
mod_license=Apache
1313

1414
library_name=sqlite-jdbc
1515
library_maven_name=org.xerial:sqlite-jdbc
16-
library_version=3.49.1.0
16+
library_version=3.41.2.1
1717

18-
release_date=20250420
18+
release_date=20230506

src/main/resources/META-INF/mods.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ version="${version}"
99
displayName="${mod_name}"
1010
displayURL="https://www.curseforge.com/minecraft/mc-mods/${mod_slug}"
1111
logoFile="${mod_slug}.png"
12-
authors="${mod_vendor}, ${mod_author}"
12+
authors="${mod_author_plain}"
1313
description='''${mod_description}'''
1414
displayTest="IGNORE_ALL_VERSION"

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"name": "${mod_name}",
66
"description": "${mod_description}",
77
"authors": [
8-
"${mod_vendor}",
9-
"${mod_author}"
8+
"${mod_author_list}"
109
],
1110
"contact": {
1211
"homepage": "https://www.curseforge.com/minecraft/mc-mods/${mod_slug}",

src/main/resources/mcmod.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"version": "${version}",
77
"mcversion": "",
88
"url": "https://www.curseforge.com/minecraft/mc-mods/${mod_slug}",
9-
"authorList": ["${mod_vendor}", "${mod_author}"],
9+
"authorList": [ "${mod_author_list}" ],
1010
"logoFile": "${mod_slug}.png"
1111
}
1212
]

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: ${mod_slug}
22
main: pl.kosma.${mod_id}.SpigotPlugin
33
description: ${mod_description}
4-
author: ${mod_vendor}, ${mod_author}
4+
author: ${mod_author_plain}
55
website: https://www.curseforge.com/minecraft/mc-mods/${mod_slug}
66
version: ${version}

0 commit comments

Comments
 (0)