Repository navigation
chore: get full history for github release #229
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| # Re-run the GitHub release, Homebrew, and Windows installer jobs for a version | |
| # that was already published to npm (e.g. after a failed or partial release). | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Version already published to npm (e.g. 2.1.3) | |
| required: true | |
| type: string | |
| ref: | |
| description: Commit SHA the version was released from (the version packages commit) | |
| required: true | |
| type: string | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| npm-release: | |
| # don't run on forks | |
| if: ${{ github.repository_owner == 'SmartThingsCommunity' }} | |
| name: NPM Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| cli-released: ${{ github.event_name == 'workflow_dispatch' || steps.changesets.outputs.published }} | |
| cli-version: ${{ steps.cli-metadata-manual.outputs.version || steps.cli-metadata.outputs.version }} | |
| cli-tag: ${{ steps.cli-metadata-manual.outputs.tag || steps.cli-metadata.outputs.tag }} | |
| steps: | |
| - name: Checkout Repo | |
| if: github.event_name != 'workflow_dispatch' | |
| uses: actions/checkout@v6.0.1 | |
| - name: Setup Node.js | |
| if: github.event_name != 'workflow_dispatch' | |
| uses: actions/setup-node@v6.1.0 | |
| with: | |
| node-version: 24.22.1 | |
| - name: Install Dependencies | |
| if: github.event_name != 'workflow_dispatch' | |
| run: npm ci | |
| - name: Create Release Pull Request or Publish to npm | |
| if: github.event_name != 'workflow_dispatch' | |
| id: changesets | |
| uses: changesets/action@v1.5.3 | |
| with: | |
| version: npm run version | |
| publish: npm run release | |
| commit: "chore(changesets): version packages" | |
| title: "chore(changesets): version packages" | |
| createGithubReleases: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Debug Published Packages | |
| run: | | |
| echo 'Published Packages:' | |
| echo '${{ steps.changesets.outputs.publishedPackages }}' | jq . | |
| echo 'Published: ${{ steps.changesets.outputs.published }}' | |
| - name: Derive Required Metadata (manual dispatch) | |
| if: github.event_name == 'workflow_dispatch' | |
| id: cli-metadata-manual | |
| run: | | |
| echo "tag=@smartthings/cli@$INPUT_VERSION" >> $GITHUB_OUTPUT | |
| echo "version=$INPUT_VERSION" >> $GITHUB_OUTPUT | |
| env: | |
| INPUT_VERSION: ${{ inputs.version }} | |
| - name: Derive Required Metadata | |
| if: github.event_name != 'workflow_dispatch' | |
| id: cli-metadata | |
| run: | # derive latest info from changesets output | |
| published_package=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq 'map(select(.name == "@smartthings/cli")) | .[]') | |
| echo "tag=$(echo $published_package | jq --raw-output '.name + "@" + .version')" >> $GITHUB_OUTPUT | |
| echo "version=$(echo $published_package | jq --raw-output '.version')" >> $GITHUB_OUTPUT | |
| - name: Debug Version | |
| run: | | |
| echo "CLI Tag: ${{ steps.cli-metadata-manual.outputs.tag || steps.cli-metadata.outputs.tag }}" | |
| echo "CLI Version: ${{ steps.cli-metadata-manual.outputs.version || steps.cli-metadata.outputs.version }}" | |
| package: | |
| name: Package CLI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v6.0.1 | |
| with: | |
| ref: ${{ inputs.ref || github.sha }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6.1.0 | |
| with: | |
| node-version: 24.22.1 | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Package CLI | |
| run: npm run package | |
| - name: Debug List Files after Packaging | |
| run: ls -lR dist_bin | |
| - name: Upload Artifacts | |
| id: upload-artifacts | |
| uses: actions/upload-artifact@v6.0.0 | |
| with: | |
| name: Binaries | |
| path: | | |
| dist_bin/*.tgz | |
| dist_bin/*.zip | |
| - name: Debug Artifact Ids | |
| run: | | |
| echo "Artifact Id: ${{ steps.upload-artifacts.outputs.artifact-id }}" | |
| functional-test: | |
| needs: package | |
| name: Functional Tests | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v6.0.1 | |
| - name: Download Binaries | |
| uses: actions/download-artifact@v7.0.0 | |
| with: | |
| name: Binaries | |
| - name: Debug List Files after Download, Windows | |
| if: runner.os == 'Windows' | |
| run: Get-ChildItem | |
| - name: Debug List Files after Download | |
| if: runner.os != 'Windows' | |
| run: ls -l | |
| - name: Extract Linux Binary | |
| if: runner.os == 'Linux' | |
| run: tar xvf smartthings-linux-x64.tgz | |
| - name: Extract MacOS Binary | |
| if: runner.os == 'macOS' | |
| run: tar xvf smartthings-mac-arm64.tgz | |
| - name: Extract Windows Binary | |
| if: runner.os == 'Windows' | |
| run: Expand-Archive -Path smartthings-windows-x64.zip -DestinationPath "${{ github.workspace }}" | |
| - uses: actions/setup-python@v6.1.0 | |
| with: | |
| python-version: '3.14.2' | |
| cache: 'pip' | |
| - name: Debug List Files after Extraction, Windows | |
| if: runner.os == 'Windows' | |
| run: Get-ChildItem | |
| - name: Debug List Files after Extraction | |
| if: runner.os != 'Windows' | |
| run: ls -l | |
| # Make sure 'smartthings' binary is available to child processes (i.e. included in PATH). | |
| - name: Set Windows Path | |
| if: runner.os == 'Windows' | |
| run: Add-Content $env:GITHUB_PATH "${{ github.workspace }}" | |
| - name: Set Path | |
| if: runner.os != 'Windows' | |
| run: echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH | |
| - name: Install Dependencies and Run Tests | |
| working-directory: functional-tests | |
| run: | | |
| python -m pip install --force-reinstall -v pip==25.3 | |
| pip install -r requirements.txt | |
| pytest | |
| github-release: | |
| needs: [npm-release, package] | |
| if: needs.npm-release.outputs.cli-released == 'true' | |
| name: Create Github Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Debug Version | |
| run: | | |
| echo "CLI Version: ${{ needs.npm-release.outputs.cli-version }}" | |
| echo "CLI Tag: ${{ needs.npm-release.outputs.cli-tag }}" | |
| - name: Checkout Repo | |
| uses: actions/checkout@v6.0.1 | |
| with: | |
| ref: ${{ inputs.ref || github.sha }} | |
| # Full history is needed to push the release tag; from a shallow clone git sends the | |
| # whole tree and GitHub rejects it as creating .github/workflows files. | |
| fetch-depth: 0 | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v7.0.0 | |
| with: | |
| name: Binaries | |
| - name: Debug Downloaded Artifacts | |
| run: ls -l smartthings-*.{tgz,zip} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6.1.0 | |
| with: | |
| node-version: 24.22.1 | |
| # On a manual dispatch the tag was never pushed (changeset publish pushes it in the normal | |
| # flow), so push it here rather than having the releases API create it. | |
| - name: Push Release Tag | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| if git ls-remote --exit-code --tags origin "refs/tags/$CLI_TAG"; then | |
| echo "Tag $CLI_TAG already exists" | |
| else | |
| git tag "$CLI_TAG" "$CLI_REF" | |
| git push origin "refs/tags/$CLI_TAG" | |
| fi | |
| env: | |
| CLI_TAG: ${{ needs.npm-release.outputs.cli-tag }} | |
| CLI_REF: ${{ inputs.ref }} | |
| - name: Create Github Release | |
| uses: softprops/action-gh-release@v2.5.0 | |
| with: | |
| name: ${{ needs.npm-release.outputs.cli-version }} | |
| tag_name: ${{ needs.npm-release.outputs.cli-tag }} | |
| target_commitish: ${{ inputs.ref || github.sha }} | |
| generate_release_notes: true | |
| prerelease: false | |
| files: 'smartthings-*.{tgz,zip}' | |
| homebrew-formula: | |
| needs: [npm-release, github-release] | |
| if: needs.npm-release.outputs.cli-released == 'true' | |
| name: Bump Homebrew Formula | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v6.0.1 | |
| - name: Configure Git Identity | |
| uses: Homebrew/actions/git-user-config@main | |
| with: | |
| username: smartthingspi | |
| - name: Tap Formula Repo | |
| run: brew tap smartthingscommunity/smartthings | |
| - name: Bump Formula | |
| uses: Homebrew/actions/bump-packages@main | |
| with: | |
| token: ${{ secrets.HOMEBREW_COMMITTER_TOKEN }} | |
| formulae: smartthingscommunity/smartthings/smartthings | |
| windows-installer: | |
| needs: [npm-release, package, github-release] | |
| if: needs.npm-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: | |
| - name: Print needs.npm-release.outputs.cli-version | |
| run: Write-Output ${{ needs.npm-release.outputs.cli-version }} | |
| # remove any pre-release labels since WiX doesn't support them | |
| - name: Sanitize CLI Version String | |
| id: safe-semver | |
| run: echo "version=$('${{ needs.npm-release.outputs.cli-version }}'.Split('-') | Select-Object -Index 0)" >> $env:GITHUB_OUTPUT | |
| - name: Print steps.safe-semver.outputs.version | |
| run: Write-Output ${{ steps.safe-semver.outputs.version }} | |
| - name: Checkout Repo | |
| uses: actions/checkout@v6.0.1 | |
| with: | |
| ref: ${{ inputs.ref || github.sha }} | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v7.0.0 | |
| with: | |
| name: Binaries | |
| - name: Debug List Files after Download | |
| run: Get-ChildItem | |
| - name: Extract Windows Binary | |
| run: Expand-Archive -Path smartthings-windows-x64.zip -DestinationPath "${{ github.workspace }}\wix" | |
| - name: Debug List Files after Extraction | |
| run: Get-ChildItem -Path .\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 -arch x64 | |
| working-directory: 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: wix | |
| - name: Add .msi Artifact to Github Release | |
| uses: softprops/action-gh-release@v2.5.0 | |
| with: | |
| tag_name: ${{ needs.npm-release.outputs.cli-tag }} | |
| files: wix/smartthings.msi |