Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .changeset/config.json

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/changeset-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Fails a PR that changes a package without a changeset, with a comment
# that links to a prefilled changeset file. The `internal` label skips it.
name: Changeset check

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches: [main]

permissions:
contents: read
pull-requests: write

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0
with:
command: check
2 changes: 1 addition & 1 deletion .github/workflows/generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ name: Generate
on:
workflow_dispatch:
push:
branches-ignore: [main]
branches-ignore: [main, "release/**"] # release/* is regenerated by verwalter: nothing to generate there

permissions:
contents: write # Required to commit the regenerated output
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# On demand: open an rc PR from the branch the workflow is run on. Merging
# it tags 1.55.0-rc.1 and publishes under the `next` dist-tag. Changesets
# stay pending for the final release.
name: Pre-release PR

on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # the tags number the rc
- uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0
with:
command: pre-release
args: --target ${{ github.ref_name }}
app-client-id: ${{ secrets.VERWALTER_RELEASE_CLIENT_ID }}
app-private-key: ${{ secrets.VERWALTER_RELEASE_APP_KEY }}
29 changes: 29 additions & 0 deletions .github/workflows/release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Keeps one release PR open while changesets are pending. Runs on every
# push to main and regenerates the release branch from main.
name: Release PRs

on:
push:
branches: [main]

permissions:
contents: write
pull-requests: write

concurrency:
group: release-prs
cancel-in-progress: true

jobs:
pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # the commit that added a changeset gives its changelog line the PR and author
- uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0
with:
command: pr
# The App token lets the release PR trigger CI. github.token does not.
app-client-id: ${{ secrets.VERWALTER_RELEASE_CLIENT_ID }}
app-private-key: ${{ secrets.VERWALTER_RELEASE_APP_KEY }}
171 changes: 137 additions & 34 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
# After a release PR merges: build, then tag both packages and create the
# GitHub release of @livekit/protocol, then publish to npm and the Go
# proxy. The step that cannot be undone comes last.
# The file name stays release.yaml: npm trusted publishing names it.
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}
# No `branches` filter: an rc PR from pre-release.yaml targets the branch
# the workflow was run on. The condition on the first job decides which
# PRs release.
pull_request:
types: [closed]
# A failed job is re-run with "Re-run failed jobs" on the run itself:
# that keeps the merge commit. This trigger is for a run that needs a
# fixed workflow file from the branch. Anyone with write access can start
# it. `verwalter release` resumes from the current state and skips what
# is done.
workflow_dispatch:
inputs:
ref:
description: 'Commit or tag to build and publish. Set it to the release tag when the tag exists. Empty is the branch head.'
type: string
default: ''

permissions:
id-token: write # Required for OIDC
contents: write # Required to create GH releases
pull-requests: write # Required to interact with PRs
contents: write
id-token: write # npm trusted publishing

jobs:
release:
name: Release
# Before the tag: a commit that does not build is never tagged.
build:
# Only a release PR the tool opened: the branch prefix alone would let
# any pushed `release/*` branch trigger a publish.
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 -->'))
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# On a run by hand, `ref` is the released tag: the branch head can
# hold newer source than the version that is published. `publish`
# fails when the files changed since the tag.
ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }}

# The published JS package is generated at build time by pnpm generate:proto, so
# protoc is a release input. Keep it on the same release as generate.yaml, or the
# published package is generated by a different compiler than the committed Go code.
# The published JS package is generated at build time, so protoc is a
# release input. Keep it on the same release as generate.yaml, or the
# published package is generated by a different compiler than the
# committed Go code.
- name: Install Protoc
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
with:
Expand All @@ -30,30 +55,108 @@ jobs:

- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1

- name: Use Node.js 20
- name: Use Node.js 26
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Create Release Pull Request or Publish packages
id: changesets
# v2 is the release line for @changesets/cli v3. v1 detects published packages by parsing
# `changeset publish` stdout for "New tag:", which CLI v3 no longer prints, so `published`
# stays false and the Go tag below is never created.
uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2
with:
# This expects you to have a script called ci:publish which does a build for your packages and calls changeset publish
publish-script: pnpm ci:publish

- name: Create git tag for golang package
if: steps.changesets.outputs.published == 'true'
uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72 # v1.7.2
id: tag_create
with:
tag: ${{format('v{0}', fromJson(steps.changesets.outputs['published-packages'])[0].version)}}
tag_exists_error: false
message: "github.com/livekit/protocol@${{fromJson(steps.changesets.outputs['published-packages'])[0].version}}"
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm --filter @livekit/protocol run build

# The bundle leaves its dependencies external, so a missing export
# only fails when the published entry points are loaded.
- name: Load the built package
working-directory: packages/javascript
run: |
node --input-type=module -e "await import('./dist/index.mjs')"
node -e "require('./dist/index.cjs')"

# src/gen is generated, not committed, and the package ships it.
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: javascript
path: |
packages/javascript/dist
packages/javascript/src/gen
if-no-files-found: error

release:
needs: build
runs-on: ubuntu-latest
outputs:
released: ${{ steps.verwalter.outputs.released }}
releases: ${{ steps.verwalter.outputs.releases }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The merge commit itself: a push to main right after the merge
# must not move the tags.
ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }}
fetch-depth: 0
- id: verwalter
uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0
with:
command: release
app-client-id: ${{ secrets.VERWALTER_RELEASE_CLIENT_ID }}
app-private-key: ${{ secrets.VERWALTER_RELEASE_APP_KEY }}

# Publishes the build job's output to npm and asks the Go proxy for the
# tag. Skips a version a registry already has, so a re-run is safe.
publish:
needs: release
if: needs.release.outputs.released == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
# One publish at a time, in arrival order. A waiting publish checks out
# after the running one ends, so it sees the newer tag and picks the
# right npm dist-tag.
concurrency:
group: publish
cancel-in-progress: false
permissions:
contents: write # the tool flips the draft release after the publish
id-token: write # npm trusted publishing
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }}
fetch-depth: 0 # tags decide what is published
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
# No registry-url: with trusted publishing, its placeholder token
# makes the publish fail with 404.
- name: Use Node.js 26
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: javascript
path: packages/javascript
- uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0
env:
GH_TOKEN: ${{ github.token }}
with:
command: publish
releases: ${{ needs.release.outputs.releases }}

# The end state, asserted: `status --check` fails when a tag is not on
# the remote, the GitHub release is missing or still a draft, or npm or
# the Go proxy does not have the version. A step that was skipped
# without an error ends here.
verify:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write # reads only. A draft release is visible only with write access
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.merge_commit_sha || inputs.ref || github.sha }}
fetch-depth: 0
- uses: livekit/verwalter@39e3d7c57c2b6d96cf2d4b7771f3ab199490faba # v0.31.0
with:
command: status
args: --check
70 changes: 70 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Releasing protocol

This repository releases with [verwalter](https://github.com/livekit/verwalter).
The commands that are the same in every repository are in the
[verwalter cheat sheet](https://github.com/livekit/verwalter/blob/main/docs/cheat-sheet.md).
This file holds what is specific to this repository.

## Packages

The two packages always share a version.

| Package | Tag | Goes to |
| ----------------------------- | ----------------------------- | ------------------------------- |
| `github.com/livekit/protocol` | `v<version>` | Go proxy. No GitHub release. |
| `@livekit/protocol` | `@livekit/protocol@<version>` | npm, with a GitHub release |

The version of the Go module is in `go.mod` and the root `package.json`.

## Workflows

| File | Starts when | Does |
| ---------------------- | ------------------------- | ---------------------------------------------------------------------------- |
| `changeset-check.yaml` | A PR is opened or updated | Fails a PR that changes a package without a changeset. |
| `release-pr.yaml` | A push to `main` | Keeps the release PR `release/main` current. |
| `release.yaml` | The release PR merges | Builds the JS package, tags both packages, publishes to npm and the Go proxy. |
| `pre-release.yaml` | Run by hand | Opens an rc PR against the branch it runs on. |

Do not rename `release.yaml`: npm trusted publishing names the file.
`generate.yaml` does not run on `release/*` branches: verwalter
regenerates them on every push to `main`.

## Release

1. Merge the release PR.
2. Watch the run of `release.yaml`: `gh run list --workflow release.yaml --limit 1`.

A release is complete when:

- both tags are on the remote
- the tag `@livekit/protocol@<version>` has a public GitHub release
- npm and the Go proxy have the version
- the `verify` job is green. It checks the three points above.

## Pre-release

`gh workflow run pre-release.yaml --ref <branch>` opens an rc PR against
`<branch>`. The merge publishes the rc to npm with the dist-tag `next`.

## A release failed

Find the cause first. The paths by cause are in the
[recovery section](https://github.com/livekit/verwalter/blob/main/docs/release-workflows.md#recovery).

| Situation | Command |
| --------------------------------------------------------------- | -------------------------------------------------------------------------- |
| A job failed for a transient reason | `gh run rerun <run-id> --failed` |
| The workflow file needed a fix, and the fix is on `main` | `gh workflow run release.yaml -f ref=<tag>` |
| The released commit is wrong, and npm does not have the version | `verwalter release --abandon <tag>`, then a changeset and the next version |

A re-run of failed jobs keeps the merge commit. Prefer it to a run by
hand. Set `ref` on a run by hand: an empty `ref` releases the head of
the branch. If no tag exists yet, set `ref` to the merge commit of the
release PR.

`publish` skips a version that a registry has. It fails when the files
of the package changed since the tag.

A version that npm or the Go proxy has cannot be replaced. For npm,
deprecate it with `npm deprecate`. For Go, add a `retract` directive to
`go.mod`. Then release the next version.
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
"name": "github.com/livekit/protocol",
"private": true,
"version": "1.54.2",
"scripts": {
"changeset": "changeset",
"ci:publish": "pnpm --filter @livekit/protocol run build && changeset publish"
},
"devDependencies": {
"@babel/core": "^8.0.0",
"@changesets/cli": "^3.0.0",
"@livekit/changesets-changelog-github": "^0.2.0",
"esbuild": "^0.28.0"
},
"packageManager": "pnpm@12.17.0"
Expand Down
Loading
Loading