feat: toolbar to headless api (state and execute) (#2757) #555
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
| # Auto-releases on push to: | |
| # - main (@next channel) | |
| # - stable (@latest channel) | |
| # Manual PR preview: dispatch with pr_number to publish @pr-<number> | |
| name: 📦 Release superdoc | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - stable | |
| paths: | |
| - 'packages/superdoc/**' | |
| - 'packages/layout-engine/**' | |
| - 'packages/super-editor/**' | |
| - 'packages/ai/**' | |
| - 'packages/word-layout/**' | |
| - 'packages/preset-geometry/**' | |
| - 'pnpm-workspace.yaml' | |
| - '!**/*.md' | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: 'PR number to publish a preview package for (leave empty for normal release)' | |
| required: false | |
| type: number | |
| permissions: | |
| contents: write | |
| packages: write | |
| pull-requests: write | |
| concurrency: | |
| group: ${{ github.ref_name == 'stable' && 'release-stable-writeback' || format('{0}-{1}', github.workflow, github.ref) }} | |
| cancel-in-progress: ${{ github.ref_name != 'stable' }} | |
| jobs: | |
| release: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Generate token | |
| id: generate_token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| # PR preview: check out the PR branch | |
| - name: Get PR head ref | |
| if: inputs.pr_number | |
| id: pr | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ inputs.pr_number }} --jq '{ref: .head.ref, sha: .head.sha}') | |
| echo "ref=$(echo $PR_DATA | jq -r .ref)" >> $GITHUB_OUTPUT | |
| echo "sha=$(echo $PR_DATA | jq -r .sha)" >> $GITHUB_OUTPUT | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ steps.pr.outputs.sha || '' }} | |
| token: ${{ steps.generate_token.outputs.token }} | |
| - name: Refresh stable branch head | |
| if: github.ref_name == 'stable' && !inputs.pr_number | |
| run: | | |
| git fetch origin "${{ github.ref_name }}" --tags | |
| git checkout -B "${{ github.ref_name }}" "origin/${{ github.ref_name }}" | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| cache: pnpm | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: oven-sh/setup-bun@v2 | |
| - name: Cache apt packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/apt-cache | |
| key: apt-canvas-${{ runner.os }}-v1 | |
| - name: Install canvas system dependencies | |
| run: | | |
| mkdir -p ~/apt-cache | |
| sudo apt-get update | |
| sudo apt-get install -y -o Dir::Cache::Archives="$HOME/apt-cache" \ | |
| build-essential \ | |
| libcairo2-dev \ | |
| libpango1.0-dev \ | |
| libjpeg-dev \ | |
| libgif-dev \ | |
| librsvg2-dev \ | |
| libpixman-1-dev | |
| - name: Install dependencies | |
| run: pnpm install | |
| # PR preview: set version before build so it's baked into the package | |
| - name: Set preview version | |
| if: inputs.pr_number | |
| id: version | |
| run: | | |
| BASE_VERSION=$(node -p "require('./packages/superdoc/package.json').version") | |
| PREVIEW_VERSION="${BASE_VERSION}-pr.${{ inputs.pr_number }}.$(date +%s)" | |
| echo "version=$PREVIEW_VERSION" >> $GITHUB_OUTPUT | |
| cd packages/superdoc | |
| npm version "$PREVIEW_VERSION" --no-git-tag-version | |
| - name: Build packages | |
| run: pnpm run build | |
| # PR preview: publish with pr-<number> dist-tag | |
| - name: Publish PR preview | |
| if: inputs.pr_number | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| node scripts/publish-superdoc.cjs \ | |
| --dist-tag pr-${{ inputs.pr_number }} \ | |
| --skip-build | |
| - name: Comment on PR | |
| if: inputs.pr_number | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh pr comment ${{ inputs.pr_number }} --body "$(cat <<'EOF' | |
| 📦 **Preview published:** `superdoc@${{ steps.version.outputs.version }}` | |
| ```bash | |
| npm install superdoc@pr-${{ inputs.pr_number }} | |
| ``` | |
| EOF | |
| )" | |
| # Normal release: semantic-release (only when NOT a PR preview) | |
| - name: Release | |
| if: ${{ !inputs.pr_number }} | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| LINEAR_TOKEN: ${{ secrets.LINEAR_TOKEN }} | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| working-directory: packages/superdoc | |
| run: pnpx semantic-release |