@@ -157,9 +157,10 @@ export const sitesDeployCommand = defineCommand<DeployArgs>({
157157 return createLinkedSite ( { coreClient, computeClient, name } ) ;
158158 } ,
159159 } ) ;
160- const { state, connection, etag } = site ;
160+ const { state, connection } = site ;
161+
162+ let etag = site . etag ;
161163
162- // Build before hashing so the deploy ID keys on the output (and a first build can create the dir).
163164 let autoDir : string | undefined ;
164165 if ( args . build !== undefined ) {
165166 const command = args . build || siteConfig ?. config . build ;
@@ -295,14 +296,8 @@ export const sitesDeployCommand = defineCommand<DeployArgs>({
295296 record ,
296297 ...state . deploys . filter ( ( d ) => d . id !== record . id ) ,
297298 ] ;
299+ etag = await writeRemoteState ( connection , state , etag ) ;
298300 }
299- if ( args . production ) {
300- if ( state . current && state . current !== deployId ) {
301- state . previous = state . current ;
302- }
303- state . current = deployId ;
304- }
305- await writeRemoteState ( connection , state , etag ) ;
306301
307302 if ( args . production ) {
308303 const promoteSpin = spinner ( "Publishing to production..." ) ;
@@ -314,6 +309,11 @@ export const sitesDeployCommand = defineCommand<DeployArgs>({
314309 state,
315310 deployId,
316311 } ) ;
312+ if ( state . current && state . current !== deployId ) {
313+ state . previous = state . current ;
314+ }
315+ state . current = deployId ;
316+ etag = await writeRemoteState ( connection , state , etag ) ;
317317 } finally {
318318 promoteSpin . stop ( ) ;
319319 }
0 commit comments