Make buildscript use variables for Modrinth ID and repository URL; Make hash provider gitihub URL build-time configurable
This commit is contained in:
1 parent
f7c4e179b7
commit
a652147e2c
5 files changed
+20
-9
No files matched your search
@@ -77,6 +77,8 @@ jobs:
|
||||
|
||||
- name: Build with Gradle
|
||||
run: gradle clean build -x test
|
||||
env:
|
||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||
|
||||
- name: Rename shaded jar to overwrite non-shaded jar
|
||||
run: mv bukkit/build/libs/knockbacksync-bukkit-${{ env.NEW_VERSION }}-all.jar bukkit/build/libs/knockbacksync-bukkit-${{ env.NEW_VERSION }}.jar
|
||||
@@ -115,7 +117,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Download the current dev-builds.txt
|
||||
curl -L -o dev-builds.txt https://github.com/CASELOAD7000/knockback-sync/releases/latest/download/dev-builds.txt
|
||||
curl -L -o dev-builds.txt https://github.com/${{ github.repository }}/releases/latest/download/dev-builds.txt
|
||||
|
||||
# Create a copy of the original file
|
||||
cp dev-builds.txt dev-builds.txt.original
|
||||
@@ -142,22 +144,22 @@ jobs:
|
||||
echo "Changes detected in dev-builds.txt, uploading new version."
|
||||
|
||||
# Get the latest release ID
|
||||
RELEASE_ID=$(curl -s "https://api.github.com/repos/CASELOAD7000/knockback-sync/releases/latest" | jq -r .id)
|
||||
RELEASE_ID=$(curl -s "https://api.github.com/repos/${{ github.repository }}/knockback-sync/releases/latest" | jq -r .id)
|
||||
|
||||
# Delete the old dev-builds.txt asset
|
||||
ASSET_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
||||
"https://api.github.com/repos/CASELOAD7000/knockback-sync/releases/$RELEASE_ID/assets" | \
|
||||
"https://api.github.com/repos/${{ github.repository }}/knockback-sync/releases/$RELEASE_ID/assets" | \
|
||||
jq -r '.[] | select(.name == "dev-builds.txt") | .id')
|
||||
if [ ! -z "$ASSET_ID" ]; then
|
||||
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
|
||||
"https://api.github.com/repos/CASELOAD7000/knockback-sync/releases/assets/$ASSET_ID"
|
||||
"https://api.github.com/repos/${{ github.repository }}/knockback-sync/releases/assets/$ASSET_ID"
|
||||
fi
|
||||
|
||||
# Upload the new dev-builds.txt
|
||||
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @dev-builds.txt \
|
||||
"https://uploads.github.com/repos/CASELOAD7000/knockback-sync/releases/$RELEASE_ID/assets?name=dev-builds.txt"
|
||||
"https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=dev-builds.txt"
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
@@ -184,7 +186,7 @@ jobs:
|
||||
|
||||
- uses: Kir-Antipov/mc-publish@v3.3
|
||||
with:
|
||||
modrinth-id: wGTbjSTq
|
||||
modrinth-id: ${{ vars.MODRINTH_ID }}
|
||||
modrinth-featured: true
|
||||
modrinth-unfeature-mode: subset
|
||||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
@@ -212,7 +214,7 @@ jobs:
|
||||
|
||||
- uses: Kir-Antipov/mc-publish@v3.3
|
||||
with:
|
||||
modrinth-id: wGTbjSTq
|
||||
modrinth-id: ${{ vars.MODRINTH_ID }}
|
||||
modrinth-featured: true
|
||||
modrinth-unfeature-mode: subset
|
||||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
|
||||
@@ -8,6 +8,7 @@ plugins {
|
||||
|
||||
val fullVersion = "1.3.5"
|
||||
val snapshot = true
|
||||
val githubRepo = System.getenv("GITHUB_REPOSITORY") ?: project.findProperty("githubRepo").toString()
|
||||
|
||||
allprojects {
|
||||
fun getVersionMeta(includeHash: Boolean): String {
|
||||
@@ -29,6 +30,7 @@ allprojects {
|
||||
group = "me.caseload.knockbacksync"
|
||||
version = "$fullVersion${getVersionMeta(true)}"
|
||||
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
|
||||
ext["githubRepo"] = githubRepo
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id("fabric-loom")
|
||||
// id("net.neoforged.moddev") version "1.0.11"
|
||||
id("com.github.gmazzo.buildconfig") version "3.1.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -34,4 +34,8 @@ repositories {
|
||||
|
||||
tasks.named("remapJar").configure {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
buildConfig {
|
||||
buildConfigField("String", "GITHUB_REPO", "\"${project.rootProject.ext["githubRepo"]}\"")
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package me.caseload.knockbacksync.stats.custom;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import me.caseload.knockbacksync.Base;
|
||||
import me.caseload.knockbacksync.common.BuildConfig;
|
||||
import me.caseload.knockbacksync.stats.SimplePie;
|
||||
import org.kohsuke.github.GHAsset;
|
||||
import org.kohsuke.github.GHRelease;
|
||||
@@ -53,7 +54,7 @@ public class BuildTypePie extends SimplePie {
|
||||
|
||||
private static void downloadBuildFiles() throws IOException {
|
||||
GitHub gitHub = GitHub.connectAnonymously();
|
||||
GHRelease latestRelease = gitHub.getRepository("CASELOAD7000/knockback-sync")
|
||||
GHRelease latestRelease = gitHub.getRepository(BuildConfig.GITHUB_REPO)
|
||||
.getLatestRelease();
|
||||
List<GHAsset> assets = latestRelease.listAssets().toList();
|
||||
for (GHAsset asset : assets) {
|
||||
|
||||
@@ -17,3 +17,5 @@ archives_base_name=knockbacksync
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.102.0+1.21
|
||||
|
||||
githubRepo=CASELOAD7000/knockback-sync
|
||||
Reference in new issue
Block a user