refactor: trim patch-fsbrowse.js to exactly 200L by removing code com… #570
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: Publish and Release | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| concurrency: | |
| group: publish-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish: | |
| if: "!contains(github.event.head_commit.author.name, 'github-actions')" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| published: ${{ steps.publish.outputs.published }} | |
| final-sha: ${{ steps.final-sha.outputs.sha }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| - name: Install dependencies | |
| run: npm install --ignore-scripts | |
| - name: Determine version to publish | |
| id: version | |
| run: | | |
| set -e | |
| CURRENT_VERSION=$(jq -r '.version' package.json) | |
| PKG_NAME=$(jq -r '.name' package.json) | |
| # Query published version from npm registry | |
| PUBLISHED_VERSION=$(npm view "$PKG_NAME" version 2>/dev/null || echo "0.0.0") | |
| echo "Current version in package.json: $CURRENT_VERSION" | |
| echo "Published version on npm: $PUBLISHED_VERSION" | |
| # Determine base version - use whichever is newer | |
| if [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then | |
| BASE_VERSION="$PUBLISHED_VERSION" | |
| NEEDS_BUMP=true | |
| else | |
| # Sort versions and use the higher one as base | |
| BASE_VERSION=$(printf '%s\n' "$CURRENT_VERSION" "$PUBLISHED_VERSION" | sort -V | tail -n1) | |
| if [ "$BASE_VERSION" != "$CURRENT_VERSION" ]; then | |
| NEEDS_BUMP=true | |
| else | |
| NEEDS_BUMP=false | |
| fi | |
| fi | |
| if [ "$NEEDS_BUMP" = "true" ]; then | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION" | |
| NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" | |
| # Update package.json | |
| jq --arg v "$NEW_VERSION" '.version = $v' package.json > package.json.tmp | |
| mv package.json.tmp package.json | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "bumped=true" >> $GITHUB_OUTPUT | |
| echo "Bumped version: $BASE_VERSION -> $NEW_VERSION" | |
| else | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "bumped=false" >> $GITHUB_OUTPUT | |
| echo "Version unchanged: $CURRENT_VERSION" | |
| fi | |
| - name: Commit version bump if needed | |
| if: steps.version.outputs.bumped == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add package.json | |
| git commit -m "chore: bump version to ${{ steps.version.outputs.version }} [skip ci]" | |
| branch_name="${GITHUB_REF#refs/heads/}" | |
| for i in 1 2 3; do | |
| git fetch origin "$branch_name" | |
| if git diff --quiet "origin/$branch_name"..HEAD; then | |
| echo "Commits already pushed, skipping push" | |
| break | |
| fi | |
| if git push origin HEAD:$branch_name; then | |
| echo "Successfully pushed version bump" | |
| break | |
| else | |
| echo "Push attempt $i failed, retrying..." | |
| sleep 2 | |
| fi | |
| done | |
| - name: Get final commit SHA | |
| id: final-sha | |
| run: | | |
| branch_name="${GITHUB_REF#refs/heads/}" | |
| git fetch origin "$branch_name" | |
| echo "sha=$(git rev-parse "origin/$branch_name")" >> $GITHUB_OUTPUT | |
| - name: Publish to npm | |
| id: publish | |
| run: | | |
| set -e | |
| # Verify and configure npm authentication | |
| if [ -z "$NODE_AUTH_TOKEN" ]; then | |
| echo "::error::NPM_TOKEN secret is missing. Please add NPM_TOKEN to repository secrets." | |
| exit 1 | |
| fi | |
| echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > ~/.npmrc | |
| chmod 0600 ~/.npmrc | |
| npm whoami | |
| PKG_NAME=$(jq -r '.name' package.json) | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Check if version is already published | |
| PUBLISHED_VERSION=$(npm view "$PKG_NAME@$VERSION" version 2>/dev/null || echo "") | |
| if [ "$PUBLISHED_VERSION" = "$VERSION" ]; then | |
| echo "Version $VERSION already published to npm, skipping publish" | |
| echo "published=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Publishing $VERSION to npm..." | |
| npm publish | |
| echo "published=true" >> $GITHUB_OUTPUT | |
| echo "Successfully published v$VERSION to npm" | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: [publish] | |
| if: needs.publish.outputs.published == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get latest commit info | |
| id: commit | |
| run: | | |
| COMMIT_HASH=$(git rev-parse --short HEAD) | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| echo "hash=$COMMIT_HASH" >> $GITHUB_OUTPUT | |
| echo "msg<<EOF" >> $GITHUB_OUTPUT | |
| echo "$COMMIT_MSG" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.publish.outputs.version }} | |
| target_commitish: ${{ needs.publish.outputs.final-sha || github.ref_name }} | |
| name: AgentGUI v${{ needs.publish.outputs.version }} | |
| body: | | |
| ## AgentGUI v${{ needs.publish.outputs.version }} | |
| **Latest commit**: ${{ steps.commit.outputs.hash }} | |
| ${{ steps.commit.outputs.msg }} | |
| Install with: | |
| ```bash | |
| bun x agentgui@latest | |
| npm install -g agentgui | |
| npx agentgui | |
| ``` | |
| **Web interface**: http://localhost:3000/gm/ | |
| **Notes**: | |
| - Data stored in `~/.gmgui/` folder | |
| - Requirements: Node.js 18+ | |
| draft: false | |
| prerelease: false |