Repository navigation
chore(main): release ts-cli 1.4.1 #103
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: Chocolatey | |
| on: | |
| pull_request: | |
| paths: | |
| - ".github/workflows/chocolatey.yml" | |
| - "package.json" | |
| - "packaging/chocolatey/**" | |
| - "packages/ts/cli/**" | |
| - "scripts/chocolatey-asset-tools.mjs" | |
| - "scripts/build-chocolatey-asset.mjs" | |
| - "scripts/check-cli-tarballs.mjs" | |
| - "scripts/cli-tarball-tools.mjs" | |
| - "scripts/pack-cli-tarballs.mjs" | |
| - "scripts/prepare-chocolatey-packages.mjs" | |
| - "scripts/serve-static.mjs" | |
| - "scripts/test-chocolatey-asset-tools.mjs" | |
| - "scripts/test-chocolatey-package-files.mjs" | |
| - "scripts/test-chocolatey-workflow-order.mjs" | |
| - "scripts/test-cli-tarball-tools.mjs" | |
| - "scripts/test-windows-command-shims.mjs" | |
| - "scripts/windows-command-shims.mjs" | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "CLI version to package. Defaults to packages/ts/cli/package.json." | |
| required: false | |
| type: string | |
| push: | |
| description: "Push packages to Chocolatey. Requires CHOCOLATEY_API_KEY." | |
| default: false | |
| required: true | |
| type: boolean | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: chocolatey-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| package: | |
| if: ${{ github.event_name != 'release' || startsWith(github.event.release.tag_name, 'ts-cli-v') }} | |
| runs-on: windows-latest | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| HAS_CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY != '' }} | |
| SENDMUX_CHOCOLATEY_VERSION: ${{ inputs.version }} | |
| steps: | |
| - name: Check out SDK | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }} | |
| - name: Check out OpenAPI snapshots | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| repository: Sendmux/docs | |
| path: sendmux-docs | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 | |
| with: | |
| version: 10.22.0 | |
| - name: Set up Node | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Verify workflow helper scripts | |
| run: | | |
| node --check scripts/serve-static.mjs | |
| pnpm test:windows-command-shims | |
| pnpm test:chocolatey-asset-tools | |
| pnpm test:chocolatey-package-files | |
| pnpm test:chocolatey-workflow-order | |
| pnpm test:cli-tarball-tools | |
| - name: Install Windows packaging tools | |
| shell: powershell | |
| run: choco install 7zip -y --no-progress | |
| - name: Build TypeScript CLI | |
| shell: bash | |
| run: | | |
| pnpm normalize:codegen | |
| pnpm generate:ts | |
| pnpm generate:cli | |
| pnpm -r \ | |
| --filter @sendmux/core \ | |
| --filter @sendmux/sending \ | |
| --filter @sendmux/mailbox \ | |
| --filter @sendmux/management \ | |
| --filter @sendmux/sdk \ | |
| --filter @sendmux/cli \ | |
| build | |
| pnpm check:cli | |
| - name: Build Windows CLI archive | |
| shell: bash | |
| run: | | |
| SENDMUX_CLI_PACK_TARGETS=win32-x64 pnpm --filter @sendmux/cli pack:tarballs | |
| pnpm check:cli-tarballs | |
| node scripts/build-chocolatey-asset.mjs | |
| - name: Generate Chocolatey packages | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| asset="$(find packages/ts/cli/dist -maxdepth 1 -type f -name "sendmux-v*-win32-x64.zip" | sort | tail -n 1)" | |
| if [ -z "$asset" ]; then | |
| echo "No local Windows ZIP asset found for PR Chocolatey install test." | |
| exit 1 | |
| fi | |
| local_url="http://127.0.0.1:8765/$(basename "$asset")" | |
| echo "SENDMUX_CHOCOLATEY_DOWNLOAD_URL=$local_url" >> "$GITHUB_ENV" | |
| export SENDMUX_CHOCOLATEY_DOWNLOAD_URL="$local_url" | |
| fi | |
| node scripts/prepare-chocolatey-packages.mjs | |
| - name: Pack Chocolatey packages | |
| shell: powershell | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| New-Item -ItemType Directory -Force -Path .tmp/chocolatey/pkg | Out-Null | |
| choco pack .tmp/chocolatey/sendmux.portable/sendmux.portable.nuspec --output-directory .tmp/chocolatey/pkg | |
| choco pack .tmp/chocolatey/sendmux/sendmux.nuspec --output-directory .tmp/chocolatey/pkg | |
| - name: Attach CLI ZIP assets to release | |
| if: ${{ github.event_name == 'release' || inputs.push == true }} | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| tag="$RELEASE_TAG" | |
| else | |
| version="${SENDMUX_CHOCOLATEY_VERSION:-$(node -p "require('./packages/ts/cli/package.json').version")}" | |
| tag="ts-cli-v${version}" | |
| fi | |
| gh release view "$tag" >/dev/null | |
| mapfile -t assets < <(find packages/ts/cli/dist -type f \( -name "sendmux-v*-win32-x64.zip" -o -name "sendmux-v*-win32-x64.zip.sha256" \) -print) | |
| if [ "${#assets[@]}" -eq 0 ]; then | |
| echo "No Chocolatey ZIP assets found to upload." | |
| exit 1 | |
| fi | |
| gh release upload "$tag" "${assets[@]}" --clobber | |
| - name: Test Chocolatey packages | |
| shell: powershell | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| $source = Resolve-Path .tmp/chocolatey/pkg | |
| $server = $null | |
| if ('${{ github.event_name }}' -eq 'pull_request') { | |
| $server = Start-Process -FilePath node -ArgumentList @('scripts/serve-static.mjs', 'packages/ts/cli/dist', '8765') -PassThru | |
| Start-Sleep -Seconds 2 | |
| } | |
| try { | |
| choco install sendmux.portable --source "$source" -y --no-progress | |
| sendmux --help | |
| choco uninstall sendmux.portable -y --no-progress | |
| choco install sendmux --source "$source" -y --no-progress | |
| sendmux --help | |
| choco uninstall sendmux -y --no-progress | |
| choco uninstall sendmux.portable -y --no-progress | |
| } finally { | |
| if ($server) { | |
| Stop-Process -Id $server.Id -Force -ErrorAction SilentlyContinue | |
| } | |
| } | |
| - name: Upload workflow artefacts | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: sendmux-chocolatey | |
| path: | | |
| packages/ts/cli/dist/sendmux-v*-win32-x64.zip | |
| packages/ts/cli/dist/sendmux-v*-win32-x64.zip.sha256 | |
| .tmp/chocolatey/pkg/*.nupkg | |
| retention-days: 30 | |
| - name: Attach Chocolatey package artefacts to release | |
| if: ${{ github.event_name == 'release' || inputs.push == true }} | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| tag="$RELEASE_TAG" | |
| else | |
| version="${SENDMUX_CHOCOLATEY_VERSION:-$(node -p "require('./packages/ts/cli/package.json').version")}" | |
| tag="ts-cli-v${version}" | |
| fi | |
| gh release view "$tag" >/dev/null | |
| mapfile -t assets < <(find .tmp/chocolatey/pkg -type f -name "*.nupkg" -print) | |
| if [ "${#assets[@]}" -eq 0 ]; then | |
| echo "No Chocolatey package assets found to upload." | |
| exit 1 | |
| fi | |
| gh release upload "$tag" "${assets[@]}" --clobber | |
| - name: Push to Chocolatey | |
| if: ${{ (github.event_name == 'release' || inputs.push == true) && env.HAS_CHOCOLATEY_API_KEY == 'true' }} | |
| env: | |
| CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }} | |
| shell: powershell | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| $version = $env:SENDMUX_CHOCOLATEY_VERSION | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| $version = (Get-Content packages/ts/cli/package.json | ConvertFrom-Json).version | |
| } | |
| $packages = @( | |
| ".tmp/chocolatey/pkg/sendmux.portable.$version.nupkg", | |
| ".tmp/chocolatey/pkg/sendmux.$version.nupkg" | |
| ) | |
| choco apikey --key "$env:CHOCOLATEY_API_KEY" --source https://push.chocolatey.org/ | |
| foreach ($package in $packages) { | |
| if (-not (Test-Path $package)) { | |
| throw "Expected Chocolatey package was not created: $package" | |
| } | |
| choco push $package --source https://push.chocolatey.org/ --api-key "$env:CHOCOLATEY_API_KEY" --no-progress | |
| } | |
| - name: Skip Chocolatey push notice | |
| if: ${{ (github.event_name == 'release' || inputs.push == true) && env.HAS_CHOCOLATEY_API_KEY != 'true' }} | |
| shell: powershell | |
| run: Write-Host 'Skipping Chocolatey push because CHOCOLATEY_API_KEY is not configured.' |