fix(release): publish CLI under @pushpalsdev scope #2
Workflow file for this run
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: Release CLI | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| jobs: | |
| meta: | |
| name: Resolve tag metadata | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.resolve.outputs.tag }} | |
| version: ${{ steps.resolve.outputs.version }} | |
| prerelease: ${{ steps.resolve.outputs.prerelease }} | |
| steps: | |
| - id: resolve | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| tag="${GITHUB_REF_NAME}" | |
| if [[ ! "$tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?)$ ]]; then | |
| echo "Tag '$tag' is not a valid semver release tag (expected vX.Y.Z)." >&2 | |
| exit 1 | |
| fi | |
| version="${BASH_REMATCH[1]}" | |
| prerelease="false" | |
| if [[ "$version" == *"-"* ]]; then | |
| prerelease="true" | |
| fi | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT" | |
| publish_npm: | |
| name: Publish @pushpalsdev/cli to npm | |
| runs-on: ubuntu-latest | |
| needs: meta | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: "1.3.9" | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Set CLI package version from tag | |
| shell: bash | |
| run: | | |
| node -e "const fs=require('fs');const path='packages/cli/package.json';const pkg=JSON.parse(fs.readFileSync(path,'utf8'));pkg.version='${{ needs.meta.outputs.version }}';fs.writeFileSync(path,JSON.stringify(pkg,null,2)+'\n');" | |
| - name: Build CLI package payload | |
| run: bun run --cwd packages/cli build | |
| - name: Publish to npm | |
| working-directory: packages/cli | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| if [ -z "${NODE_AUTH_TOKEN:-}" ]; then | |
| echo "NPM_TOKEN secret is required to publish @pushpalsdev/cli." >&2 | |
| exit 1 | |
| fi | |
| npm publish --access public --provenance | |
| build_binaries: | |
| name: Build standalone CLI binaries | |
| needs: meta | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| output_name: pushpals-linux-x64 | |
| - os: windows-latest | |
| output_name: pushpals-windows-x64.exe | |
| - os: macos-13 | |
| output_name: pushpals-macos-x64 | |
| - os: macos-14 | |
| output_name: pushpals-macos-arm64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: "1.3.9" | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build standalone binary | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Path dist -Force | Out-Null | |
| $output = Join-Path "dist" "${{ matrix.output_name }}" | |
| bun build scripts/pushpals-cli.ts --compile --outfile $output | |
| if ("${{ runner.os }}" -ne "Windows") { | |
| chmod +x $output | |
| } | |
| - name: Upload binary artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.output_name }} | |
| path: dist/${{ matrix.output_name }} | |
| publish_release: | |
| name: Publish GitHub release assets | |
| runs-on: ubuntu-latest | |
| needs: | |
| - meta | |
| - publish_npm | |
| - build_binaries | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate checksums | |
| shell: bash | |
| run: | | |
| cd dist | |
| sha256sum pushpals-* > SHA256SUMS.txt | |
| - name: Resolve release log file | |
| id: release_log | |
| shell: bash | |
| run: | | |
| path="release_log.md" | |
| if [[ -f "$path" ]]; then | |
| echo "found=true" >> "$GITHUB_OUTPUT" | |
| echo "path=$path" >> "$GITHUB_OUTPUT" | |
| echo "Using release log at $path" | |
| else | |
| echo "found=false" >> "$GITHUB_OUTPUT" | |
| echo "path=" >> "$GITHUB_OUTPUT" | |
| echo "No release log found at $path; using default release body." | |
| fi | |
| - name: Create GitHub release (release log) | |
| if: steps.release_log.outputs.found == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.meta.outputs.tag }} | |
| name: PushPals CLI ${{ needs.meta.outputs.tag }} | |
| prerelease: ${{ needs.meta.outputs.prerelease == 'true' }} | |
| generate_release_notes: true | |
| body_path: ${{ steps.release_log.outputs.path }} | |
| files: | | |
| dist/pushpals-* | |
| dist/SHA256SUMS.txt | |
| - name: Create GitHub release (default body) | |
| if: steps.release_log.outputs.found != 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.meta.outputs.tag }} | |
| name: PushPals CLI ${{ needs.meta.outputs.tag }} | |
| prerelease: ${{ needs.meta.outputs.prerelease == 'true' }} | |
| generate_release_notes: true | |
| body: | | |
| ## Install | |
| - npm: `npm i -g @pushpalsdev/cli` | |
| - bun: `bun install -g @pushpalsdev/cli` | |
| ## Direct downloads | |
| Use the platform binaries attached to this release when npm/Bun is unavailable. | |
| files: | | |
| dist/pushpals-* | |
| dist/SHA256SUMS.txt |