From aa1439e62d4a5c84237f58a0e35eff9659a946ae Mon Sep 17 00:00:00 2001 From: John Undersander <19363370+john-u@users.noreply.github.com> Date: Wed, 6 Jul 2022 14:11:44 -0500 Subject: [PATCH] ci: build Windows installer --- .changeset/selfish-pears-joke.md | 5 +++ .github/workflows/release.yaml | 61 +++++++++++++++++++++++++++++ packages/cli/wix/License.rtf | Bin 0 -> 911 bytes packages/cli/wix/README.md | 39 +++++++++++++++++++ packages/cli/wix/smartthings.wxs | 64 +++++++++++++++++++++++++++++++ packages/cli/zip-binaries.sh | 3 +- 6 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 .changeset/selfish-pears-joke.md create mode 100644 packages/cli/wix/License.rtf create mode 100644 packages/cli/wix/README.md create mode 100644 packages/cli/wix/smartthings.wxs 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 0000000000000000000000000000000000000000..73d34bd0762ce64d9e14b22cff45486c80cbbd34 GIT binary patch literal 911 zcma)5L2lbH5bQZX{;=?=4P04LlLDzvZsHXB2nS{r>!{XTm6B0~DsrqKsK(5p~Qqs>Sr`YI?w2unIL=?u~^Ni5g`ZLlQ@E zlw8M`$(}tEc0WnWOV)}6&d*rGtz?!yeU6z^>E&>5Tji4jAD5;~aa~;pF3rwTReMO| zG=*ZztzXxqD>sHri)fhhI_>;yK?1cy39XiB!Pf}0h6gfm?2O?DT1Q4h8pZH_0E~{U z(T6GQObc7S18qFC4#NO)P?AEx7lDlj(lE%Uh--n+k*^OQIgW_n={Ue_JP%kN(9I4^ zd5Qw=PdP(4eK3Jg$(~)XQc2Rz_jga<=c`4Q-$U(v^JOyWx-Q~}Z6afUf+ zOy@%?BzQB3)LHVuqA@sA`i@%!NzPl^wEiD=j>18Z`4kZR;TlG>0sPjH{*w`0KIO^5)#G. 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" ) }