Skip to content

Expose Drive grep warnings in SDK #24

Expose Drive grep warnings in SDK

Expose Drive grep warnings in SDK #24

Workflow file for this run

name: Release
# Auto-publish @diskd-ai/sdk to npmjs.com whenever main moves and the
# version in package.json hasn't been published yet. Bumping is local:
#
# npm version patch # or: minor / major
# git push origin main
#
# The next CI run sees the new version, runs typecheck + lint + tests +
# build, publishes with provenance, and tags vX.Y.Z. If the version has
# already been published, the job exits clean as a no-op -- safe to push
# README-only commits without re-publishing.
#
# Required repo secret:
# - NPM_TOKEN — npmjs.com granular token with publish + bypass-2FA
# for the @diskd-ai scope.
on:
push:
branches: [main]
workflow_dispatch: {}
permissions:
contents: write # tag + push tag back after publish
id-token: write # required by npm provenance attestation
# Avoid two parallel publishes if main is updated rapidly.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node 24
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
scope: '@diskd-ai'
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: '1.2.23'
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Typecheck
run: bun run typecheck
- name: Lint
run: bun run lint
- name: Unit tests
run: bun run test
- name: Build
run: bun run build
- name: Check whether package.json version is already published
id: ver
run: |
set -euo pipefail
VERSION="$(node -p 'require("./package.json").version')"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Anonymous registry GET on the version-specific endpoint:
# 200 = exists (skip publish), 404 = new (do publish).
HTTP_CODE="$(curl -s -o /dev/null -w '%{http_code}' "https://registry.npmjs.org/@diskd-ai/sdk/$VERSION")"
echo "Registry probe for $VERSION returned HTTP $HTTP_CODE"
if [ "$HTTP_CODE" = "200" ]; then
echo "publish=false" >> "$GITHUB_OUTPUT"
echo "::notice::@diskd-ai/sdk@$VERSION already on npmjs -- nothing to publish."
else
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "::notice::@diskd-ai/sdk@$VERSION not yet on npmjs -- will publish."
fi
- name: npm publish (provenance enabled)
if: steps.ver.outputs.publish == 'true'
run: npm publish --provenance --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Tag the release
if: steps.ver.outputs.publish == 'true'
run: |
set -euo pipefail
TAG="v${{ steps.ver.outputs.version }}"
# If the tag was pushed manually before this run, re-pushing
# is a no-op; we only push when the tag does not yet exist.
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists locally."
else
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git tag "$TAG"
git push origin "$TAG"
fi
- name: Summary
run: |
if [ "${{ steps.ver.outputs.publish }}" = "true" ]; then
echo "### Published @diskd-ai/sdk@${{ steps.ver.outputs.version }}" >> "$GITHUB_STEP_SUMMARY"
else
echo "### Skipped publish: @diskd-ai/sdk@${{ steps.ver.outputs.version }} already on npmjs" >> "$GITHUB_STEP_SUMMARY"
fi
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "https://www.npmjs.com/package/@diskd-ai/sdk/v/${{ steps.ver.outputs.version }}" >> "$GITHUB_STEP_SUMMARY"