docs: add intro text to structured output match behavior table #202
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 | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| permissions: | |
| contents: write | |
| id-token: write | |
| actions: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: { fetch-depth: 0 } | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| registry-url: "https://registry.npmjs.org" | |
| - run: pnpm install --frozen-lockfile | |
| - name: Check if version is already published | |
| id: check | |
| run: | | |
| PKG_NAME=$(node -p "require('./package.json').name") | |
| PKG_VERSION=$(node -p "require('./package.json').version") | |
| echo "version=${PKG_VERSION}" >> "$GITHUB_OUTPUT" | |
| if npm view "${PKG_NAME}@${PKG_VERSION}" version 2>/dev/null; then | |
| echo "published=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "published=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Sync package.json description from README | |
| if: steps.check.outputs.published == 'false' | |
| run: | | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('package.json','utf-8')); | |
| const lines = fs.readFileSync('README.md','utf-8').split('\n'); | |
| for (const line of lines) { | |
| const t = line.trim(); | |
| if (!t || t.startsWith('#') || t.startsWith('[') || t.startsWith('http') || t.startsWith('![')) continue; | |
| pkg.description = t.replace(/[*_\`]/g,'').replace(/\s+/g,' ').trim(); | |
| break; | |
| } | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); | |
| " | |
| - name: Strip video URLs from README for npm | |
| if: steps.check.outputs.published == 'false' | |
| run: sed -i '/^https:\/\/github.com\/user-attachments\//d' README.md | |
| - name: Build and publish | |
| if: steps.check.outputs.published == 'false' | |
| run: pnpm build && npm publish --access public | |
| - name: Ensure git tag exists | |
| if: steps.check.outputs.published == 'false' | |
| run: | | |
| TAG="v${{ steps.check.outputs.version }}" | |
| if ! git rev-parse "${TAG}" >/dev/null 2>&1; then | |
| git tag "${TAG}" | |
| git push origin "${TAG}" | |
| fi | |
| - name: Update major version tag for GitHub Action | |
| if: steps.check.outputs.published == 'false' | |
| run: | | |
| MAJOR="v$(echo "${{ steps.check.outputs.version }}" | cut -d. -f1)" | |
| git tag -f "${MAJOR}" | |
| git push origin "${MAJOR}" --force | |
| - name: Create GitHub Release | |
| if: steps.check.outputs.published == 'false' | |
| run: | | |
| TAG="v${{ steps.check.outputs.version }}" | |
| gh release create "${TAG}" --generate-notes --title "${TAG}" --verify-tag --latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Trigger Docker publish workflow | |
| # GitHub's anti-recursion rule: tags pushed by GITHUB_TOKEN do NOT | |
| # trigger downstream workflows. Explicitly dispatch publish-docker.yml | |
| # so the GHCR image actually gets built on every release. | |
| if: steps.check.outputs.published == 'false' | |
| run: | | |
| TAG="v${{ steps.check.outputs.version }}" | |
| gh workflow run publish-docker.yml --ref "${TAG}" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Notify Slack | |
| if: steps.check.outputs.published == 'false' | |
| run: | | |
| if [ -z "$SLACK_WEBHOOK" ]; then echo "SLACK_WEBHOOK not set, skipping"; exit 0; fi | |
| VERSION="v${{ steps.check.outputs.version }}" | |
| curl -s -X POST "$SLACK_WEBHOOK" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"text\":\"📦 *@copilotkit/aimock ${VERSION} published*\nnpm: https://www.npmjs.com/package/@copilotkit/aimock/v/${{ steps.check.outputs.version }}\nRelease: https://github.com/${{ github.repository }}/releases/tag/${VERSION}\"}" | |
| env: | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |