@hubspot/npm-scripts 0.3.4-experimental.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -155,16 +155,18 @@ Merging the PR should trigger your publish workflow. Dist-tags aren't changed lo
155
155
 
156
156
  **`experimental`** dispatches a workflow that publishes the current branch:
157
157
 
158
- 1. Check that you're not on the main or previous branch, and that the branch is pushed: it has an upstream and `HEAD` matches `origin/<branch>`
159
- 2. Show the expected version and confirm. The workflow recomputes the final version.
158
+ 1. Check that you're not on the main or previous branch, that your active `gh` account can access the repository, and that the branch is pushed: `HEAD` matches `origin/<branch>`
159
+ 2. Show the current `latest` version, the last experimental release, and the new version, and confirm. The workflow recomputes the final version.
160
160
  3. Run `gh workflow run <experimentalWorkflow> --ref <mainBranch> -f branch=<branch> -f sha=<HEAD sha>`. The workflow always runs from the main branch.
161
- 4. Find the run, print its URL, and stream it with `gh run watch`
161
+ 4. Find the run, link to it, and print each job as it finishes
162
162
  5. Download the `experimental-version` artifact and print the published version and its `yarn add` command
163
163
 
164
164
  With `-d`, the script runs the checks and prints the `gh workflow run` command without dispatching it.
165
165
 
166
166
  The workflow (`experimental-release.yml` by default, set with `experimentalWorkflow`) must accept `branch` and `sha` inputs, set `run-name: "Experimental release ${{ inputs.branch }}@${{ inputs.sha }}"` so the script can find the run, and upload an artifact named `experimental-version` with a `version.txt` file that contains the published version.
167
167
 
168
+ Run your publish jobs in a [GitHub environment](https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments) that only the main branch can deploy to, and set that environment on the package's npm trusted publishers. Otherwise anyone with write access can publish by running a modified workflow from another branch.
169
+
168
170
  #### Features
169
171
 
170
172
  - **Branch protection**: Ensures releases are made from the correct branch
@@ -256,3 +258,5 @@ yarn experimental-release
256
258
  ```
257
259
 
258
260
  The [Release](.github/workflows/release.yml) workflow builds and dry-run publishes each release PR, then publishes when the PR merges. It also tags the merge commit, moves the `next` dist-tag to each `latest` release, and creates the GitHub release for `latest`. The [Experimental Release](.github/workflows/experimental-release.yml) workflow publishes the given branch commit on the `experimental` tag.
261
+
262
+ Both publish jobs run in the `npm-publish` environment, which only `master` can deploy to. The package's npm trusted publishers require that environment.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/npm-scripts",
3
- "version": "0.3.4-experimental.0",
3
+ "version": "0.4.0",
4
4
  "description": "Scripts for working with npm packages in the HubSpot ecosystem",
5
5
  "author": "",
6
6
  "license": "Apache-2.0",
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
2
  import { buildReleaseScript } from '../release.js';
3
- import { exec as _exec, execFile as _execFile, execSync, } from 'node:child_process';
3
+ import { exec as _exec, execFile as _execFile } from 'node:child_process';
4
4
  import yargs from 'yargs';
5
5
  import { getCurrentGitBranch, gitCleanup } from '../utils/git.js';
6
6
  import { getDistTags, getPublishedVersions, publish, updateNextTag, updatePreviousTag, } from '../utils/npm.js';
@@ -38,6 +38,7 @@ vi.mock('../utils/logging.js', () => ({
38
38
  success: vi.fn(),
39
39
  warn: vi.fn(),
40
40
  },
41
+ uiLink: (text, url) => `${text}: ${url}`,
41
42
  }));
42
43
  vi.mock('open', () => ({
43
44
  default: vi.fn().mockResolvedValue(undefined),
@@ -857,7 +858,9 @@ describe('release handler', () => {
857
858
  skipBranchValidation: false,
858
859
  skipVersionCheck: false,
859
860
  };
861
+ let runStatus;
860
862
  beforeEach(() => {
863
+ runStatus = { status: 'completed', conclusion: 'success', jobs: [] };
861
864
  vi.mocked(getCurrentGitBranch).mockResolvedValue('feature-branch');
862
865
  mockedExec.mockImplementation((cmd) => Promise.resolve({
863
866
  stdout: cmd.startsWith('git rev-parse HEAD') ||
@@ -874,7 +877,9 @@ describe('release handler', () => {
874
877
  return Promise.resolve({
875
878
  stdout: args[0] === 'run' && args[1] === 'list'
876
879
  ? JSON.stringify(isDispatched ? [RUN] : [])
877
- : '',
880
+ : args[0] === 'run' && args[1] === 'view'
881
+ ? JSON.stringify(runStatus)
882
+ : '',
878
883
  stderr: '',
879
884
  });
880
885
  });
@@ -897,9 +902,13 @@ describe('release handler', () => {
897
902
  '-f',
898
903
  `sha=${HEAD_SHA}`,
899
904
  ]);
900
- expect(execSync).toHaveBeenCalledWith('gh run watch 99 --exit-status', {
901
- stdio: 'inherit',
902
- });
905
+ expect(mockedExecFile).toHaveBeenCalledWith('gh', [
906
+ 'run',
907
+ 'view',
908
+ '99',
909
+ '--json',
910
+ 'status,conclusion,jobs',
911
+ ]);
903
912
  expect(logger.success).toHaveBeenCalledWith('Published @hubspot/test-package@1.0.0-experimental.0 on the experimental tag');
904
913
  });
905
914
  it('uses the experimentalWorkflow option', async () => {
@@ -939,9 +948,7 @@ describe('release handler', () => {
939
948
  expectOnlyRepoAccessCheck();
940
949
  });
941
950
  it('exits non-zero with the run URL when the workflow fails', async () => {
942
- vi.mocked(execSync).mockImplementation(() => {
943
- throw new Error('exit 1');
944
- });
951
+ runStatus = { status: 'completed', conclusion: 'failure', jobs: [] };
945
952
  const exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => {
946
953
  throw new Error('process.exit called');
947
954
  });
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
- import { logger } from '../logging.js';
2
+ import { logger, uiLink } from '../logging.js';
3
3
  describe('logging', () => {
4
4
  const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
5
5
  beforeEach(() => {
@@ -61,4 +61,18 @@ describe('logging', () => {
61
61
  consoleTableSpy.mockRestore();
62
62
  });
63
63
  });
64
+ describe('uiLink', () => {
65
+ const originalIsTTY = process.stdout.isTTY;
66
+ afterEach(() => {
67
+ process.stdout.isTTY = originalIsTTY;
68
+ });
69
+ it('should return a terminal hyperlink when stdout is a TTY', () => {
70
+ process.stdout.isTTY = true;
71
+ expect(uiLink('View it', 'https://example.com')).toBe('\u001B]8;;https://example.com\u0007View it\u001B]8;;\u0007');
72
+ });
73
+ it('should include the URL as text when stdout is not a TTY', () => {
74
+ process.stdout.isTTY = false;
75
+ expect(uiLink('View it', 'https://example.com')).toBe('View it: https://example.com');
76
+ });
77
+ });
64
78
  });
@@ -6,3 +6,4 @@ export declare const logger: {
6
6
  error(...args: unknown[]): void;
7
7
  table(...args: unknown[]): void;
8
8
  };
9
+ export declare function uiLink(text: string, url: string): string;
@@ -19,3 +19,9 @@ export const logger = {
19
19
  console.table(...args);
20
20
  },
21
21
  };
22
+ export function uiLink(text, url) {
23
+ if (!process.stdout.isTTY) {
24
+ return `${text}: ${url}`;
25
+ }
26
+ return `\u001B]8;;${url}\u0007${text}\u001B]8;;\u0007`;
27
+ }
@@ -8,7 +8,7 @@ import { gitCleanup } from '../../../utils/git.js';
8
8
  import { publish, updateNextTag, updatePreviousTag, } from '../../../utils/npm.js';
9
9
  import { confirm, select } from '../../../utils/prompting.js';
10
10
  import { TAG, INCREMENT } from '../../../constants/release.js';
11
- import { confirmRelease, runBuild, tryBuild, createTempBranch, bumpVersion, ensureNpmAuth, tryPublish, updateDistTagsForLatest, finalizeRelease, logReleaseSuccess, ensureCleanWorkingTree, ensureGhCli, ensureBranchPushed, findWorkflowRun, openReleasePr, resolveVersionIncrement, runExperimentalWorkflow, } from '../steps.js';
11
+ import { confirmRelease, runBuild, tryBuild, createTempBranch, bumpVersion, ensureNpmAuth, tryPublish, updateDistTagsForLatest, finalizeRelease, logReleaseSuccess, ensureCleanWorkingTree, ensureGhCli, ensureBranchPushed, findWorkflowRun, openReleasePr, resolveVersionIncrement, runExperimentalWorkflow, watchWorkflowRun, } from '../steps.js';
12
12
  import { ReleaseError } from '../errors.js';
13
13
  vi.mock('util', () => ({ promisify: vi.fn(fn => fn) }));
14
14
  vi.mock('node:child_process', () => ({
@@ -19,6 +19,7 @@ vi.mock('node:child_process', () => ({
19
19
  vi.mock('open', () => ({ default: vi.fn().mockResolvedValue(undefined) }));
20
20
  vi.mock('../../../utils/logging.js', () => ({
21
21
  logger: { log: vi.fn(), error: vi.fn(), success: vi.fn(), warn: vi.fn() },
22
+ uiLink: (text, url) => `${text}: ${url}`,
22
23
  }));
23
24
  vi.mock('../../../utils/process.js', () => ({
24
25
  EXIT_CODES: { SUCCESS: 0, ERROR: 1 },
@@ -497,23 +498,45 @@ describe('release/steps', () => {
497
498
  packageName: PACKAGE_NAME,
498
499
  isDryRun: false,
499
500
  };
500
- beforeEach(() => {
501
+ const SUCCEEDED = {
502
+ status: 'completed',
503
+ conclusion: 'success',
504
+ jobs: [
505
+ { name: 'version', status: 'completed', conclusion: 'success' },
506
+ { name: 'publish', status: 'completed', conclusion: 'success' },
507
+ ],
508
+ };
509
+ function mockRuns(runStatus) {
501
510
  let isDispatched = false;
502
511
  mockedExecFile.mockImplementation((_file, args) => {
503
512
  if (args[0] === 'workflow') {
504
513
  isDispatched = true;
505
514
  }
506
515
  return Promise.resolve({
507
- stdout: args[1] === 'list' ? JSON.stringify(isDispatched ? [RUN] : []) : '',
516
+ stdout: args[1] === 'list'
517
+ ? JSON.stringify(isDispatched ? [RUN] : [])
518
+ : args[1] === 'view'
519
+ ? JSON.stringify(runStatus)
520
+ : '',
508
521
  stderr: '',
509
522
  });
510
523
  });
524
+ }
525
+ beforeEach(() => {
526
+ mockRuns(SUCCEEDED);
511
527
  vi.mocked(fs.mkdtemp).mockResolvedValue('/tmp/exp-1');
512
528
  vi.mocked(fs.readFile).mockResolvedValue('1.0.0-experimental.3\n');
513
529
  });
514
530
  it('should dispatch, watch, download the version, and print the install command', async () => {
515
531
  await runExperimentalWorkflow(BASE_ARGS);
516
- expect(mockedExecSync).toHaveBeenCalledWith('gh run watch 7 --exit-status', { stdio: 'inherit' });
532
+ expect(mockedExecFile).toHaveBeenCalledWith('gh', [
533
+ 'run',
534
+ 'view',
535
+ '7',
536
+ '--json',
537
+ 'status,conclusion,jobs',
538
+ ]);
539
+ expect(logger.log).toHaveBeenCalledWith('Workflow completed successfully');
517
540
  expect(mockedExecFile).toHaveBeenCalledWith('gh', [
518
541
  'run',
519
542
  'download',
@@ -525,7 +548,7 @@ describe('release/steps', () => {
525
548
  ]);
526
549
  expect(vi.mocked(fs.readFile)).toHaveBeenCalledWith('/tmp/exp-1/version.txt', 'utf8');
527
550
  expect(vi.mocked(fs.remove)).toHaveBeenCalledWith('/tmp/exp-1');
528
- expect(logger.log).toHaveBeenCalledWith(`Workflow run: ${RUN.url}`);
551
+ expect(logger.log).toHaveBeenCalledWith(`View workflow in GitHub: ${RUN.url}`);
529
552
  expect(logger.success).toHaveBeenCalledWith(`Published ${PACKAGE_NAME}@1.0.0-experimental.3 on the experimental tag`);
530
553
  expect(logger.log).toHaveBeenCalledWith(`Install it with: yarn add ${PACKAGE_NAME}@1.0.0-experimental.3`);
531
554
  });
@@ -550,7 +573,7 @@ describe('release/steps', () => {
550
573
  await vi.runAllTimersAsync();
551
574
  await assertion;
552
575
  vi.useRealTimers();
553
- expect(mockedExecSync).not.toHaveBeenCalled();
576
+ expect(mockedExecFile).not.toHaveBeenCalledWith('gh', expect.arrayContaining(['view']));
554
577
  });
555
578
  it('should throw an actionable ReleaseError when the dispatch fails', async () => {
556
579
  mockedExecFile.mockImplementation((_file, args) => args[0] === 'workflow'
@@ -566,13 +589,24 @@ describe('release/steps', () => {
566
589
  await vi.runAllTimersAsync();
567
590
  await assertion;
568
591
  vi.useRealTimers();
569
- expect(mockedExecSync).not.toHaveBeenCalled();
592
+ expect(mockedExecFile).not.toHaveBeenCalledWith('gh', expect.arrayContaining(['view']));
570
593
  });
571
- it('should throw with the run URL when the workflow fails', async () => {
572
- mockedExecSync.mockImplementation(() => {
573
- throw new Error('exit 1');
594
+ it('should name the failed job and link the run when the workflow fails', async () => {
595
+ mockRuns({
596
+ status: 'completed',
597
+ conclusion: 'failure',
598
+ jobs: [
599
+ { name: 'version', status: 'completed', conclusion: 'success' },
600
+ { name: 'build', status: 'completed', conclusion: 'failure' },
601
+ { name: 'publish', status: 'completed', conclusion: 'skipped' },
602
+ ],
574
603
  });
575
- await expect(runExperimentalWorkflow(BASE_ARGS)).rejects.toThrow(`The experimental release workflow failed. See ${RUN.url}`);
604
+ await expect(runExperimentalWorkflow(BASE_ARGS)).rejects.toThrow(`The experimental release workflow failed in the build job. See ${RUN.url}`);
605
+ expect(logger.log).not.toHaveBeenCalledWith('Workflow completed successfully');
606
+ });
607
+ it('should report the run conclusion when no job failed', async () => {
608
+ mockRuns({ status: 'completed', conclusion: 'cancelled', jobs: [] });
609
+ await expect(runExperimentalWorkflow(BASE_ARGS)).rejects.toThrow(`The experimental release workflow finished with 'cancelled'. See ${RUN.url}`);
576
610
  });
577
611
  it('should warn with the run URL but succeed when the version artifact cannot be read', async () => {
578
612
  vi.mocked(fs.readFile).mockRejectedValue(new Error('ENOENT'));
@@ -581,6 +615,62 @@ describe('release/steps', () => {
581
615
  expect(vi.mocked(fs.remove)).toHaveBeenCalledWith('/tmp/exp-1');
582
616
  });
583
617
  });
618
+ describe('watchWorkflowRun', () => {
619
+ const job = (name, status, conclusion = '') => ({
620
+ name,
621
+ status,
622
+ conclusion,
623
+ });
624
+ function mockStatuses(...responses) {
625
+ for (const response of responses) {
626
+ if (response instanceof Error) {
627
+ mockedExecFile.mockRejectedValueOnce(response);
628
+ }
629
+ else {
630
+ mockedExecFile.mockResolvedValueOnce({
631
+ stdout: JSON.stringify(response),
632
+ stderr: '',
633
+ });
634
+ }
635
+ }
636
+ }
637
+ it('should log each job once as it finishes and return the completed run', async () => {
638
+ const completed = {
639
+ status: 'completed',
640
+ conclusion: 'success',
641
+ jobs: [
642
+ job('version', 'completed', 'success'),
643
+ job('build', 'completed', 'success'),
644
+ ],
645
+ };
646
+ mockStatuses({
647
+ status: 'in_progress',
648
+ conclusion: '',
649
+ jobs: [
650
+ job('version', 'completed', 'success'),
651
+ job('build', 'in_progress'),
652
+ ],
653
+ }, completed);
654
+ await expect(watchWorkflowRun(7, 0)).resolves.toEqual(completed);
655
+ const logged = vi.mocked(logger.log).mock.calls.map(([line]) => line);
656
+ expect(logged).toHaveLength(2);
657
+ expect(logged[0]).toContain('version');
658
+ expect(logged[1]).toContain('build');
659
+ });
660
+ it('should keep polling through transient status errors', async () => {
661
+ const completed = {
662
+ status: 'completed',
663
+ conclusion: 'success',
664
+ jobs: [],
665
+ };
666
+ mockStatuses(new Error('HTTP 502'), completed);
667
+ await expect(watchWorkflowRun(7, 0, 3)).resolves.toEqual(completed);
668
+ });
669
+ it('should throw after too many status errors in a row', async () => {
670
+ mockStatuses(new Error('HTTP 502'), new Error('HTTP 502'));
671
+ await expect(watchWorkflowRun(7, 0, 2)).rejects.toThrow('HTTP 502');
672
+ });
673
+ });
584
674
  describe('openReleasePr', () => {
585
675
  const BASE_ARGS = {
586
676
  tag: TAG.NEXT,
@@ -16,6 +16,17 @@ type WorkflowRun = {
16
16
  url: string;
17
17
  };
18
18
  export declare function findWorkflowRun(workflow: string, sha: string, existingRunIds: Set<number>, attempts?: number, intervalMs?: number): Promise<WorkflowRun | undefined>;
19
+ type WorkflowJob = {
20
+ name: string;
21
+ status: string;
22
+ conclusion: string;
23
+ };
24
+ type WorkflowRunStatus = {
25
+ status: string;
26
+ conclusion: string;
27
+ jobs: WorkflowJob[];
28
+ };
29
+ export declare function watchWorkflowRun(runId: number, intervalMs?: number, maxStatusErrors?: number): Promise<WorkflowRunStatus>;
19
30
  export declare function runExperimentalWorkflow({ workflow, mainBranch, branch, sha, packageName, isDryRun, }: RunExperimentalWorkflowOptions): Promise<void>;
20
31
  export declare function openReleasePr({ tag, newVersion, isDryRun, baseBranch, repositoryUrl, headBranch, onTempBranch, tempBranch, originalBranch, }: OpenReleasePrOptions): Promise<void>;
21
32
  export declare function tryPublish({ tag, isDryRun, ignoreScripts, registry, newVersion, isExperimental, onTempBranch, tempBranch, originalBranch, }: TryPublishOptions): Promise<void>;
@@ -1,10 +1,11 @@
1
1
  import { exec as _exec, execFile as _execFile, execSync, } from 'node:child_process';
2
2
  import { promisify } from 'util';
3
+ import chalk from 'chalk';
3
4
  import os from 'os';
4
5
  import path from 'path';
5
6
  import fs from 'fs-extra';
6
7
  import open from 'open';
7
- import { logger } from '../../utils/logging.js';
8
+ import { logger, uiLink } from '../../utils/logging.js';
8
9
  import { EXIT_CODES } from '../../utils/process.js';
9
10
  import { gitCleanup } from '../../utils/git.js';
10
11
  import { publish, updateNextTag, updatePreviousTag } from '../../utils/npm.js';
@@ -15,6 +16,7 @@ const exec = promisify(_exec);
15
16
  const execFile = promisify(_execFile);
16
17
  const WORKFLOW_RUN_POLL_ATTEMPTS = 10;
17
18
  const WORKFLOW_RUN_POLL_INTERVAL_MS = 3000;
19
+ const WORKFLOW_RUN_MAX_STATUS_ERRORS = 5;
18
20
  export async function resolveVersionIncrement(tag, versionIncrement, skipPrompts) {
19
21
  if (versionIncrement) {
20
22
  return versionIncrement;
@@ -36,7 +38,7 @@ export async function confirmRelease({ isDryRun, currentVersion, currentVersionL
36
38
  if (lastExperimentalVersion) {
37
39
  logger.log(`Last experimental release: ${lastExperimentalVersion}`);
38
40
  }
39
- logger.log(`New version to release: ${newVersion}`);
41
+ logger.log(`New version to release: ${newVersion}\n`);
40
42
  if (skipPrompts) {
41
43
  logger.log(`Releasing version ${newVersion} on tag ${tag} (--yes)`);
42
44
  }
@@ -221,6 +223,55 @@ export async function findWorkflowRun(workflow, sha, existingRunIds, attempts =
221
223
  }
222
224
  return undefined;
223
225
  }
226
+ async function getWorkflowRunStatus(runId) {
227
+ const { stdout } = await execFile('gh', [
228
+ 'run',
229
+ 'view',
230
+ String(runId),
231
+ '--json',
232
+ 'status,conclusion,jobs',
233
+ ]);
234
+ return JSON.parse(stdout);
235
+ }
236
+ function formatJob({ name, conclusion }) {
237
+ if (conclusion === 'success') {
238
+ return `${chalk.green('✓')} ${name}`;
239
+ }
240
+ if (conclusion === 'skipped') {
241
+ return chalk.dim(`- ${name} (skipped)`);
242
+ }
243
+ return `${chalk.red('✗')} ${name} (${conclusion})`;
244
+ }
245
+ export async function watchWorkflowRun(runId, intervalMs = WORKFLOW_RUN_POLL_INTERVAL_MS, maxStatusErrors = WORKFLOW_RUN_MAX_STATUS_ERRORS) {
246
+ const reportedJobs = new Set();
247
+ let statusErrors = 0;
248
+ for (let attempt = 0;; attempt++) {
249
+ if (attempt > 0) {
250
+ await new Promise(resolve => setTimeout(resolve, intervalMs));
251
+ }
252
+ let run;
253
+ try {
254
+ run = await getWorkflowRunStatus(runId);
255
+ statusErrors = 0;
256
+ }
257
+ catch (e) {
258
+ statusErrors++;
259
+ if (statusErrors >= maxStatusErrors) {
260
+ throw e;
261
+ }
262
+ continue;
263
+ }
264
+ for (const job of run.jobs) {
265
+ if (job.status === 'completed' && !reportedJobs.has(job.name)) {
266
+ reportedJobs.add(job.name);
267
+ logger.log(formatJob(job));
268
+ }
269
+ }
270
+ if (run.status === 'completed') {
271
+ return run;
272
+ }
273
+ }
274
+ }
224
275
  async function readExperimentalVersion(runId) {
225
276
  const downloadDir = await fs.mkdtemp(path.join(os.tmpdir(), 'experimental-version-'));
226
277
  try {
@@ -266,7 +317,7 @@ export async function runExperimentalWorkflow({ workflow, mainBranch, branch, sh
266
317
  logger.error(e);
267
318
  throw new ReleaseError(`Failed to list runs of ${workflow}. Check that the workflow exists on ${mainBranch} and that your gh account can read Actions runs in this repository.`);
268
319
  }
269
- logger.log(`\nDispatching ${workflow} for ${branch}@${sha}...`);
320
+ logger.log('\nInitiating release via GitHub Actions...');
270
321
  try {
271
322
  await execFile('gh', dispatchArgs);
272
323
  }
@@ -278,15 +329,20 @@ export async function runExperimentalWorkflow({ workflow, mainBranch, branch, sh
278
329
  if (!run) {
279
330
  throw new ReleaseError(`Dispatched ${workflow}, but couldn't find its run. Look for "Experimental release ${branch}@${sha}" with: gh run list --workflow ${workflow}`);
280
331
  }
281
- logger.log(`Workflow run: ${run.url}`);
332
+ logger.log(uiLink('View workflow in GitHub', run.url));
333
+ let result;
282
334
  try {
283
- execSync(`gh run watch ${run.databaseId} --exit-status`, {
284
- stdio: 'inherit',
285
- });
335
+ result = await watchWorkflowRun(run.databaseId);
286
336
  }
287
- catch (_e) {
288
- throw new ReleaseError(`The experimental release workflow failed. See ${run.url}`);
337
+ catch (e) {
338
+ logger.error(e);
339
+ throw new ReleaseError(`Couldn't read the status of the experimental release workflow. Check it at ${run.url}`);
340
+ }
341
+ if (result.conclusion !== 'success') {
342
+ const failedJob = result.jobs.find(({ conclusion }) => conclusion && conclusion !== 'success' && conclusion !== 'skipped');
343
+ throw new ReleaseError(`The experimental release workflow ${failedJob ? `failed in the ${failedJob.name} job` : `finished with '${result.conclusion}'`}. See ${run.url}`);
289
344
  }
345
+ logger.log('Workflow completed successfully');
290
346
  let version;
291
347
  try {
292
348
  version = await readExperimentalVersion(run.databaseId);