From 80b74f5e25fc3f62fa66436202d4f3862f82b84a Mon Sep 17 00:00:00 2001 From: PunGrumpy <108584943+PunGrumpy@users.noreply.github.com> Date: Fri, 11 Sep 2026 01:29:04 +0700 Subject: [PATCH] ci: publish preview releases with pkg.pr.new MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every push to main and every pull request now builds @docker-doctor/cli and publishes it to pkg.pr.new, so a fix can be installed from a commit sha before it ships to npm — without consuming a version number on the registry the way a snapshot publish would. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/preview-release.yml | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/preview-release.yml diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml new file mode 100644 index 0000000..23ac162 --- /dev/null +++ b/.github/workflows/preview-release.yml @@ -0,0 +1,56 @@ +name: Preview Release + +on: + push: + branches: + - main + pull_request: + +concurrency: + # Keyed by PR number rather than head_ref: two fork PRs can share a branch + # name, and a name-keyed group would let one push cancel an unrelated run. + group: preview-release-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + publish: + name: Publish Preview + runs-on: ubuntu-latest + if: github.repository_owner == 'PunGrumpy' + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Install Bun + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + - name: Setup Bun cache + uses: actions/cache@v6 + with: + path: ~/.bun/install/cache + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} + restore-keys: | + ${{ runner.os }}-bun- + - name: Install dependencies + run: bun install + - name: Build CLI + run: bun run build --filter @docker-doctor/cli + - name: Publish preview to pkg.pr.new + run: | + max_attempts=4 + for attempt in $(seq 1 "$max_attempts"); do + if bun x pkg-pr-new publish ./packages/docker-doctor; then + exit 0 + fi + + if [ "$attempt" -eq "$max_attempts" ]; then + exit 1 + fi + + delay=$((2 ** attempt)) + echo "pkg-pr-new publish failed (attempt ${attempt}/${max_attempts}); retrying in ${delay}s..." + sleep "$delay" + done