@@ -50,7 +50,7 @@ var allPlatforms = []Platform{
5050}
5151
5252var (
53- versionFlag = flag .String ("version" , "" , "Force all 6 platforms for this version (no R2 check )" )
53+ versionFlag = flag .String ("version" , "" , "Build missing platforms for this version (checks R2 if credentials provided, otherwise all platforms )" )
5454 r2Endpoint = flag .String ("r2-endpoint" , "" , "R2 endpoint URL" )
5555 r2Bucket = flag .String ("r2-bucket" , "" , "R2 bucket name" )
5656 r2AccessKey = flag .String ("r2-access-key" , "" , "R2 access key ID" )
@@ -77,17 +77,31 @@ var httpClient = &http.Client{
7777func main () {
7878 flag .Parse ()
7979
80- // If --version is provided, output all 6 platforms without R2 check
80+ hasR2Creds := * r2Endpoint != "" && * r2Bucket != "" && * r2AccessKey != "" && * r2SecretKey != ""
81+
8182 if * versionFlag != "" {
82- matrix := buildMatrixForVersion (* versionFlag )
83- outputMatrix (matrix )
83+ // --version provided: check R2 if credentials available, otherwise output all platforms
84+ if hasR2Creds {
85+ fmt .Fprintf (os .Stderr , "Checking R2 for existing builds of Ruby %s...\n " , * versionFlag )
86+ existingMeta , err := fetchExistingMeta ()
87+ if err != nil {
88+ fmt .Fprintf (os .Stderr , "Error fetching R2 metadata: %v\n " , err )
89+ os .Exit (1 )
90+ }
91+ matrix := computeGaps ([]string {* versionFlag }, existingMeta )
92+ fmt .Fprintf (os .Stderr , "Detected %d missing platforms for %s\n " , len (matrix .Include ), * versionFlag )
93+ outputMatrix (matrix )
94+ } else {
95+ fmt .Fprintln (os .Stderr , "No R2 credentials provided, outputting all platforms" )
96+ matrix := buildMatrixForVersion (* versionFlag )
97+ outputMatrix (matrix )
98+ }
8499 return
85100 }
86101
87- // Otherwise, detect gaps by comparing upstream vs R2
88- if * r2Endpoint == "" || * r2Bucket == "" || * r2AccessKey == "" || * r2SecretKey == "" {
102+ // No --version: full auto-detect requires R2 credentials
103+ if ! hasR2Creds {
89104 fmt .Fprintln (os .Stderr , "Error: R2 credentials required (--r2-endpoint, --r2-bucket, --r2-access-key, --r2-secret-key)" )
90- fmt .Fprintln (os .Stderr , " Or use --version=X to force all platforms for a specific version" )
91105 os .Exit (1 )
92106 }
93107
0 commit comments