Tweak version json name

This commit is contained in:
Alexander Xia committed 2018-11-25 01:44:06 +08:00
1 parent fbd06f147a
commit 6b3531964e
3 files changed
+45 -18

No files matched your search

+40 -9
View File
@@ -20,6 +20,12 @@ import com.qcloud.cos.auth.COSCredentials
import com.qcloud.cos.model.PutObjectRequest
import com.qcloud.cos.region.Region
String getMcVersion(String filename) {
if (filename.endsWith(".json"))
return filename.substring(0, filename.indexOf('-'))
return filename.substring(filename.indexOf('_'), filename.indexOf('-'))
}
String getKey(String filename) {
String name = filename.substring(0, filename.lastIndexOf('.'))
if (filename.endsWith(".json"))
@@ -38,20 +44,45 @@ String getKey(String filename) {
return filename
}
void uploadFileToCOS(String key, File file) {
String bucketName = System.getenv("COS_BUCKET")
String cosUrl = "https://csl.littleservice.cn/"
COSClient cosClient = null
COSClient getCosClient() {
if (cosClient != null) return cosClient
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")
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file)
cosClient.putObject(putObjectRequest)
println("Uploaded to COS: " + key)
cosClient = new COSClient(cred, clientConfig)
}
void uploadFileToCOS(File file) {
uploadFileToCOS(getKey(file.getName()), file)
void uploadFile(String key, 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)
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file)
getCosClient().putObject(putObjectRequest)
}
void downloadFile(String key, File file) {
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key)
getCosClient().getObject(getObjectRequest, file)
}
void uploadArtifacts() {
File dir = rootProject.file("build/libs")
if (!dir.isDirectory()) return
File[] files = dir.listFiles()
for (file in files) {
String key = getKey(file.getName())
uploadFile(key, file)
String url = cosUrl + key
String version = getMcVersion(file.getName())
println(version + "\t" + url)
}
}
ext {
uploadFileToCOS = this.&uploadFileToCOS
uploadArtifacts = this.&uploadArtifacts
}
+3 -3
View File
@@ -18,15 +18,15 @@ String getBuildNum() {
return "00"
}
//Example: 14.4a-SNAPSHOT-20160820
//Example: 14.10a-SNAPSHOT-33
String getCSLVersion() {
return rootProject.ext.config.version + rootProject.ext.config.dev_version +
(isRelease() ? '' : ('-SNAPSHOT-' + getBuildNum()))
}
//Example: 14.4a-S-20160820
//Example: 14.10a-s33
String getShortVersion() {
return getVersion().replace("SNAPSHOT", "S")
return getVersion().replace("SNAPSHOT-", "s")
}
ext {