Support new versioning scheme

This commit is contained in:
Luke Street 2021-03-30 04:51:27 -04:00
parent 06cb695733
commit 2ad0d099b8
1 changed files with 34 additions and 14 deletions

48
main.go
View File

@ -61,21 +61,20 @@ func main() {
} }
for _, artifact := range artifacts.Artifacts { for _, artifact := range artifacts.Artifacts {
split := strings.Split(*artifact.Name, "-") info := parseArtifactName(*artifact.Name)
project, version, platform, compiler, arch := split[0], split[1], split[2], split[3], split[4] if info.project != "urde" || platformCompilerMap[info.platform] != info.compiler {
if project != "urde" || platformCompilerMap[platform] != compiler {
continue continue
} }
fmt.Println("Selected artifact", project, version, platform, compiler, arch) fmt.Println("Selected artifact", info.project, info.version, info.platform, info.compiler, info.arch)
baseDir := fmt.Sprintf("continuous/%s", platform) baseDir := fmt.Sprintf("continuous/%s", info.platform)
name := fmt.Sprintf("%s-%s-%s-%s", project, version, platform, arch) name := fmt.Sprintf("%s-%s-%s-%s", info.project, info.version, info.platform, info.arch)
extension := "" extension := ""
if platform == "win32" { if info.platform == "win32" {
extension = "zip" extension = "zip"
} else if platform == "linux" { } else if info.platform == "linux" {
extension = "tar" extension = "tar"
} else if platform == "macos" { } else if info.platform == "macos" {
extension = "dmg" extension = "dmg"
} }
@ -91,7 +90,7 @@ func main() {
} }
// Add to platform index file // Add to platform index file
platformIndex[platform] = append(platformIndex[platform], fmt.Sprintf("%s.%s", name, extension)) platformIndex[info.platform] = append(platformIndex[info.platform], fmt.Sprintf("%s.%s", name, extension))
// Check if artifact already exists in output // Check if artifact already exists in output
outPath := fmt.Sprintf("%s/%s.%s", baseDir, name, extension) outPath := fmt.Sprintf("%s/%s.%s", baseDir, name, extension)
@ -109,11 +108,11 @@ func main() {
} }
found := false found := false
if platform == "linux" { if info.platform == "linux" {
found, err = writeLinuxTar(zr, name, baseDir) found, err = writeLinuxTar(zr, name, baseDir)
} else if platform == "win32" { } else if info.platform == "win32" {
found, err = writeWin32Zip(zr, name, baseDir) found, err = writeWin32Zip(zr, name, baseDir)
} else if platform == "macos" { } else if info.platform == "macos" {
found, err = writeMacosDmg(zr, name, baseDir) found, err = writeMacosDmg(zr, name, baseDir)
} }
if err != nil { if err != nil {
@ -126,7 +125,7 @@ func main() {
fmt.Println("Artifact skipped") fmt.Println("Artifact skipped")
// Remove from platform index // Remove from platform index
platformIndex[platform] = platformIndex[platform][:len(platformIndex[platform])-1] platformIndex[info.platform] = platformIndex[info.platform][:len(platformIndex[info.platform])-1]
// Create .skip file // Create .skip file
file, err := os.Create(skipFile) file, err := os.Create(skipFile)
@ -345,3 +344,24 @@ func extractFile(file *zip.File, w io.Writer) error {
} }
return nil return nil
} }
type artifactInfo struct {
project string
version string
platform string
compiler string
arch string
}
func parseArtifactName(name string) artifactInfo {
info := artifactInfo{}
split := strings.Split(name, "-")
if len(split) == 5 {
// urde-123-macos-appleclang-x86_64
info.project, info.version, info.platform, info.compiler, info.arch = split[0], split[1], split[2], split[3], split[4]
} else if len(split) == 6 {
// urde-v1.2.3-4-macos-appleclang-x86_64
info.project, info.version, info.platform, info.compiler, info.arch = split[0], split[1]+"-"+split[2], split[3], split[4], split[5]
}
return info
}