@@ -307,6 +307,9 @@ func addSingleReleaseWorkflow(build *BuildReleaseTasks, milestone *task.Mileston
307
307
dlclCommit := wd .Task ("Wait for DL CL" , version .AwaitCL , dlcl , wd .Constant ("" ))
308
308
wd .Output ("Download CL submitted" , dlclCommit )
309
309
310
+ startSigner := wd .Task ("Start signing command" , build .startSigningCommand , nextVersion )
311
+ wd .Output ("Signing command" , startSigner )
312
+
310
313
// Build, test, and sign release.
311
314
signedAndTestedArtifacts , err := build .addBuildTasks (wd , "go1.19" , nextVersion , releaseBase , skipTests , checked )
312
315
if err != nil {
@@ -382,13 +385,13 @@ func (tasks *BuildReleaseTasks) addBuildTasks(wd *workflow.Definition, majorVers
382
385
383
386
// BuildReleaseTasks serves as an adapter to the various build tasks in the task package.
384
387
type BuildReleaseTasks struct {
385
- GerritURL string
386
- GCSClient * storage.Client
387
- ScratchURL , StagingURL , ServingURL string
388
- DownloadURL string
389
- PublishFile func (* WebsiteFile ) error
390
- CreateBuildlet func (string ) (buildlet.Client , error )
391
- ApproveActionFunc func (taskName string ) func (* workflow.TaskContext , interface {}) error
388
+ GerritURL string
389
+ GCSClient * storage.Client
390
+ ScratchURL , ServingURL string
391
+ DownloadURL string
392
+ PublishFile func (* WebsiteFile ) error
393
+ CreateBuildlet func (string ) (buildlet.Client , error )
394
+ ApproveActionFunc func (taskName string ) func (* workflow.TaskContext , interface {}) error
392
395
}
393
396
394
397
func (b * BuildReleaseTasks ) buildSource (ctx * workflow.TaskContext , revision , version string ) (artifact , error ) {
@@ -530,15 +533,22 @@ func (b *BuildReleaseTasks) runBuildStep(
530
533
}, nil
531
534
}
532
535
536
+ // An artifact represents a file as it moves through the release process. Most
537
+ // files will appear on go.dev/dl eventually.
533
538
type artifact struct {
534
539
// The target platform of this artifact, or nil for source.
535
540
Target * releasetargets.Target
536
- // The scratch path of this artifact.
541
+ // The scratch path of this artifact within the scratch directory.
542
+ // <workflow-id>/<filename>-<random-number>
537
543
ScratchPath string
538
- // The path the artifact was staged to for the signing process.
544
+ // The path within the scratch directory the artifact was staged to for the
545
+ // signing process.
546
+ // <workflow-id>/signing/<go version>/<filename>
539
547
StagingPath string
540
- // The path artifact can be found at after the signing process. It may be
541
- // the same as the staging path for artifacts that are externally signed.
548
+ // The path within the scratch directory the artifact can be found at
549
+ // after the signing process. For files not modified by the signing
550
+ // process, the staging path, or for those that are
551
+ // <workflow-id>/signing/<go version>/signed/<filename>
542
552
SignedPath string
543
553
// The contents of the GPG signature for this artifact (.asc file).
544
554
GPGSignature string
@@ -560,15 +570,17 @@ func (w *sizeWriter) Write(p []byte) (n int, err error) {
560
570
return len (p ), nil
561
571
}
562
572
573
+ func (tasks * BuildReleaseTasks ) startSigningCommand (ctx * workflow.TaskContext , version string ) (string , error ) {
574
+ args := fmt .Sprintf ("--relui_staging=%q" , path .Join (tasks .ScratchURL , signingStagingDir (ctx , version )))
575
+ ctx .Printf ("run signer with " + args )
576
+ return args , nil
577
+ }
578
+
563
579
func (tasks * BuildReleaseTasks ) copyToStaging (ctx * workflow.TaskContext , version string , artifacts []artifact ) ([]artifact , error ) {
564
580
scratchFS , err := gcsfs .FromURL (ctx , tasks .GCSClient , tasks .ScratchURL )
565
581
if err != nil {
566
582
return nil , err
567
583
}
568
- stagingFS , err := gcsfs .FromURL (ctx , tasks .GCSClient , tasks .StagingURL )
569
- if err != nil {
570
- return nil , err
571
- }
572
584
var stagedArtifacts []artifact
573
585
for _ , a := range artifacts {
574
586
staged := a
@@ -577,14 +589,14 @@ func (tasks *BuildReleaseTasks) copyToStaging(ctx *workflow.TaskContext, version
577
589
} else {
578
590
staged .Filename = version + "." + a .Suffix
579
591
}
580
- staged .StagingPath = path .Join (version , staged .Filename )
592
+ staged .StagingPath = path .Join (signingStagingDir ( ctx , version ) , staged .Filename )
581
593
stagedArtifacts = append (stagedArtifacts , staged )
582
594
583
595
in , err := scratchFS .Open (a .ScratchPath )
584
596
if err != nil {
585
597
return nil , err
586
598
}
587
- out , err := gcsfs .Create (stagingFS , staged .StagingPath )
599
+ out , err := gcsfs .Create (scratchFS , staged .StagingPath )
588
600
if err != nil {
589
601
return nil , err
590
602
}
@@ -598,9 +610,20 @@ func (tasks *BuildReleaseTasks) copyToStaging(ctx *workflow.TaskContext, version
598
610
return nil , err
599
611
}
600
612
}
613
+ out , err := gcsfs .Create (scratchFS , path .Join (signingStagingDir (ctx , version ), "ready" ))
614
+ if err != nil {
615
+ return nil , err
616
+ }
617
+ if err := out .Close (); err != nil {
618
+ return nil , err
619
+ }
601
620
return stagedArtifacts , nil
602
621
}
603
622
623
+ func signingStagingDir (ctx * workflow.TaskContext , version string ) string {
624
+ return path .Join (ctx .WorkflowID .String (), "signing" , version )
625
+ }
626
+
604
627
var signingPollDuration = 30 * time .Second
605
628
606
629
// awaitSigned waits for all of artifacts to be signed, plus the pkgs for
@@ -617,7 +640,7 @@ func (tasks *BuildReleaseTasks) awaitSigned(ctx *workflow.TaskContext, version s
617
640
})
618
641
}
619
642
620
- stagingFS , err := gcsfs .FromURL (ctx , tasks .GCSClient , tasks .StagingURL )
643
+ scratchFS , err := gcsfs .FromURL (ctx , tasks .GCSClient , tasks .ScratchURL )
621
644
if err != nil {
622
645
return nil , err
623
646
}
@@ -629,7 +652,7 @@ func (tasks *BuildReleaseTasks) awaitSigned(ctx *workflow.TaskContext, version s
629
652
var signedArtifacts []artifact
630
653
for {
631
654
for a := range todo {
632
- signed , ok , err := readSignedArtifact (stagingFS , version , a )
655
+ signed , ok , err := readSignedArtifact (ctx , scratchFS , version , a )
633
656
if err != nil {
634
657
return nil , err
635
658
}
@@ -653,7 +676,7 @@ func (tasks *BuildReleaseTasks) awaitSigned(ctx *workflow.TaskContext, version s
653
676
}
654
677
}
655
678
656
- func readSignedArtifact (stagingFS fs.FS , version string , a artifact ) (_ artifact , ok bool , _ error ) {
679
+ func readSignedArtifact (ctx * workflow. TaskContext , scratchFS fs.FS , version string , a artifact ) (_ artifact , ok bool , _ error ) {
657
680
// Our signing process has somewhat uneven behavior. In general, for things
658
681
// that contain their own signature, such as MSIs and .pkgs, we don't
659
682
// produce a GPG signature, just the new file. On macOS, tars can be signed
@@ -684,18 +707,19 @@ func readSignedArtifact(stagingFS fs.FS, version string, a artifact) (_ artifact
684
707
Filename : a .Filename ,
685
708
Suffix : a .Suffix ,
686
709
}
710
+ stagingDir := signingStagingDir (ctx , version )
687
711
if modifiedBySigning {
688
- signed .SignedPath = version + "/signed/" + a .Filename
712
+ signed .SignedPath = stagingDir + "/signed/" + a .Filename
689
713
} else {
690
- signed .SignedPath = version + "/" + a .Filename
714
+ signed .SignedPath = stagingDir + "/" + a .Filename
691
715
}
692
716
693
- fi , err := fs .Stat (stagingFS , signed .SignedPath )
717
+ fi , err := fs .Stat (scratchFS , signed .SignedPath )
694
718
if err != nil {
695
719
return artifact {}, false , nil
696
720
}
697
721
if modifiedBySigning {
698
- hash , err := fs .ReadFile (stagingFS , version + "/signed/" + a .Filename + ".sha256" )
722
+ hash , err := fs .ReadFile (scratchFS , stagingDir + "/signed/" + a .Filename + ".sha256" )
699
723
if err != nil {
700
724
return artifact {}, false , nil
701
725
}
@@ -706,7 +730,7 @@ func readSignedArtifact(stagingFS fs.FS, version string, a artifact) (_ artifact
706
730
signed .Size = a .Size
707
731
}
708
732
if hasGPG {
709
- sig , err := fs .ReadFile (stagingFS , version + "/signed/" + a .Filename + ".asc" )
733
+ sig , err := fs .ReadFile (scratchFS , stagingDir + "/signed/" + a .Filename + ".asc" )
710
734
if err != nil {
711
735
return artifact {}, false , nil
712
736
}
@@ -718,7 +742,7 @@ func readSignedArtifact(stagingFS fs.FS, version string, a artifact) (_ artifact
718
742
var uploadPollDuration = 30 * time .Second
719
743
720
744
func (tasks * BuildReleaseTasks ) uploadArtifacts (ctx * workflow.TaskContext , artifacts []artifact ) error {
721
- stagingFS , err := gcsfs .FromURL (ctx , tasks .GCSClient , tasks .StagingURL )
745
+ scratchFS , err := gcsfs .FromURL (ctx , tasks .GCSClient , tasks .ScratchURL )
722
746
if err != nil {
723
747
return err
724
748
}
@@ -729,7 +753,7 @@ func (tasks *BuildReleaseTasks) uploadArtifacts(ctx *workflow.TaskContext, artif
729
753
730
754
todo := map [artifact ]bool {}
731
755
for _ , a := range artifacts {
732
- if err := uploadArtifact (stagingFS , servingFS , a ); err != nil {
756
+ if err := uploadArtifact (scratchFS , servingFS , a ); err != nil {
733
757
return err
734
758
}
735
759
todo [a ] = true
@@ -762,8 +786,8 @@ func (tasks *BuildReleaseTasks) uploadArtifacts(ctx *workflow.TaskContext, artif
762
786
}
763
787
}
764
788
765
- func uploadArtifact (stagingFS , servingFS fs.FS , a artifact ) error {
766
- in , err := stagingFS .Open (a .SignedPath )
789
+ func uploadArtifact (scratchFS , servingFS fs.FS , a artifact ) error {
790
+ in , err := scratchFS .Open (a .SignedPath )
767
791
if err != nil {
768
792
return err
769
793
}
0 commit comments