Clear session edits after successfully sending to agent #237
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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| task: | |
| description: Task to run | |
| required: true | |
| default: release | |
| type: choice | |
| options: | |
| - release | |
| - unpublish | |
| bump: | |
| description: Version bump type (release only) | |
| required: true | |
| default: patch | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| - prerelease | |
| preid: | |
| description: Pre-release identifier (prerelease only) | |
| required: false | |
| default: beta | |
| type: string | |
| npm_tag: | |
| description: npm dist-tag (auto = latest for stable, beta for prerelease) | |
| required: true | |
| default: auto | |
| type: choice | |
| options: | |
| - auto | |
| - latest | |
| - beta | |
| - next | |
| unpublish_versions: | |
| description: Space-separated versions to unpublish (unpublish only) | |
| required: false | |
| default: "0.1.0-beta.3 0.1.0-beta.4 0.1.0-beta.5 0.1.0-beta.6 0.1.0-beta.7 0.1.0-beta.8" | |
| type: string | |
| confirm_unpublish: | |
| description: Type UNPUBLISH to confirm unpublish task | |
| required: false | |
| default: "" | |
| type: string | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: publish-${{ github.event_name }}-${{ github.ref }}-${{ github.event.inputs.task || 'ci' }} | |
| cancel-in-progress: false | |
| jobs: | |
| ci: | |
| if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build | |
| run: bun run build | |
| - name: Typecheck | |
| run: bunx tsc --noEmit | |
| - name: Test | |
| run: bunx vitest run | |
| release: | |
| if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.task == 'release' && github.ref == 'refs/heads/main' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Configure git author | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Verify npm authentication | |
| run: npm whoami | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Build | |
| run: bun run build | |
| - name: Typecheck | |
| run: bunx tsc --noEmit | |
| - name: Test | |
| run: bunx vitest run | |
| - name: Validate release inputs | |
| run: | | |
| if [ "${{ github.event.inputs.bump }}" = "prerelease" ] && [ -z "${{ github.event.inputs.preid }}" ]; then | |
| echo "preid is required when bump=prerelease" | |
| exit 1 | |
| fi | |
| - name: Bump version | |
| id: version | |
| run: | | |
| if [ "${{ github.event.inputs.bump }}" = "prerelease" ]; then | |
| bun pm version prerelease --preid "${{ github.event.inputs.preid }}" | |
| else | |
| bun pm version "${{ github.event.inputs.bump }}" | |
| fi | |
| VERSION=$(bun -e "import pkg from './package.json'; console.log(pkg.version)") | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Resolve publish tag | |
| id: publish_tag | |
| run: | | |
| TAG="${{ github.event.inputs.npm_tag }}" | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [ "$TAG" = "auto" ]; then | |
| if [[ "$VERSION" == *-* ]]; then | |
| TAG="beta" | |
| else | |
| TAG="latest" | |
| fi | |
| fi | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| - name: Publish to npm | |
| run: npm publish --provenance --tag "${{ steps.publish_tag.outputs.tag }}" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Push version commit | |
| run: git push origin HEAD:main | |
| unpublish: | |
| if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.task == 'unpublish' && github.ref == 'refs/heads/main' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Validate unpublish confirmation and versions | |
| run: | | |
| if [ "${{ github.event.inputs.confirm_unpublish }}" != "UNPUBLISH" ]; then | |
| echo "Set confirm_unpublish to UNPUBLISH to run unpublish task." | |
| exit 1 | |
| fi | |
| VERSIONS="${{ github.event.inputs.unpublish_versions }}" | |
| if [ -z "$VERSIONS" ]; then | |
| echo "No versions provided." | |
| exit 1 | |
| fi | |
| for VERSION in $(echo "$VERSIONS" | tr ',' ' '); do | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]]; then | |
| echo "Invalid version: $VERSION" | |
| exit 1 | |
| fi | |
| done | |
| - name: Unpublish selected versions | |
| run: | | |
| for VERSION in $(echo "${{ github.event.inputs.unpublish_versions }}" | tr ',' ' '); do | |
| set +e | |
| OUTPUT=$(bunx npm unpublish "made-refine@$VERSION" 2>&1) | |
| STATUS=$? | |
| set -e | |
| echo "$OUTPUT" | |
| if [ "$STATUS" -ne 0 ]; then | |
| if echo "$OUTPUT" | grep -qiE "404|not found|is not in this registry|already unpublished"; then | |
| echo "$VERSION already unpublished or not found" | |
| else | |
| echo "Failed to unpublish $VERSION" | |
| exit "$STATUS" | |
| fi | |
| fi | |
| done | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |