diff --git a/.changeset/selfish-pears-joke.md b/.changeset/selfish-pears-joke.md new file mode 100644 index 000000000..c0ab8b17d --- /dev/null +++ b/.changeset/selfish-pears-joke.md @@ -0,0 +1,5 @@ +--- +"@smartthings/cli": patch +--- + +Add Windows installer build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 19dfe888e..26e0e0b84 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -16,6 +16,11 @@ jobs: runs-on: ubuntu-latest + outputs: + cli-released: ${{ steps.cli-release.outputs.published }} + cli-version: ${{ steps.cli-metadata.outputs.version }} + cli-tag: ${{ steps.cli-metadata.outputs.tag }} + steps: - name: Checkout Repo uses: actions/checkout@v3 @@ -89,3 +94,59 @@ jobs: Created by https://github.com/mislav/bump-homebrew-formula-action env: COMMITTER_TOKEN: ${{ secrets.HOMEBREW_COMMITTER_TOKEN }} + + - name: Upload .exe Artifact + if: steps.cli-package.outcome == 'success' + uses: actions/upload-artifact@v3 + with: + name: windows-exe + path: packages/cli/dist_bin/win/smartthings.exe + + windows-installer: + needs: release + + if: needs.release.outputs.cli-released == 'true' + + name: Release Windows Installer + + # ensure WiX Toolset is installed on image before updating runner + # ex: https://github.com/actions/virtual-environments/blob/b87bdfb146bdd41a98f33fc9572a961e9a60e9dd/images/win/Windows2022-Readme.md + runs-on: windows-2022 + + steps: + # remove any pre-release labels since WiX doesn't support them + - name: Sanitize CLI Version String + id: safe-semver + run: echo "::set-output name=version::$('${{ needs.release.outputs.cli-version }}'.Split('-') | Select-Object -Index 0)" + + - name: Checkout Repo + uses: actions/checkout@v3 + + - name: Download .exe Artifact + uses: actions/download-artifact@v3 + with: + name: windows-exe + path: packages\cli\wix + + # https://github.community/t/set-path-for-wix-toolset-in-windows-runner/154708/2 + # https://stackoverflow.com/a/71579543 + - name: Add WiX Toolset to Path + run: Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\WiX Toolset v3.11\bin" + + - name: Compile WiX file + run: candle.exe smartthings.wxs -ext WixUIExtension + working-directory: packages\cli\wix + env: + SMARTTHINGS_SEMVER: ${{ steps.safe-semver.outputs.version }} + # must be absolute path or relative to .wxs file + SMARTTHINGS_BINARY_PATH: .\smartthings.exe + + - name: Build .msi + run: light.exe -out smartthings.msi smartthings.wixobj -ext WixUIExtension + working-directory: packages\cli\wix + + - name: Add .msi Artifact to Github Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ needs.release.outputs.cli-tag }} + files: packages\cli\wix\smartthings.msi diff --git a/packages/cli/wix/License.rtf b/packages/cli/wix/License.rtf new file mode 100644 index 000000000..73d34bd07 Binary files /dev/null and b/packages/cli/wix/License.rtf differ diff --git a/packages/cli/wix/README.md b/packages/cli/wix/README.md new file mode 100644 index 000000000..01e56641c --- /dev/null +++ b/packages/cli/wix/README.md @@ -0,0 +1,39 @@ +## SmartThings CLI Windows Installer + +### WiX Toolset + +We use a "simple" [WiX Toolset](https://wixtoolset.org/) v3 configuration. The majority of the .wxs file was written with these examples as reference . Comments try to point to references for info that is not immediately intuitive. + +### smartthings.wxs + +This is the WiX source file that needs to be "compiled" to a `.wixobj` and then finally linked into an `.msi`. The steps and expectations for this process are below. + +#### Environment Variables + +The WiX file includes some build variables that can be passed by setting specific env vars in the shell that runs the tasks. + +1. `SMARTTHINGS_SEMVER`: Sets the version that shows in Windows Programs and Features. This should not include the fourth section of the Windows format, as we ignore this and leave 0. Pre-release labels are not supported. + +1. `SMARTTHINGS_BINARY_PATH`: Specifies the location of the executable that we want to install. This will need to be accessible during the linking step below, so needs to be relative path to the `.wxs` file or an absolute system path. + +#### License + +The End User License Agreement step of the installer requires an `.rtf` file specified in the WiX markup. The current setup assumes this is in the same directory as the `.wxs` file. + +#### Usage + +The following assumes running under Windows OS with the WiX Toolset installed and on the system Path. GitHub hosted runners have the v3 tools installed by default as of writing. These tasks are ran in the same directory as required files. + +> :warning: Ensure the required Environment Variables are set. + +Compile WiX Source + +```console +candle.exe smartthings.wxs -ext WixUIExtension +``` + +Build .msi Installer + +```console +light.exe -out smartthings.msi smartthings.wixobj -ext WixUIExtension +``` diff --git a/packages/cli/wix/smartthings.wxs b/packages/cli/wix/smartthings.wxs new file mode 100644 index 000000000..c32daaab7 --- /dev/null +++ b/packages/cli/wix/smartthings.wxs @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/cli/zip-binaries.sh b/packages/cli/zip-binaries.sh index ac39e1cdb..ea9ad5323 100755 --- a/packages/cli/zip-binaries.sh +++ b/packages/cli/zip-binaries.sh @@ -13,7 +13,8 @@ function zip_binary() { tar -czf assets/smartthings-$os.tar.gz "smartthings$ext" fi zip assets/smartthings-$os.zip "smartthings$ext" - mv "smartthings$ext" "smartthings-$os$ext" + mkdir -p $os + mv "smartthings$ext" "$os" ) }