@@ -13,7 +13,13 @@ func main() {
1313 draft := flag .Bool ("draft" , false , "create a draft release" )
1414 flag .Parse ()
1515
16+ arch := flag .Arg (0 )
17+ if arch == "" {
18+ log .Fatalf ("missing platform_arch argument" )
19+ }
20+
1621 sha := os .Getenv ("GITHUB_SHA" )
22+ ref := os .Getenv ("GITHUB_REF" )
1723 cmd := exec .Command ("git" , "show" , "--no-patch" , "--no-notes" , "--pretty=%ci" , sha )
1824 out , err := cmd .CombinedOutput ()
1925 if err != nil {
@@ -26,31 +32,36 @@ func main() {
2632 date = strings .Replace (date , ":" , "" , - 1 )
2733 version := fmt .Sprintf ("v0.0.0-%s-%s" , date , sha [:12 ])
2834
29- x := "-X github.com/kyleconroy/sqlc/internal/cmd.version=" + version
30- log .Printf ("Releasing %s on channel %s" , flag .Arg (1 ), flag .Arg (0 ))
31-
3235 xname := "./equinox"
3336 if _ , err := os .Stat ("./equinox" ); os .IsNotExist (err ) {
3437 xname = "equinox"
3538 }
3639
40+ channel := "devel"
41+ if strings .HasPrefix (ref , "refs/tags/" ) {
42+ channel = "stable"
43+ version = strings .TrimPrefix (ref , "refs/tags/" )
44+ }
45+
3746 args := []string {"release" ,
38- "--channel" , flag . Arg ( 0 ) ,
47+ "--channel" , channel ,
3948 "--version" , version ,
4049 }
4150
4251 if * draft {
4352 args = append (args , "--draft" )
4453 }
4554
55+ x := "-X github.com/kyleconroy/sqlc/internal/cmd.version=" + version
4656 args = append (args , []string {
47- "--platforms" , flag .Arg (1 ),
57+ "--platforms" , flag .Arg (0 ),
4858 "--app" , "app_i4iCp1SuYfZ" ,
4959 "--token" , os .Getenv ("EQUINOX_API_TOKEN" ),
5060 "--" ,
5161 "-ldflags" , x , "./cmd/sqlc" ,
5262 }... )
5363
64+ log .Printf ("Releasing %s on channel %s" , flag .Arg (0 ), channel )
5465 cmd = exec .Command (xname , args ... )
5566 cmd .Env = os .Environ ()
5667 out , err = cmd .CombinedOutput ()
0 commit comments