name: Build, Release & Publish to NPM on: push: tags: - 'v*' workflow_dispatch: inputs: tag: description: 'Tag to build (e.g., v0.12.0)' required: true type: string source_ref: description: 'Source ref to build/publish (defaults to tag)' required: false type: string validate_only: description: 'Build and test without publishing npm packages or a GitHub Release' required: false default: false type: boolean permissions: {} concurrency: group: npm-release-${{ github.event.inputs.tag || github.ref_name }} cancel-in-progress: false jobs: cli: uses: ./.github/workflows/cli-native.yaml permissions: contents: read with: source_ref: ${{ inputs.source_ref || inputs.tag || github.ref_name }} release: name: Build, Release and Publish runs-on: ubuntu-latest needs: cli permissions: contents: write id-token: write env: RELEASE_TAG: ${{ github.event.inputs.tag || github.ref_name }} SOURCE_REF: ${{ github.event.inputs.source_ref || github.event.inputs.tag || github.ref_name }} steps: - name: Checkout uses: actions/checkout@v4 with: ref: ${{ env.SOURCE_REF }} fetch-depth: 0 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: 1.4.4 - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: '24' registry-url: 'https://registry.npmjs.org' package-manager-cache: false - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y ripgrep bubblewrap socat ffmpeg poppler-utils imagemagick libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev fd-find - name: Install dependencies run: bun install - name: Validate release source and version run: bun scripts/publish-cli-release.ts ${{ inputs.validate_only && 'validate-only' || 'validate' }} - name: Compile i18n run: bun run i18n:compile - name: Lint run: bun run lint - name: Format run: bun run format && git diff --exit-code - name: Typecheck run: bun run typecheck - name: Test run: bun run test - name: Build NPM packages run: bun run build-npm - name: Download tested CLI archives uses: actions/download-artifact@v4 with: pattern: cli-* path: out/cli-release merge-multiple: true - name: Assemble CLI release assets run: bun run build:cli --assemble - name: Generate release notes if: ${{ !inputs.validate_only }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | CHANGELOG_NOTES=$(bun run scripts/extract-changelog.ts "${{ env.RELEASE_TAG }}" 2>/dev/null || true) PR_NOTES=$(gh api "repos/${{ github.repository }}/releases/generate-notes" -f tag_name="${{ env.RELEASE_TAG }}" --jq .body 2>/dev/null || true) { if [ -n "$CHANGELOG_NOTES" ]; then echo "$CHANGELOG_NOTES" echo "" echo "---" echo "" fi if [ -n "$PR_NOTES" ]; then echo "$PR_NOTES" fi } > /tmp/release-notes.md - name: Stage draft GitHub Release and CLI assets if: ${{ !inputs.validate_only }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: bun scripts/publish-cli-release.ts stage - name: Upgrade npm for trusted publishing if: ${{ !inputs.validate_only }} run: | npm install -g npm@11.16.0 --ignore-scripts npm --version - name: Publish to NPM if: ${{ !inputs.validate_only }} run: bun run scripts/publish.ts - name: Publish completed GitHub Release if: ${{ !inputs.validate_only }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: bun scripts/publish-cli-release.ts publish