Skip to content

Commit d2c61de

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 2ed4d2d + 493af9d commit d2c61de

File tree

2 files changed

+15
-69
lines changed

2 files changed

+15
-69
lines changed

.github/workflows/publish.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,29 @@ jobs:
8282
GITHUB_TOKEN: ${{ github.token }}
8383
run: ./gradlew closeMilestone --stacktrace --no-configuration-cache
8484

85+
- name: Build website update inputs
86+
id: website_inputs
87+
if: ${{ inputs.update_website }}
88+
run: |
89+
echo "wurst_version=$(grep '^mod_version=' gradle.properties | cut -d'=' -f2 | tr -d ' \r' | sed 's/^v//' | sed 's/-MC.*$//')" >> "$GITHUB_OUTPUT"
90+
echo "mc_version=$(grep '^minecraft_version=' gradle.properties | cut -d'=' -f2 | tr -d ' \r')" >> "$GITHUB_OUTPUT"
91+
echo "fapi_version=$(grep '^fabric_version=' gradle.properties | cut -d'=' -f2 | tr -d ' \r')" >> "$GITHUB_OUTPUT"
92+
8593
- name: Upload backups
8694
if: ${{ inputs.upload_backups }}
87-
env:
88-
WI_BACKUPS_API_KEY: ${{ secrets.WI_BACKUPS_API_KEY }}
89-
run: ./gradlew uploadBackups --stacktrace --no-configuration-cache
95+
uses: Wurst-Imperium/upload-backups@v1
96+
with:
97+
api_key: ${{ secrets.WI_BACKUPS_API_KEY }}
98+
project: Wurst
99+
version: ${{ steps.website_inputs.outputs.wurst_version }}
100+
path: build/libs/*.jar
90101

91102
- name: Publish to GitHub
92103
if: ${{ inputs.publish_github }}
93104
env:
94105
GITHUB_TOKEN: ${{ secrets.OLD_MCX_PUBLISH_TOKEN }}
95106
run: ./gradlew github --stacktrace --no-configuration-cache
96107

97-
- name: Build website update inputs
98-
id: website_inputs
99-
if: ${{ inputs.update_website }}
100-
run: |
101-
echo "wurst_version=$(grep '^mod_version=' gradle.properties | cut -d'=' -f2 | tr -d ' \r' | sed 's/^v//' | sed 's/-MC.*$//')" >> "$GITHUB_OUTPUT"
102-
echo "mc_version=$(grep '^minecraft_version=' gradle.properties | cut -d'=' -f2 | tr -d ' \r')" >> "$GITHUB_OUTPUT"
103-
echo "fapi_version=$(grep '^fabric_version=' gradle.properties | cut -d'=' -f2 | tr -d ' \r')" >> "$GITHUB_OUTPUT"
104-
105108
- name: Trigger website update
106109
if: ${{ inputs.update_website }}
107110
uses: Wurst-Imperium/dispatch-and-wait@v1

build.gradle

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66

77
plugins {
88
id "fabric-loom" version "${loom_version}"
9-
id "com.diffplug.spotless" version "8.0.0"
9+
id "com.diffplug.spotless" version "8.1.0"
1010
}
1111

1212
def ENV = System.getenv()
@@ -319,60 +319,3 @@ task closeMilestone {
319319
}
320320
}
321321
}
322-
323-
task uploadBackups {
324-
dependsOn build
325-
326-
onlyIf {
327-
ENV.WI_BACKUPS_API_KEY
328-
}
329-
330-
doLast {
331-
def shortVersion = getGhVersion().substring(1)
332-
def backupUrl = "https://api.wurstclient.net/artifact-backups/Wurst/${shortVersion}"
333-
334-
def maxRetries = 3
335-
def retryCount = 0
336-
def success = false
337-
338-
while (!success && retryCount < maxRetries) {
339-
try {
340-
def connection = new URL(backupUrl).openConnection() as HttpURLConnection
341-
def boundary = UUID.randomUUID().toString()
342-
connection.setRequestMethod("POST")
343-
connection.setRequestProperty("X-API-Key", ENV.WI_BACKUPS_API_KEY)
344-
connection.setRequestProperty("Accept", "application/json")
345-
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=$boundary")
346-
connection.doOutput = true
347-
348-
def output = connection.outputStream
349-
[remapJar, remapSourcesJar].each { jarTask ->
350-
def file = jarTask.archiveFile.get().asFile
351-
output << "--${boundary}\r\n"
352-
output << "Content-Disposition: form-data; name=\"files\"; filename=\"${file.name}\"\r\n"
353-
output << "Content-Type: application/java-archive\r\n\r\n"
354-
file.withInputStream { input ->
355-
output << input
356-
}
357-
output << "\r\n"
358-
}
359-
output << "--${boundary}--\r\n"
360-
output.flush()
361-
362-
if(connection.responseCode != 200) {
363-
throw new IOException("HTTP ${connection.responseCode}: ${connection.responseMessage}")
364-
}
365-
366-
success = true
367-
368-
} catch (Exception e) {
369-
retryCount++
370-
if (retryCount >= maxRetries) {
371-
throw new GradleException("Failed to upload backups after ${maxRetries} attempts: ${e.message}")
372-
}
373-
println "Upload attempt ${retryCount} failed: ${e.message}. Retrying in 5 seconds..."
374-
Thread.sleep(5000)
375-
}
376-
}
377-
}
378-
}

0 commit comments

Comments
 (0)