@@ -30,7 +30,6 @@ package main
3030
3131import (
3232 "archive/zip"
33- "bytes"
3433 "encoding/json"
3534 "flag"
3635 "fmt"
@@ -226,17 +225,16 @@ func runPublish(cmd *command, args []string) {
226225
227226 checkWD ()
228227
229- requireTools ("jq" , " npx" , "gh" , "git " )
228+ requireTools ("npx" )
230229
230+ // npx vsce directly reads VSCE_PAT, so no parsing is needed.
231+ // See https://github.com/microsoft/vscode-vsce/blob/ba6681809080ee8685fb86d4b4fca765f1d82708/src/main.ts#L186
231232 requireEnv ("VSCE_PAT" )
232- requireEnv ("GITHUB_TOKEN" )
233233 tagName := requireEnv ("TAG_NAME" )
234234
235235 version , isPrerelease := releaseVersionInfo (tagName )
236- checkPackageJSON (tagName , isPrerelease )
237236 inDir := prepareInputDir (cmd .lookupFlag ("in" ).String ())
238- vsix := filepath .Join (inDir , fmt .Sprintf ("go-%s.vsix" , version ))
239- publish (tagName , vsix , isPrerelease )
237+ publish (tagName , filepath .Join (inDir , fmt .Sprintf ("go-%s.vsix" , version )), isPrerelease )
240238}
241239
242240func fatalf (format string , args ... any ) {
@@ -354,40 +352,6 @@ func parseVersionTagName(tagName string) (major, minor, patch int, label string)
354352 return atoi ("Major" ), atoi ("Minor" ), atoi ("Patch" ), m [versionTagRE .SubexpIndex ("Label" )]
355353}
356354
357- // checkPackageJSON checks if package.json has the expected version value.
358- // If prerelease, the major/minor version should match.
359- // Otherwise, major/minor/patch version should match.
360- func checkPackageJSON (tagName string , isPrerelease bool ) {
361- if ! strings .HasPrefix (tagName , "v" ) {
362- fatalf ("unexpected tagName in checkPackageJSON: %q" , tagName )
363- }
364-
365- if flagN {
366- tracef ("jq -r .version package.json" )
367- return
368- }
369- cmd := exec .Command ("jq" , "-r" , ".version" , "package.json" )
370- cmd .Stderr = os .Stderr
371- var buf bytes.Buffer
372- cmd .Stdout = & buf
373- if err := commandRun (cmd ); err != nil {
374- fatalf ("failed to read package.json version" )
375- }
376-
377- versionInPackageJSON := string (bytes .TrimSpace (buf .Bytes ()))
378- if ! isPrerelease {
379- if got , want := versionInPackageJSON , tagName [1 :]; got != want {
380- fatalf ("package.json version %q does not match wanted string %q" , got , want )
381- }
382- return
383- }
384- // Check only major.minor for prerelease.
385- major , minor , _ , _ := parseVersionTagName (tagName )
386- if want := fmt .Sprintf ("%d.%d." , major , minor ); ! strings .HasPrefix (versionInPackageJSON , want ) {
387- fatalf ("package.json version %q does not match wanted string %q" , versionInPackageJSON , want )
388- }
389- }
390-
391355func commandRun (cmd * exec.Cmd ) error {
392356 if flagN {
393357 if cmd .Dir != "" {
@@ -456,36 +420,21 @@ func buildPackage(version, tagName string, isPrerelease bool, output string) {
456420 }
457421}
458422
459- // publish publishes the extension to the VS Code Marketplace and GitHub, using npx vsce and gh release create .
423+ // publish publishes the extension to the VS Code Marketplace using npx vsce.
460424func publish (tagName , packageFile string , isPrerelease bool ) {
425+ // Skip prerelease versions, as they are not published to the marketplace.
426+ if strings .Contains (tagName , "-rc." ) {
427+ return
428+ }
429+
461430 // check if the package file exists.
462431 if flagN {
463432 tracef ("stat %s" , packageFile )
464433 } else {
465434 if _ , err := os .Stat (packageFile ); os .IsNotExist (err ) {
466- fatalf ("package file %q does not exist. Did you run 'go run build /release.go package'?" , packageFile )
435+ fatalf ("package file %q does not exist. Did you run 'go run tools/release /release.go package'?" , packageFile )
467436 }
468437 }
469- isRC := strings .Contains (tagName , "-rc." )
470-
471- // publish release to GitHub. This will create a draft release - manually publish it after reviewing the draft.
472- // TODO(hyangah): populate the changelog (the first section of CHANGELOG.md) and pass it using --notes-file instead of --generate-notes.
473- ghArgs := []string {"release" , "create" , "--generate-notes" , "--target" , commitSHA (), "--title" , "Release " + tagName , "--draft" }
474- fmt .Printf ("%s\n " , strings .Join (ghArgs , " " ))
475- if isRC || isPrerelease {
476- ghArgs = append (ghArgs , "--prerelease" )
477- }
478- ghArgs = append (ghArgs , "-R" , "github.com/golang/vscode-go" )
479- ghArgs = append (ghArgs , tagName , packageFile )
480- cmd := exec .Command ("gh" , ghArgs ... )
481- cmd .Stderr = os .Stderr
482- if err := commandRun (cmd ); err != nil {
483- fatalf ("failed to publish release: %v" , err )
484- }
485-
486- if isRC { // Do not publish RC versions to the marketplace.
487- return
488- }
489438
490439 npxVsceArgs := []string {"vsce" , "publish" , "-i" , packageFile }
491440 if isPrerelease {
0 commit comments