Skip to content

Commit cf61030

Browse files
committed
chore: update prep for releasing ESM and yargs-based CLI as version 2.0
1 parent 2cae1fd commit cf61030

File tree

11 files changed

+138
-121
lines changed

11 files changed

+138
-121
lines changed

.changeset/cuddly-ants-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smartthings/cli": major
3+
---
4+
5+
refactor to use yargs

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = {
2727
parserOptions: {
2828
ecmaVersion: 2019,
2929
tsconfigRootDir: __dirname,
30-
project: ['./tsconfig.json', './tsconfig-test.json'],
30+
project: ['./tsconfig.json'],
3131
},
3232
rules: {
3333
indent: 'off',

.github/workflows/cd.yaml

Lines changed: 110 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
concurrency: ${{ github.workflow }}-${{ github.ref }}
99

1010
jobs:
11-
release:
11+
npm-release:
1212
# don't run on forks
1313
if: ${{ github.repository_owner == 'SmartThingsCommunity' }}
1414

@@ -17,16 +17,15 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
outputs:
20-
cli-released: ${{ steps.cli-release.outputs.published }}
2120
cli-version: ${{ steps.cli-metadata.outputs.version }}
2221
cli-tag: ${{ steps.cli-metadata.outputs.tag }}
2322

2423
steps:
2524
- name: Checkout Repo
26-
uses: actions/checkout@v3
25+
uses: actions/checkout@v6.0.1
2726

2827
- name: Setup Node.js
29-
uses: actions/setup-node@v3
28+
uses: actions/setup-node@v6.1.0
3029
with:
3130
node-version: 24.8.0
3231

@@ -35,7 +34,7 @@ jobs:
3534

3635
- name: Create Release Pull Request or Publish to npm
3736
id: changesets
38-
uses: changesets/action@v1
37+
uses: changesets/action@v1.5.3
3938
with:
4039
version: npm run version
4140
publish: npm run release
@@ -46,42 +45,34 @@ jobs:
4645
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4746
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4847

49-
# decouple Github Release from library-only publishing
50-
- name: Check if CLI Published
51-
id: cli-release
52-
run: echo "published=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq 'any(.name == "@smartthings/cli")')" >> $GITHUB_OUTPUT
48+
- name: Debug Published Packages
49+
run: |
50+
echo "Published Packages:"
51+
echo '${{ steps.changesets.outputs.publishedPackages }}' | jq .
5352
5453
- name: Derive Required Metadata
5554
id: cli-metadata
56-
if: steps.cli-release.outputs.published == 'true'
5755
run: | # derive latest info from changesets output
58-
PUBLISHED_PACKAGE=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq 'map(select(.name == "@smartthings/cli")) | .[]')
59-
echo "tag=$(echo $PUBLISHED_PACKAGE | jq --raw-output '.name + "@" + .version')" >> $GITHUB_OUTPUT
60-
echo "version=$(echo $PUBLISHED_PACKAGE | jq --raw-output '.version')" >> $GITHUB_OUTPUT
56+
published_package=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq 'map(select(.name == "@smartthings/cli")) | .[]')
57+
echo "tag=$(echo $published_package | jq --raw-output '.name + "@" + .version')" >> $GITHUB_OUTPUT
58+
echo "version=$(echo $published_package | jq --raw-output '.version')" >> $GITHUB_OUTPUT
59+
60+
- name: Debug Version
61+
run: |
62+
echo "CLI Tag: ${{ steps.cli-metadata.outputs.tag }}"
63+
echo "CLI Version: ${{ steps.cli-metadata.outputs.version }}"
6164
6265
package:
6366
name: Package CLI
6467

6568
runs-on: ubuntu-latest
6669

6770
steps:
68-
- name: Install and Setup QEMU
69-
run: |
70-
sudo apt update
71-
sudo apt install binfmt-support qemu-user-static
72-
73-
# see https://github.com/vercel/pkg/issues/1251#issuecomment-1024832725
74-
- name: Download and Install ldid Codesign Utility
75-
run: |
76-
wget https://github.com/jesec/ldid-static/releases/download/v2.1.4/ldid-amd64
77-
chmod +x ldid-amd64
78-
sudo mv ldid-amd64 /usr/local/bin/ldid
79-
8071
- name: Checkout Repo
81-
uses: actions/checkout@v3
72+
uses: actions/checkout@v6.0.1
8273

8374
- name: Setup Node.js
84-
uses: actions/setup-node@v3
75+
uses: actions/setup-node@v6.1.0
8576
with:
8677
node-version: 24.8.0
8778

@@ -91,16 +82,21 @@ jobs:
9182
- name: Package CLI
9283
run: npm run package
9384

94-
# maintain executable file permissions
95-
# see https://github.com/actions/upload-artifact/issues/38
96-
- name: Tar files
97-
run: tar -cvf dist_bin.tar packages/cli/dist_bin/
85+
- name: Debug List Files after Packaging
86+
run: ls -lR dist_bin
9887

9988
- name: Upload Artifacts
100-
uses: actions/upload-artifact@v4.4.0
89+
id: upload-artifacts
90+
uses: actions/upload-artifact@v6.0.0
10191
with:
102-
name: dist_bin
103-
path: dist_bin.tar
92+
name: Binaries
93+
path: |
94+
dist_bin/*.tgz
95+
dist_bin/*.zip
96+
97+
- name: Debug Artifact Ids
98+
run: |
99+
echo "Artifact Id: ${{ steps.upload-artifacts.outputs.artifact-id }}"
104100
105101
functional-test:
106102
needs: package
@@ -115,111 +111,126 @@ jobs:
115111
os: [ubuntu-latest, macos-latest, windows-latest]
116112

117113
steps:
118-
- uses: actions/checkout@v3
114+
- uses: actions/checkout@v6.0.1
119115

120-
- name: Download Artifacts
121-
uses: actions/download-artifact@v4.1.8
116+
- name: Download Binaries
117+
uses: actions/download-artifact@v7.0.0
122118
with:
123-
name: dist_bin
119+
name: Binaries
120+
121+
- name: Debug List Files after Download, Windows
122+
if: runner.os == 'Windows'
123+
run: Get-ChildItem -Path dist_bin
124+
125+
- name: Debug List Files after Download
126+
if: runner.os != 'Windows'
127+
run: ls -l dist_bin
128+
129+
- name: Extract Linux Binary
130+
if: runner.os == 'Linux'
131+
run: tar xvf dist_bin/smartthings-linux-x64.tgz
132+
133+
- name: Extract MacOS Binary
134+
if: runner.os == 'macOS'
135+
run: tar xvf dist_bin/smartthings-mac-arm64.tgz
124136

125-
- name: Extract Artifacts
126-
run: tar -xvf dist_bin.tar
137+
- name: Extract Windows Binary
138+
if: runner.os == 'Windows'
139+
run: Expand-Archive -Path dist_bin\smartthings-windows-x64.zip -DestinationPath "${{ github.workspace }}"
127140

128-
- uses: actions/setup-python@v4
141+
- uses: actions/setup-python@v6.1.0
129142
with:
130-
python-version: '3.11.5'
143+
python-version: '3.14.2'
131144
cache: 'pip'
132145

133-
# make sure 'smartthings' is available to child processes
146+
- name: Debug List Files after Extraction, Windows
147+
if: runner.os == 'Windows'
148+
run: Get-ChildItem
149+
150+
- name: Debug List Files after Extraction
151+
if: runner.os != 'Windows'
152+
run: ls -l
153+
154+
# Make sure 'smartthings' binary is available to child processes (i.e. included in PATH).
134155
- name: Set Windows Path
135156
if: runner.os == 'Windows'
136-
run: Add-Content $env:GITHUB_PATH "${{ github.workspace }}\packages\cli\dist_bin\win\x64"
137-
- name: Set macOS Path
138-
if: runner.os == 'macOS'
139-
run: echo "$GITHUB_WORKSPACE/packages/cli/dist_bin/macos/x64" >> $GITHUB_PATH
140-
- name: Set Linux Path
141-
if: runner.os == 'Linux'
142-
run: echo "$GITHUB_WORKSPACE/packages/cli/dist_bin/linux/x64" >> $GITHUB_PATH
157+
run: Add-Content $env:GITHUB_PATH "${{ github.workspace }}"
158+
- name: Set Path
159+
if: runner.os != 'Windows'
160+
run: echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH
143161

144162
- name: Install Dependencies and Run Tests
163+
working-directory: functional-tests
145164
run: |
146-
python -m pip install --force-reinstall -v pip==23.3.1
165+
python -m pip install --force-reinstall -v pip==25.3
147166
pip install -r requirements.txt
148167
pytest
149-
working-directory: packages/cli/functional-tests
150168
151169
github-release:
152-
needs: [release, package]
153-
154-
if: needs.release.outputs.cli-released == 'true'
170+
needs: [npm-release, package]
155171

156172
name: Create Github Release
157173

158174
runs-on: ubuntu-latest
159175

160176
steps:
177+
- name: Debug Version
178+
run: |
179+
echo "CLI Version: ${{ needs.npm-release.outputs.cli-version }}"
180+
echo "CLI Tag: ${{ needs.npm-release.outputs.cli-tag }}"
181+
161182
- name: Checkout Repo
162-
uses: actions/checkout@v3
183+
uses: actions/checkout@v6.0.1
163184

164185
- name: Download Artifacts
165-
uses: actions/download-artifact@v4.1.8
186+
uses: actions/download-artifact@v7.0.0
166187
with:
167-
name: dist_bin
188+
name: Binaries
168189

169-
- name: Extract Artifacts
170-
run: tar -xvf dist_bin.tar
190+
- name: Debug Downloaded Artifacts
191+
run: ls -l dist_bin/smartthings-*.{tgz,zip}
171192

172193
- name: Setup Node.js
173-
uses: actions/setup-node@v3
194+
uses: actions/setup-node@v6.1.0
174195
with:
175196
node-version: 24.8.0
176197

177-
- run: npm ci
178-
179-
# hack since Github auto generated notes aren't working right now
180-
- name: Generate Github Release Notes
181-
run: node generate-release-notes.mjs ${{ needs.release.outputs.cli-version }}
182-
183198
- name: Create Github Release
184-
uses: softprops/action-gh-release@v1
199+
uses: softprops/action-gh-release@v2.5.0
185200
with:
186-
name: ${{ needs.release.outputs.cli-version }}
187-
body_path: ${{ github.workspace }}/RELEASE_NOTES.txt
188-
tag_name: ${{ needs.release.outputs.cli-tag }}
201+
name: ${{ needs.npm-release.outputs.cli-version }}
202+
tag_name: ${{ needs.npm-release.outputs.cli-tag }}
203+
generate_release_notes: true
189204
prerelease: false
190-
files: 'packages/cli/dist_bin/**/*.@(tgz|zip)'
205+
files: 'dist_bin/smartthings-*.{tgz,zip}'
191206

192207
homebrew-formula:
193-
needs: [release, github-release]
194-
195-
if: needs.release.outputs.cli-released == 'true'
208+
needs: [npm-release, github-release]
196209

197210
name: Bump Homebrew Formula
198211

199212
runs-on: macos-latest
200213

201214
steps:
202215
- name: Checkout Repo
203-
uses: actions/checkout@v3
216+
uses: actions/checkout@v6.0.1
204217

205218
- name: Configure Git Identity
206-
uses: Homebrew/actions/git-user-config@master
219+
uses: Homebrew/actions/git-user-config@main
207220
with:
208221
username: smartthingspi
209222

210223
- name: Tap Formula Repo
211224
run: brew tap smartthingscommunity/smartthings
212225

213226
- name: Bump Formula
214-
uses: Homebrew/actions/bump-formulae@master
227+
uses: Homebrew/actions/bump-packages@main
215228
with:
216229
token: ${{ secrets.HOMEBREW_COMMITTER_TOKEN }}
217230
formulae: smartthingscommunity/smartthings/smartthings
218231

219232
windows-installer:
220-
needs: [release, package, github-release]
221-
222-
if: needs.release.outputs.cli-released == 'true'
233+
needs: [npm-release, package, github-release]
223234

224235
name: Release Windows Installer
225236

@@ -228,29 +239,33 @@ jobs:
228239
runs-on: windows-2022
229240

230241
steps:
231-
- name: Print needs.release.outputs.cli-version
232-
run: Write-Output ${{ needs.release.outputs.cli-version }}
242+
- name: Print needs.npm-release.outputs.cli-version
243+
run: Write-Output ${{ needs.npm-release.outputs.cli-version }}
233244

234245
# remove any pre-release labels since WiX doesn't support them
235246
- name: Sanitize CLI Version String
236247
id: safe-semver
237-
run: echo "version=$('${{ needs.release.outputs.cli-version }}'.Split('-') | Select-Object -Index 0)" >> $env:GITHUB_OUTPUT
248+
run: echo "version=$('${{ needs.npm-release.outputs.cli-version }}'.Split('-') | Select-Object -Index 0)" >> $env:GITHUB_OUTPUT
238249

239250
- name: Print steps.safe-semver.outputs.version
240251
run: Write-Output ${{ steps.safe-semver.outputs.version }}
241252

242253
- name: Checkout Repo
243-
uses: actions/checkout@v3
254+
uses: actions/checkout@v6.0.1
244255

245256
- name: Download Artifacts
246-
uses: actions/download-artifact@v4.1.8
257+
uses: actions/download-artifact@v7.0.0
247258
with:
248-
name: dist_bin
259+
name: Binaries
260+
261+
- name: Debug List Files after Download
262+
run: Get-ChildItem -Path dist_bin
249263

250-
- name: Extract Artifacts
251-
run: tar -xvf dist_bin.tar
264+
- name: Extract Windows Binary
265+
run: Expand-Archive -Path dist_bin\smartthings-windows-x64.zip -DestinationPath "${{ github.workspace }}\wix"
252266

253-
- run: mv packages\cli\dist_bin\win\x64\smartthings.exe packages\cli\wix
267+
- name: Debug List Files after Extraction
268+
run: Get-ChildItem -Path .\wix
254269

255270
# https://github.community/t/set-path-for-wix-toolset-in-windows-runner/154708/2
256271
# https://stackoverflow.com/a/71579543
@@ -259,18 +274,18 @@ jobs:
259274

260275
- name: Compile WiX file
261276
run: candle.exe smartthings.wxs -ext WixUIExtension -arch x64
262-
working-directory: packages\cli\wix
277+
working-directory: wix
263278
env:
264279
SMARTTHINGS_SEMVER: ${{ steps.safe-semver.outputs.version }}
265280
# must be absolute path or relative to .wxs file
266281
SMARTTHINGS_BINARY_PATH: .\smartthings.exe
267282

268283
- name: Build .msi
269284
run: light.exe -out smartthings.msi smartthings.wixobj -ext WixUIExtension
270-
working-directory: packages\cli\wix
285+
working-directory: wix
271286

272287
- name: Add .msi Artifact to Github Release
273-
uses: softprops/action-gh-release@v1
288+
uses: softprops/action-gh-release@v2.5.0
274289
with:
275-
tag_name: ${{ needs.release.outputs.cli-tag }}
276-
files: packages/cli/wix/smartthings.msi
290+
tag_name: ${{ needs.npm-release.outputs.cli-tag }}
291+
files: wix/smartthings.msi

0 commit comments

Comments
 (0)