Skip to content

Update OpenAPI spec (9961670) (#104) #71

Update OpenAPI spec (9961670) (#104)

Update OpenAPI spec (9961670) (#104) #71

Workflow file for this run

name: Publish OpenAPI Spec to npm
on:
push:
branches: [main]
paths:
- 'spec/open-api-spec.yaml'
- 'src/policy/**'
- 'operationOverrides.node.json'
- 'tsdown.config.ts'
# The services roster (dist/services) is generated by this script and
# bundled by tsdown. A fix to its logic alone must republish. Do NOT add
# package.json/package-lock.json here: the publish job commits those back
# to main via the App token, which would re-trigger this workflow in a loop.
- 'scripts/generate-services.mjs'
workflow_dispatch:
inputs:
bump:
description: 'Version bump type'
required: true
default: 'minor'
type: choice
options:
- patch
- minor
- major
concurrency:
group: publish-spec
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
client-id: ${{ vars.SDK_BOT_APP_ID }}
private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }}
permission-contents: write
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Bump version
id: version
run: |
set -euo pipefail
bump="${{ github.event.inputs.bump || 'minor' }}"
current="$(node -p "require('./package.json').version")"
npm version "$bump" --no-git-tag-version
next="$(node -p "require('./package.json').version")"
echo "current=$current" >> "$GITHUB_OUTPUT"
echo "next=$next" >> "$GITHUB_OUTPUT"
echo "Bump: $bump | $current → $next"
- name: Build policy module
run: npm run build:policy
- name: Generate TypeScript types
run: |
set -euo pipefail
mkdir -p dist
npx -y openapi-typescript@7 spec/open-api-spec.yaml -o dist/types.d.ts
- name: Stage dist assets
run: |
set -euo pipefail
cp spec/open-api-spec.yaml dist/
cp operationOverrides.node.json dist/
- name: Publish to npm
run: npm publish --access public --provenance
- name: Commit version bump
run: |
set -euo pipefail
git config user.name "workos-sdk-automation[bot]"
git config user.email "255426317+workos-sdk-automation[bot]@users.noreply.github.com"
git add package.json package-lock.json
git diff --cached --quiet && exit 0
git commit -m "chore: release v${{ steps.version.outputs.next }}"
git push origin main
- name: Tag release
run: |
set -euo pipefail
tag="v${{ steps.version.outputs.next }}"
git tag -a "$tag" -m "Release $tag"
git push origin "$tag"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
TAG: v${{ steps.version.outputs.next }}
VERSION: ${{ steps.version.outputs.next }}
PREVIOUS: v${{ steps.version.outputs.current }}
run: |
set -euo pipefail
notes_file="$(mktemp)"
{
echo "Published [\`@workos/openapi-spec@${VERSION}\`](https://www.npmjs.com/package/@workos/openapi-spec/v/${VERSION}) to npm."
echo
echo "**Changes:** [\`${PREVIOUS}...${TAG}\`](https://github.com/${GITHUB_REPOSITORY}/compare/${PREVIOUS}...${TAG})"
} > "$notes_file"
gh release create "$TAG" \
--title "$TAG" \
--notes-file "$notes_file" \
spec/open-api-spec.yaml