@@ -146,35 +146,27 @@ func (r *ReleaseVSCodeGoTasks) NewPrereleaseDefinition() *wf.Definition {
146
146
147
147
release := wf .Task1 (wd , "determine the release version" , r .determineReleaseVersion , versionBumpStrategy )
148
148
prerelease := wf .Task1 (wd , "find the next pre-release version" , r .nextPrereleaseVersion , release )
149
- revision := wf .Task2 (wd , "find the revision for the pre-release version" , r .findRevision , release , prerelease )
150
149
approved := wf .Action2 (wd , "await release coordinator's approval" , r .approveStablePrerelease , release , prerelease )
151
150
152
- verified := wf .Action1 (wd , "verify the release candidate" , r .verifyTestResults , revision , wf .After (approved ))
151
+ branch := wf .Task2 (wd , "create release branch" , r .createReleaseBranch , release , prerelease , wf .After (approved ))
152
+
153
+ changeID := wf .Task2 (wd , "update package.json in release branch" , r .updatePackageJSONVersionInReleaseBranch , release , coordinators , wf .After (branch ))
154
+ submitted := wf .Task1 (wd , "await config CL submission" , clAwaiter {r .Gerrit }.awaitSubmission , changeID )
155
+
156
+ // Read the head of the release branch after the required CL submission.
157
+ revision := wf .Task2 (wd , "find the revision for the pre-release version" , r .Gerrit .ReadBranchHead , wf .Const ("vscode-go" ), branch , wf .After (submitted ))
158
+ verified := wf .Action1 (wd , "verify the release candidate" , r .verifyTestResults , revision )
153
159
154
160
issue := wf .Task2 (wd , "create release milestone and issue" , r .createReleaseMilestoneAndIssue , release , coordinators , wf .After (verified ))
155
- branched := wf .Action2 (wd , "create release branch" , r .createReleaseBranch , release , prerelease , wf .After (verified ))
156
161
build := wf .Task3 (wd , "generate package extension (.vsix) for release candidate" , r .generatePackageExtension , release , prerelease , revision , wf .After (verified ))
157
162
158
- tagged := wf .Action3 (wd , "tag the release candidate" , r .tag , revision , release , prerelease , wf .After (branched ))
163
+ tagged := wf .Action3 (wd , "tag the release candidate" , r .tag , revision , release , prerelease , wf .After (branch ))
159
164
released := wf .Action3 (wd , "create release note" , r .createGitHubReleaseDraft , release , prerelease , build , wf .After (tagged ))
160
165
161
166
wf .Action4 (wd , "mail announcement" , r .mailAnnouncement , release , prerelease , revision , issue , wf .After (released ))
162
167
return wd
163
168
}
164
169
165
- // findRevision determines the appropriate revision for the current release.
166
- // Returns the head of the master branch if this is the first release candidate
167
- // for a stable minor version (as no release branch exists yet).
168
- // Returns the head of the corresponding release branch otherwise.
169
- func (r * ReleaseVSCodeGoTasks ) findRevision (ctx * wf.TaskContext , release releaseVersion , prerelease string ) (string , error ) {
170
- branch := vscodeGoReleaseBranch (release )
171
- if release .Patch == 0 && prerelease == "rc.1" {
172
- branch = "master"
173
- }
174
-
175
- return r .Gerrit .ReadBranchHead (ctx , "vscode-go" , branch )
176
- }
177
-
178
170
func (r * ReleaseVSCodeGoTasks ) verifyTestResults (ctx * wf.TaskContext , revision string ) error {
179
171
// We are running all tests in a docker as a user 'node' (uid: 1000)
180
172
// Let the user own the directory.
@@ -269,48 +261,48 @@ func (r *ReleaseVSCodeGoTasks) createReleaseMilestoneAndIssue(ctx *wf.TaskContex
269
261
270
262
// createReleaseBranch creates corresponding release branch only for the initial
271
263
// release candidate of a minor version.
272
- func (r * ReleaseVSCodeGoTasks ) createReleaseBranch (ctx * wf.TaskContext , release releaseVersion , prerelease string ) error {
264
+ func (r * ReleaseVSCodeGoTasks ) createReleaseBranch (ctx * wf.TaskContext , release releaseVersion , prerelease string ) ( string , error ) {
273
265
branch := fmt .Sprintf ("release-v%v.%v" , release .Major , release .Minor )
274
266
releaseHead , err := r .Gerrit .ReadBranchHead (ctx , "vscode-go" , branch )
275
267
276
268
if err == nil {
277
269
ctx .Printf ("Found the release branch %q with head pointing to %s\n " , branch , releaseHead )
278
- return nil
270
+ return branch , nil
279
271
}
280
272
281
273
if ! errors .Is (err , gerrit .ErrResourceNotExist ) {
282
- return fmt .Errorf ("failed to read the release branch: %w" , err )
274
+ return "" , fmt .Errorf ("failed to read the release branch: %w" , err )
283
275
}
284
276
285
277
// Require vscode release branch existence if this is a non-minor release.
286
278
if release .Patch != 0 {
287
- return fmt .Errorf ("release branch is required for patch releases: %w" , err )
279
+ return "" , fmt .Errorf ("release branch is required for patch releases: %w" , err )
288
280
}
289
281
290
282
rc , err := prereleaseNumber (prerelease )
291
283
if err != nil {
292
- return err
284
+ return "" , err
293
285
}
294
286
295
287
// Require vscode release branch existence if this is not the first rc in
296
288
// a minor release.
297
289
if rc != 1 {
298
- return fmt .Errorf ("release branch is required for non-initial release candidates: %w" , err )
290
+ return "" , fmt .Errorf ("release branch is required for non-initial release candidates: %w" , err )
299
291
}
300
292
301
293
// Create the release branch using the revision from the head of master branch.
302
294
head , err := r .Gerrit .ReadBranchHead (ctx , "vscode-go" , "master" )
303
295
if err != nil {
304
- return err
296
+ return "" , err
305
297
}
306
298
307
299
ctx .DisableRetries () // Beyond this point we want retries to be done manually, not automatically.
308
300
_ , err = r .Gerrit .CreateBranch (ctx , "vscode-go" , branch , gerrit.BranchInput {Revision : head })
309
301
if err != nil {
310
- return err
302
+ return "" , err
311
303
}
312
304
ctx .Printf ("Created branch %q at revision %s.\n " , branch , head )
313
- return nil
305
+ return branch , nil
314
306
}
315
307
316
308
// generatePackageExtension builds the vscode-go package extension from source.
@@ -776,7 +768,7 @@ func (r *ReleaseVSCodeGoTasks) NewInsiderDefinition() *wf.Definition {
776
768
777
769
reviewers := wf .Param (wd , reviewersParam )
778
770
779
- changeID := wf .Task1 (wd , "update package.json in master branch" , r .updatePackageJSONVersion , reviewers )
771
+ changeID := wf .Task1 (wd , "update package.json in master branch" , r .updatePackageJSONVersionInMasterBranch , reviewers )
780
772
submitted := wf .Task1 (wd , "await config CL submission" , clAwaiter {r .Gerrit }.awaitSubmission , changeID )
781
773
782
774
release := wf .Task0 (wd , "determine the insider version" , r .determineInsiderVersion )
@@ -819,12 +811,20 @@ func (r *ReleaseVSCodeGoTasks) determineInsiderVersion(ctx *wf.TaskContext) (rel
819
811
return insider , nil
820
812
}
821
813
822
- // updatePackageJSONVersion updates the "package.json" and "package-lock.json"
823
- // files in the master branch of the vscode-go repository.
814
+ // updatePackageJSONVersionInReleaseBranch updates the "package.json" and
815
+ // "package-lock.json" files in the release branch of the vscode-go repository.
816
+ // The "package.json" and "package-lock.json" will reference the current release
817
+ // version.
818
+ func (r * ReleaseVSCodeGoTasks ) updatePackageJSONVersionInReleaseBranch (ctx * wf.TaskContext , release releaseVersion , reviewers []string ) (string , error ) {
819
+ return r .updatePackageJSONVersion (ctx , vscodeGoReleaseBranch (release ), release .String ()[1 :], reviewers )
820
+ }
821
+
822
+ // updatePackageJSONVersionInMasterBranch updates the "package.json" and
823
+ // "package-lock.json" files in the master branch of the vscode-go repository.
824
824
// The updated "package.json" and "package-lock.json" will reference the next
825
825
// stable release version with special suffix "-dev" to indicate this is a
826
826
// prerelease.
827
- func (r * ReleaseVSCodeGoTasks ) updatePackageJSONVersion (ctx * wf.TaskContext , reviewers []string ) (string , error ) {
827
+ func (r * ReleaseVSCodeGoTasks ) updatePackageJSONVersionInMasterBranch (ctx * wf.TaskContext , reviewers []string ) (string , error ) {
828
828
tags , err := r .Gerrit .ListTags (ctx , "vscode-go" )
829
829
if err != nil {
830
830
return "" , err
@@ -842,10 +842,19 @@ func (r *ReleaseVSCodeGoTasks) updatePackageJSONVersion(ctx *wf.TaskContext, rev
842
842
// point to "0.46.0-dev".
843
843
devVersion := versionString (releaseVersion {Major : latestStable .Major , Minor : latestStable .Minor + 2 , Patch : 0 }, "dev" )[1 :]
844
844
845
- clTitle := "extension/package.json: update version to " + devVersion
846
- openCL , err := openCL (ctx , r .Gerrit , "vscode-go" , "master" , clTitle )
845
+ return r .updatePackageJSONVersion (ctx , "master" , devVersion , reviewers )
846
+ }
847
+
848
+ // updatePackageJSONVersion updates the "package.json" and "package-lock.json"
849
+ // files in the given branch of the vscode-go repository with the desired version.
850
+ func (r * ReleaseVSCodeGoTasks ) updatePackageJSONVersion (ctx * wf.TaskContext , branch string , version string , reviewers []string ) (string , error ) {
851
+ clTitle := "extension/package.json: update version to " + version
852
+ if branch != "master" {
853
+ clTitle = "[" + branch + "]" + clTitle
854
+ }
855
+ openCL , err := openCL (ctx , r .Gerrit , "vscode-go" , branch , clTitle )
847
856
if err != nil {
848
- return "" , fmt .Errorf ("failed to find the open CL of title %q in branch %q: %w" , clTitle , "master" , err )
857
+ return "" , fmt .Errorf ("failed to find the open CL of title %q in branch %q: %w" , clTitle , branch , err )
849
858
}
850
859
if openCL != "" {
851
860
ctx .Printf ("not creating CL: found existing CL %s" , openCL )
@@ -862,7 +871,7 @@ npm ci &> npm-output.log
862
871
npx vsce package %s --no-git-tag-version &> npx-output.log
863
872
cat npm-output.log
864
873
cat npx-output.log
865
- ` , devVersion )
874
+ ` , version )
866
875
867
876
saveScriptFmt := cloudBuildClientScriptPrefix
868
877
for _ , file := range []string {
@@ -881,6 +890,11 @@ cat npx-output.log
881
890
Name : "gcr.io/cloud-builders/git" ,
882
891
Args : []string {"clone" , "https://go.googlesource.com/vscode-go" , "vscode-go" },
883
892
},
893
+ {
894
+ Name : "gcr.io/cloud-builders/git" ,
895
+ Args : []string {"checkout" , branch },
896
+ Dir : "vscode-go" ,
897
+ },
884
898
{
885
899
Name : "gcr.io/cloud-builders/npm" ,
886
900
Script : script ,
@@ -908,11 +922,13 @@ cat npx-output.log
908
922
ctx .Printf ("the output from npx package:\n %s\n " , outputs ["npx-output.log" ])
909
923
910
924
changed := map [string ]string {}
911
- if outputs ["package.json" ] != outputs ["package.json.before" ] {
912
- changed ["extension/package.json" ] = outputs ["package.json" ]
925
+ // "npx vsce package" generate "package.json" with an offending trailing
926
+ // new line. Remove this new line before creating the CL.
927
+ if after := strings .TrimRight (outputs ["package.json" ], "\n " ); after != outputs ["package.json.before" ] {
928
+ changed ["extension/package.json" ] = after
913
929
}
914
- if outputs ["package-lock.json" ] != outputs ["package-lock.json.before" ] {
915
- changed ["extension/package-lock.json" ] = outputs [ "package-lock.json" ]
930
+ if after := outputs ["package-lock.json" ]; after != outputs ["package-lock.json.before" ] {
931
+ changed ["extension/package-lock.json" ] = after
916
932
}
917
933
918
934
// Skip CL creation as nothing changed.
@@ -923,7 +939,7 @@ cat npx-output.log
923
939
924
940
changeID , err := r .Gerrit .CreateAutoSubmitChange (ctx , gerrit.ChangeInput {
925
941
Project : "vscode-go" ,
926
- Branch : "master" ,
942
+ Branch : branch ,
927
943
Subject : fmt .Sprintf ("%s\n \n This is an automated CL which updates the package.json and package-lock.json.\n " , clTitle ),
928
944
}, reviewers , changed )
929
945
if err != nil {
0 commit comments