Skip to content

Commit 671e1e8

Browse files
committed
chore: fix cd to allow rerelease after failed npm publish has been fixed
1 parent 874fefa commit 671e1e8

1 file changed

Lines changed: 38 additions & 5 deletions

File tree

‎.github/workflows/cd.yaml‎

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ on:
44
push:
55
branches:
66
- main
7+
# Re-run the GitHub release, Homebrew, and Windows installer jobs for a version
8+
# that was already published to npm (e.g. after a failed or partial release).
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: Version already published to npm (e.g. 2.1.3)
13+
required: true
14+
type: string
15+
ref:
16+
description: Commit SHA the version was released from (the version packages commit)
17+
required: true
18+
type: string
719

820
concurrency: ${{ github.workflow }}-${{ github.ref }}
921

@@ -17,23 +29,27 @@ jobs:
1729
runs-on: ubuntu-latest
1830

1931
outputs:
20-
cli-released: ${{ steps.changesets.outputs.published }}
21-
cli-version: ${{ steps.cli-metadata.outputs.version }}
22-
cli-tag: ${{ steps.cli-metadata.outputs.tag }}
32+
cli-released: ${{ github.event_name == 'workflow_dispatch' || steps.changesets.outputs.published }}
33+
cli-version: ${{ steps.cli-metadata-manual.outputs.version || steps.cli-metadata.outputs.version }}
34+
cli-tag: ${{ steps.cli-metadata-manual.outputs.tag || steps.cli-metadata.outputs.tag }}
2335

2436
steps:
2537
- name: Checkout Repo
38+
if: github.event_name != 'workflow_dispatch'
2639
uses: actions/checkout@v6.0.1
2740

2841
- name: Setup Node.js
42+
if: github.event_name != 'workflow_dispatch'
2943
uses: actions/setup-node@v6.1.0
3044
with:
3145
node-version: 24.22.1
3246

3347
- name: Install Dependencies
48+
if: github.event_name != 'workflow_dispatch'
3449
run: npm ci
3550

3651
- name: Create Release Pull Request or Publish to npm
52+
if: github.event_name != 'workflow_dispatch'
3753
id: changesets
3854
uses: changesets/action@v1.5.3
3955
with:
@@ -52,7 +68,17 @@ jobs:
5268
echo '${{ steps.changesets.outputs.publishedPackages }}' | jq .
5369
echo 'Published: ${{ steps.changesets.outputs.published }}'
5470
71+
- name: Derive Required Metadata (manual dispatch)
72+
if: github.event_name == 'workflow_dispatch'
73+
id: cli-metadata-manual
74+
run: |
75+
echo "tag=@smartthings/cli@$INPUT_VERSION" >> $GITHUB_OUTPUT
76+
echo "version=$INPUT_VERSION" >> $GITHUB_OUTPUT
77+
env:
78+
INPUT_VERSION: ${{ inputs.version }}
79+
5580
- name: Derive Required Metadata
81+
if: github.event_name != 'workflow_dispatch'
5682
id: cli-metadata
5783
run: | # derive latest info from changesets output
5884
published_package=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq 'map(select(.name == "@smartthings/cli")) | .[]')
@@ -61,8 +87,8 @@ jobs:
6187
6288
- name: Debug Version
6389
run: |
64-
echo "CLI Tag: ${{ steps.cli-metadata.outputs.tag }}"
65-
echo "CLI Version: ${{ steps.cli-metadata.outputs.version }}"
90+
echo "CLI Tag: ${{ steps.cli-metadata-manual.outputs.tag || steps.cli-metadata.outputs.tag }}"
91+
echo "CLI Version: ${{ steps.cli-metadata-manual.outputs.version || steps.cli-metadata.outputs.version }}"
6692
6793
package:
6894
name: Package CLI
@@ -72,6 +98,8 @@ jobs:
7298
steps:
7399
- name: Checkout Repo
74100
uses: actions/checkout@v6.0.1
101+
with:
102+
ref: ${{ inputs.ref || github.sha }}
75103

76104
- name: Setup Node.js
77105
uses: actions/setup-node@v6.1.0
@@ -185,6 +213,8 @@ jobs:
185213
186214
- name: Checkout Repo
187215
uses: actions/checkout@v6.0.1
216+
with:
217+
ref: ${{ inputs.ref || github.sha }}
188218

189219
- name: Download Artifacts
190220
uses: actions/download-artifact@v7.0.0
@@ -204,6 +234,7 @@ jobs:
204234
with:
205235
name: ${{ needs.npm-release.outputs.cli-version }}
206236
tag_name: ${{ needs.npm-release.outputs.cli-tag }}
237+
target_commitish: ${{ inputs.ref || github.sha }}
207238
generate_release_notes: true
208239
prerelease: false
209240
files: 'smartthings-*.{tgz,zip}'
@@ -260,6 +291,8 @@ jobs:
260291

261292
- name: Checkout Repo
262293
uses: actions/checkout@v6.0.1
294+
with:
295+
ref: ${{ inputs.ref || github.sha }}
263296

264297
- name: Download Artifacts
265298
uses: actions/download-artifact@v7.0.0

0 commit comments

Comments
 (0)