|
| 1 | +# SPDX-FileCopyrightText: 2026 LiveKit, Inc. |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +# After a release PR merges: tag and create the GitHub releases, then |
| 6 | +# publish to npm. The step that cannot be undone comes last. |
| 7 | +name: Release |
| 8 | + |
| 9 | +on: |
| 10 | + # Any base branch: an rc PR from `pre-release` targets the branch it |
| 11 | + # was run on. The bot and marker check on the job gates the run. |
| 12 | + pull_request: |
| 13 | + types: [closed] |
| 14 | + # A failed job is re-run with "Re-run failed jobs" on the run itself: |
| 15 | + # that keeps the merge commit. Run by hand only for a fixed workflow |
| 16 | + # file, with `ref` set to the release tag. `verwalter release` resumes |
| 17 | + # from the current state and skips what is done. With `package`, that |
| 18 | + # package is reported again even when complete, so the publish job and |
| 19 | + # the docs job run for it. |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + ref: |
| 23 | + description: Commit or tag to release and publish. Set it to the release tag. Empty is the branch head. |
| 24 | + required: false |
| 25 | + default: '' |
| 26 | + package: |
| 27 | + description: Only this package; always reported to the publish job. |
| 28 | + required: false |
| 29 | + default: '' |
| 30 | + |
| 31 | +permissions: |
| 32 | + contents: write |
| 33 | + id-token: write # trusted publishing |
| 34 | + |
| 35 | +jobs: |
| 36 | + # Build before the tag: a build that fails stops the run before |
| 37 | + # anything is public. The publish and docs jobs use this build. |
| 38 | + build: |
| 39 | + # Only a release PR the tool opened: the branch prefix alone would let |
| 40 | + # any pushed `release/*` branch trigger a publish. |
| 41 | + if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') && github.event.pull_request.user.login == 'verwalter-release[bot]' && contains(github.event.pull_request.body, '<!-- verwalter release -->')) |
| 42 | + runs-on: ubuntu-latest |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 47 | + with: |
| 48 | + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} |
| 49 | + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 |
| 50 | + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 51 | + with: |
| 52 | + node-version: 24 |
| 53 | + cache: pnpm |
| 54 | + - run: pnpm install |
| 55 | + - name: Build server SDK |
| 56 | + run: pnpm --filter="livekit-server-sdk" build |
| 57 | + - name: Build rtc-node |
| 58 | + run: pnpm --filter="@livekit/rtc-node" build |
| 59 | + # The build output, and the generated version file that both |
| 60 | + # packages ship in `src`. |
| 61 | + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 62 | + with: |
| 63 | + name: build |
| 64 | + if-no-files-found: error |
| 65 | + path: | |
| 66 | + packages/livekit-server-sdk/dist |
| 67 | + packages/livekit-server-sdk/src/version.ts |
| 68 | + packages/livekit-rtc/dist |
| 69 | + packages/livekit-rtc/src/version.ts |
| 70 | +
|
| 71 | + release: |
| 72 | + needs: build |
| 73 | + runs-on: ubuntu-latest |
| 74 | + outputs: |
| 75 | + released: ${{ steps.verwalter.outputs.released }} |
| 76 | + releases: ${{ steps.verwalter.outputs.releases }} |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 79 | + with: |
| 80 | + # The merge commit itself: a push to main right after the merge |
| 81 | + # must not move the tags. |
| 82 | + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} |
| 83 | + fetch-depth: 0 |
| 84 | + - id: verwalter |
| 85 | + uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 |
| 86 | + with: |
| 87 | + command: release |
| 88 | + args: ${{ inputs.package && format('--package {0}', inputs.package) || '' }} |
| 89 | + |
| 90 | + publish: |
| 91 | + needs: release |
| 92 | + if: needs.release.outputs.released == 'true' || github.event_name == 'workflow_dispatch' |
| 93 | + runs-on: ubuntu-latest |
| 94 | + # One publish at a time, in arrival order. A waiting publish checks out |
| 95 | + # after the running one ends, so it sees the newer tag and picks the |
| 96 | + # right npm dist-tag. `queue: max` keeps every waiting run: without it, |
| 97 | + # a third run cancels the waiting one. |
| 98 | + concurrency: |
| 99 | + group: npm-publish |
| 100 | + cancel-in-progress: false |
| 101 | + queue: max |
| 102 | + permissions: |
| 103 | + contents: write # the tool flips draft releases after the publish |
| 104 | + id-token: write # trusted publishing |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 107 | + with: |
| 108 | + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} |
| 109 | + fetch-depth: 0 # tags decide what is published |
| 110 | + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 |
| 111 | + # No registry-url: npm trusted publishing needs no token, and the |
| 112 | + # placeholder token setup-node writes would make the publish fail. |
| 113 | + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 114 | + with: |
| 115 | + node-version: 24 # npm 11.5.1 or later is required for OIDC |
| 116 | + cache: pnpm |
| 117 | + - run: pnpm install |
| 118 | + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 |
| 119 | + with: |
| 120 | + name: build |
| 121 | + path: packages |
| 122 | + - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 |
| 123 | + env: |
| 124 | + GH_TOKEN: ${{ github.token }} |
| 125 | + with: |
| 126 | + command: publish |
| 127 | + releases: ${{ needs.release.outputs.releases }} |
| 128 | + |
| 129 | + # The end state, asserted: `status --check` fails when a tag is not on |
| 130 | + # the remote, a GitHub release is missing or still a draft, or npm does |
| 131 | + # not have the version. A step that was skipped without an error ends here. |
| 132 | + verify: |
| 133 | + needs: publish |
| 134 | + runs-on: ubuntu-latest |
| 135 | + permissions: |
| 136 | + contents: write # reads only. A draft release is visible only with write access |
| 137 | + steps: |
| 138 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 139 | + with: |
| 140 | + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} |
| 141 | + fetch-depth: 0 |
| 142 | + - uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0 |
| 143 | + with: |
| 144 | + command: status |
| 145 | + args: --check |
| 146 | + |
| 147 | + # Its own job: a docs failure is red, and the publish job stays green, |
| 148 | + # so it is clear that the release is complete. A re-run is safe. |
| 149 | + # The docs site holds one version, the newest final server SDK release |
| 150 | + # from main. An rc, another branch, or a release of rtc-node alone must |
| 151 | + # not replace it. |
| 152 | + docs: |
| 153 | + needs: [release, publish] |
| 154 | + if: success() && (github.event.pull_request.base.ref == 'main' || github.ref == 'refs/heads/main') |
| 155 | + runs-on: ubuntu-latest |
| 156 | + permissions: |
| 157 | + contents: read |
| 158 | + steps: |
| 159 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 160 | + with: |
| 161 | + ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }} |
| 162 | + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 |
| 163 | + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 164 | + with: |
| 165 | + node-version: 24 |
| 166 | + cache: pnpm |
| 167 | + - name: Check for a final server SDK release |
| 168 | + id: docs |
| 169 | + env: |
| 170 | + RELEASES: ${{ needs.release.outputs.releases }} |
| 171 | + run: | |
| 172 | + if jq -e 'any(.[]; .package == "livekit-server-sdk" and .prerelease == false)' <<< "${RELEASES:-[]}" >/dev/null; then |
| 173 | + echo "stable=true" >> "$GITHUB_OUTPUT" |
| 174 | + fi |
| 175 | + - if: steps.docs.outputs.stable == 'true' |
| 176 | + run: pnpm install |
| 177 | + # The build job's output has src/version.ts, which the docs need. |
| 178 | + - if: steps.docs.outputs.stable == 'true' |
| 179 | + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 |
| 180 | + with: |
| 181 | + name: build |
| 182 | + path: packages |
| 183 | + - name: Build Server SDK Docs |
| 184 | + if: steps.docs.outputs.stable == 'true' |
| 185 | + run: pnpm --filter=livekit-server-sdk build-docs |
| 186 | + - name: S3 Upload Server SDK Docs |
| 187 | + if: steps.docs.outputs.stable == 'true' |
| 188 | + run: aws s3 cp packages/livekit-server-sdk/docs/ s3://livekit-docs/server-sdk-js --recursive |
| 189 | + env: |
| 190 | + AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }} |
| 191 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }} |
| 192 | + AWS_DEFAULT_REGION: 'us-east-1' |
0 commit comments