refactor(api): remove hosted personal agent #83
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
| # Publish @indexnetwork/cli prereleases from dev and stable releases from main. | |
| # Builds native binaries for all platforms before publishing. | |
| # Skips if the version in package.json is already on npm. | |
| # | |
| # Requires: org-level NPM_TOKEN secret. | |
| name: Publish | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| - main | |
| concurrency: | |
| group: publish-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| # ── Check version ───────────────────────────────────────────────────── | |
| check: | |
| runs-on: ubuntu-latest | |
| name: Check if version needs publishing | |
| outputs: | |
| skip: ${{ steps.check.outputs.skip }} | |
| version: ${{ steps.check.outputs.version }} | |
| tag: ${{ steps.meta.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Determine publish version and tag | |
| id: meta | |
| run: | | |
| BASE_VERSION=$(node -p "require('./package.json').version") | |
| if [ "${GITHUB_REF_NAME}" = "dev" ]; then | |
| PUBLISH_VERSION="${BASE_VERSION}-rc.${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}" | |
| NPM_TAG="rc" | |
| else | |
| PUBLISH_VERSION="${BASE_VERSION}" | |
| NPM_TAG="latest" | |
| fi | |
| echo "version=${PUBLISH_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag=${NPM_TAG}" >> "$GITHUB_OUTPUT" | |
| - name: Check if version already published | |
| id: check | |
| run: | | |
| NAME=$(node -p "require('./package.json').name") | |
| VERSION="${{ steps.meta.outputs.version }}" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| if npm view "${NAME}@${VERSION}" version &>/dev/null; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "Version ${VERSION} already published — skipping." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # ── Build platform binaries ─────────────────────────────────────────── | |
| build: | |
| needs: check | |
| if: needs.check.outputs.skip == 'false' | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: bun-linux-x64 | |
| npm-dir: linux-x64 | |
| binary-name: index-linux-x64 | |
| - os: ubuntu-24.04-arm | |
| target: bun-linux-arm64 | |
| npm-dir: linux-arm64 | |
| binary-name: index-linux-arm64 | |
| - os: macos-latest | |
| target: bun-darwin-x64 | |
| npm-dir: darwin-x64 | |
| binary-name: index-darwin-x64 | |
| - os: macos-latest | |
| target: bun-darwin-arm64 | |
| npm-dir: darwin-arm64 | |
| binary-name: index-darwin-arm64 | |
| runs-on: ${{ matrix.os }} | |
| name: Build ${{ matrix.npm-dir }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Compile binary | |
| run: | | |
| mkdir -p dist | |
| bun build src/main.ts --compile --target=${{ matrix.target }} --outfile dist/${{ matrix.binary-name }} | |
| - name: Upload binary artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.npm-dir }} | |
| path: dist/${{ matrix.binary-name }} | |
| retention-days: 1 | |
| # ── Publish all packages to npm ─────────────────────────────────────── | |
| publish: | |
| needs: [check, build] | |
| if: needs.check.outputs.skip == 'false' | |
| runs-on: ubuntu-latest | |
| name: Publish to npm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Build JS fallback bundle | |
| run: | | |
| mkdir -p dist | |
| bun build src/main.ts --outdir dist --target node --format esm --entry-naming index.js | |
| - name: Download all platform binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Place binaries into platform packages | |
| run: | | |
| for dir in linux-x64 linux-arm64 darwin-x64 darwin-arm64; do | |
| mkdir -p "npm/$dir/bin" | |
| cp "artifacts/$dir/index-$dir" "npm/$dir/bin/index" | |
| chmod +x "npm/$dir/bin/index" | |
| done | |
| - name: Rewrite package versions for publish | |
| run: | | |
| VERSION="${{ needs.check.outputs.version }}" | |
| node -e "const fs=require('fs'); const path='package.json'; const pkg=JSON.parse(fs.readFileSync(path,'utf8')); pkg.version=process.argv[1]; Object.keys(pkg.optionalDependencies||{}).forEach(k=>pkg.optionalDependencies[k]=process.argv[1]); fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n');" "$VERSION" | |
| for dir in linux-x64 linux-arm64 darwin-x64 darwin-arm64; do | |
| node -e "const fs=require('fs'); const path='npm/' + process.argv[1] + '/package.json'; const pkg=JSON.parse(fs.readFileSync(path,'utf8')); pkg.version=process.argv[2]; fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n');" "$dir" "$VERSION" | |
| done | |
| - name: Publish platform packages | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| for dir in linux-x64 linux-arm64 darwin-x64 darwin-arm64; do | |
| echo "Publishing @indexnetwork/cli-$dir..." | |
| npm publish --access public --tag "${{ needs.check.outputs.tag }}" "./npm/$dir" | |
| done | |
| - name: Publish main package | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access public --tag "${{ needs.check.outputs.tag }}" |