@@ -8,6 +8,7 @@ import fs from "fs/promises";
8
8
import { IncomingMessage } from "http" ;
9
9
import path from "path" ;
10
10
import prettyBytes from "pretty-bytes" ;
11
+ import * as semver from "semver" ;
11
12
import * as vscode from "vscode" ;
12
13
import { errToStr } from "./api-helper" ;
13
14
import * as cli from "./cliManager" ;
@@ -139,6 +140,12 @@ export class Storage {
139
140
// and to log for debugging.
140
141
const buildInfo = await restClient . getBuildInfo ( ) ;
141
142
this . output . info ( "Got server version" , buildInfo . version ) ;
143
+ const parsedVersion = semver . parse ( buildInfo . version ) ;
144
+ if ( ! parsedVersion ) {
145
+ throw new Error (
146
+ `Got invalid version from deployment: ${ buildInfo . version } ` ,
147
+ ) ;
148
+ }
142
149
143
150
// Check if there is an existing binary and whether it looks valid. If it
144
151
// is valid and matches the server, or if it does not match the server but
@@ -230,9 +237,11 @@ export class Storage {
230
237
// named exactly the same with an appended `.asc` (such as
231
238
// coder-windows-amd64.exe.asc or coder-linux-amd64.asc).
232
239
binSource + ".asc" ,
233
- // The releases.coder.com bucket does not include the leading "v".
234
- // The signature name follows the same rule as above.
235
- `https://releases.coder.com/coder-cli/${ buildInfo . version . replace ( / ^ v / , "" ) } /${ binName } .asc` ,
240
+ // The releases.coder.com bucket does not include the leading "v",
241
+ // and unlike what we get from buildinfo it uses a truncated version
242
+ // with only major.minor.patch. The signature name follows the same
243
+ // rule as above.
244
+ `https://releases.coder.com/coder-cli/${ parsedVersion . major } .${ parsedVersion . minor } .${ parsedVersion . patch } /${ binName } .asc` ,
236
245
] ) ;
237
246
}
238
247
0 commit comments