|
| 1 | +name: Publish CLI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Version to publish (leave empty to use package.json version)" |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + dry-run: |
| 11 | + description: "Dry run (skip actual publish)" |
| 12 | + required: false |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + id-token: write # required for npm provenance |
| 19 | + |
| 20 | +defaults: |
| 21 | + run: |
| 22 | + working-directory: . |
| 23 | + |
| 24 | +jobs: |
| 25 | + publish-cli: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: "22" |
| 35 | + registry-url: "https://registry.npmjs.org" |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: npm ci |
| 39 | + |
| 40 | + - name: Build SDK (dependency) |
| 41 | + run: npm run build --workspace=packages/sdk |
| 42 | + |
| 43 | + - name: Build CLI |
| 44 | + run: npm run build --workspace=packages/cli |
| 45 | + |
| 46 | + - name: Run tests |
| 47 | + run: npm test --workspace=packages/cli |
| 48 | + |
| 49 | + - name: Set version (if provided) |
| 50 | + if: ${{ inputs.version != '' }} |
| 51 | + working-directory: packages/cli |
| 52 | + run: npm version "${{ inputs.version }}" --no-git-tag-version |
| 53 | + |
| 54 | + - name: Read version |
| 55 | + id: version |
| 56 | + working-directory: packages/cli |
| 57 | + run: echo "version=$(node -p 'require(\"./package.json\").version')" >> "$GITHUB_OUTPUT" |
| 58 | + |
| 59 | + - name: Publish to npm |
| 60 | + if: ${{ !inputs.dry-run }} |
| 61 | + working-directory: packages/cli |
| 62 | + run: npm publish --provenance --access public |
| 63 | + env: |
| 64 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 65 | + |
| 66 | + - name: Publish (dry run) |
| 67 | + if: ${{ inputs.dry-run }} |
| 68 | + working-directory: packages/cli |
| 69 | + run: npm publish --dry-run |
| 70 | + env: |
| 71 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 72 | + |
| 73 | + - name: Summary |
| 74 | + run: | |
| 75 | + echo "## 📦 @pixelml/agenticflow-cli@${{ steps.version.outputs.version }}" >> "$GITHUB_STEP_SUMMARY" |
| 76 | + if [ "${{ inputs.dry-run }}" = "true" ]; then |
| 77 | + echo "🏃 **Dry run** — nothing was published" >> "$GITHUB_STEP_SUMMARY" |
| 78 | + else |
| 79 | + echo "✅ Published to [npm](https://www.npmjs.com/package/@pixelml/agenticflow-cli/v/${{ steps.version.outputs.version }})" >> "$GITHUB_STEP_SUMMARY" |
| 80 | + fi |
0 commit comments