mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-20 22:42:16 +00:00
Try to upload file to COS
This commit is contained in:
1 parent
7a3dc4f9c2
commit
78bc4b5f7e
3 files changed
+45
-3
No files matched your search
@@ -25,7 +25,7 @@ jobs:
|
||||
|
||||
# Gradle
|
||||
- run: gradle --version
|
||||
- run: gradle clean build
|
||||
- run: gradle clean build upload
|
||||
|
||||
- store_artifacts:
|
||||
path: ./build/libs
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"libraries": [
|
||||
{
|
||||
"name": "customskinloader:CustomSkinLoader_${mcVersion}:${modFullVersion}",
|
||||
"url": "https://lib.airweb.top/"
|
||||
"url": "https://csl.littleservice.cn/libraries/"
|
||||
},
|
||||
{
|
||||
"name": "net.minecraft:launchwrapper:1.12"
|
||||
|
||||
+43
-1
@@ -18,10 +18,52 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath 'com.qcloud:cos_api:5.4.6'
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
if (!project.name.toLowerCase().contains("forge"))
|
||||
apply from: rootProject.file('common.gradle')
|
||||
}
|
||||
}
|
||||
|
||||
/* COS Upload Begin */
|
||||
import com.qcloud.cos.COSClient
|
||||
import com.qcloud.cos.ClientConfig
|
||||
import com.qcloud.cos.auth.BasicCOSCredentials
|
||||
import com.qcloud.cos.auth.COSCredentials
|
||||
import com.qcloud.cos.region.Region
|
||||
import com.qcloud.cos.model.PutObjectRequest
|
||||
|
||||
static String getLibKey(String filename) {
|
||||
return String.format(
|
||||
"libraries/customskinloader/%s/%s/%s",
|
||||
filename.substring(0, filename.lastIndexOf('.')),
|
||||
filename.substring(filename.lastIndexOf('.') + 1),
|
||||
filename
|
||||
)
|
||||
}
|
||||
|
||||
static void uploadFileToCOS(File file) {
|
||||
COSCredentials cred = new BasicCOSCredentials(System.getenv("COS_SECRET_ID"), System.getenv("COS_SECRET_KEY"))
|
||||
ClientConfig clientConfig = new ClientConfig(new Region("ap-shanghai"))
|
||||
COSClient cosClient = new COSClient(cred, clientConfig)
|
||||
String bucketName = System.getenv("COS_BUCKET")
|
||||
String key = getLibKey(file.getName())
|
||||
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file)
|
||||
cosClient.putObject(putObjectRequest)
|
||||
println("Uploaded to COS: " + key)
|
||||
}
|
||||
|
||||
task upload {
|
||||
doLast {
|
||||
File dir = rootProject.file("build/libs")
|
||||
if (!dir.isDirectory()) return
|
||||
File[] files = dir.listFiles()
|
||||
for (file in files) {
|
||||
uploadFileToCOS(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* COS Upload End */
|
||||
Reference in new issue
Block a user