Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate protobufs and set up changesets publishing workflow #629

Merged
merged 19 commits into from
Mar 8, 2024
Merged
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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
15 changes: 15 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@livekit/changesets-changelog-github",
{ "repo": "livekit/protocol" }
],
"commit": false,
"fixed": [["github.com/livekit/protocol", "@livekit/protocol"]],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [],
"privatePackages": { "version": true, "tag": true }
}
64 changes: 32 additions & 32 deletions .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,41 @@ name: Test
on:
workflow_dispatch:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/go/bin
~/.cache
key: livekit-protocol

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Set up gotestfmt
run: go install github.com/gotesttools/gotestfmt/v2/cmd/[email protected]

- name: Download Go modules
run: go mod download

- name: Static Check
uses: amarpal/staticcheck-action@master
with:
checks: '["all", "-ST1000", "-ST1003", "-ST1020", "-ST1021", "-ST1022", "-SA1019"]'
install-go: false

- name: Test
run: |
set -euo pipefail
MallocNanoZone=0 go test -race -json -v ./... 2>&1 | gotestfmt
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/go/bin
~/.cache
key: livekit-protocol

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Set up gotestfmt
run: go install github.com/gotesttools/gotestfmt/v2/cmd/[email protected]

- name: Download Go modules
run: go mod download

- name: Static Check
uses: amarpal/staticcheck-action@master
with:
checks: '["all", "-ST1000", "-ST1003", "-ST1020", "-ST1021", "-ST1022", "-SA1019"]'
install-go: false

- name: Test
run: |
set -euo pipefail
MallocNanoZone=0 go test -race -json -v ./... 2>&1 | gotestfmt
85 changes: 51 additions & 34 deletions .github/workflows/generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,59 @@ name: Generate
on:
workflow_dispatch:
push:
branches-ignore: [ main ]
branches-ignore: [main]

jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '>=1.20'

- name: Go mod tidy
run: go mod tidy

- name: Install generators
uses: magefile/mage-action@v3
with:
version: latest
args: bootstrap

- name: Generate Protobuf
uses: magefile/mage-action@v3
with:
version: latest
args: proto

- name: Add changes
uses: EndBug/add-and-commit@v9
with:
add: '["livekit", "rpc", "infra"]'
default_author: github_actions
message: generated protobuf
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.20"

- name: Go mod tidy
run: go mod tidy

- name: Install generators
uses: magefile/mage-action@v3
with:
version: latest
install-only: true

- name: Bootstrap
run: mage bootstrap

- name: Generate Protobuf
run: mage proto

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Install JS dependencies
run: pnpm install

- name: Test generate JS files
run: |
pnpm --filter @livekit/protocol run generate:proto

- name: Add changes
uses: EndBug/add-and-commit@v9
with:
add: '["livekit", "rpc", "infra"]'
default_author: github_actions
message: generated protobuf
60 changes: 0 additions & 60 deletions .github/workflows/release-js.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Create Release Pull Request or Publish packages
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called ci:publish which does a build for your packages and calls changeset publish
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
# Dependency directories (remove the comment below to include it)
# vendor/
.idea/

node_modules/
8 changes: 4 additions & 4 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func Proto() error {
"--twirp_opt=paths=source_relative",
"--plugin=go=" + protocGoPath,
"--plugin=twirp=" + twirpPath,
"-I=.",
"-I=./protobufs",
}, twirpProtoFiles...)
cmd := exec.Command(protoc, args...)
connectStd(cmd)
Expand All @@ -116,7 +116,7 @@ func Proto() error {
"--go-grpc_opt=paths=source_relative",
"--plugin=go=" + protocGoPath,
"--plugin=go-grpc=" + protocGrpcGoPath,
"-I=.",
"-I=./protobufs",
}, grpcProtoFiles...)
cmd = exec.Command(protoc, args...)
connectStd(cmd)
Expand All @@ -131,7 +131,7 @@ func Proto() error {
"--go-grpc_opt=paths=source_relative",
"--plugin=go=" + protocGoPath,
"--plugin=go-grpc=" + protocGrpcGoPath,
"-I=.",
"-I=./protobufs",
}, infraProtoFiles...)
cmd = exec.Command(protoc, args...)
connectStd(cmd)
Expand Down Expand Up @@ -161,7 +161,7 @@ func Proto() error {
"--plugin=go=" + protocGoPath,
"--plugin=psrpc=" + psrpcPath,
"-I" + psrpcDir + "/protoc-gen-psrpc/options",
"-I=.",
"-I=./protobufs",
}, psrpcProtoFiles...)
cmd = exec.Command(protoc, args...)
mageutil.ConnectStd(cmd)
Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "github.com/livekit/protocol",
"private": true,
"version": "1.10.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we need to update the version here when tagging a new release?

Same question for packages/javascript/package.json.

What's the difference between the two, btw? It's for compatibility, I assume?

Copy link
Contributor Author

@lukasIO lukasIO Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this will automatically be done by the changesets PR.
Here's an example of what that looks like on the client-sdk-js.
Once merged, the release action will create the git tag.

One (the one in the javascript folder) is for tracking the changes of the JS package, the other one (in root) will track the golang module.

"scripts": {
"changeset": "changeset",
"publish:ci": "pnpm --filter @livekit/protocol run build && changeset publish"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@livekit/changesets-changelog-github": "^0.0.4"
}
}
3 changes: 3 additions & 0 deletions packages/javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
src/gen
!src/gen/version.d.ts
6 changes: 3 additions & 3 deletions packages/js/package.json → packages/javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@livekit/protocol",
"version": "13.0.0",
"version": "1.10.1",
"description": "",
"type": "module",
"main": "src/index.js",
Expand All @@ -10,8 +10,8 @@
],
"scripts": {
"generate:version": "genversion --esm --semi src/gen/version.js",
"generate:proto": "protoc --es_out src/gen --es_opt target=js+dts -I=../../ ../../livekit_rtc.proto ../../livekit_models.proto ../../livekit_agent.proto ../../livekit_webhook.proto ../../livekit_egress.proto ../../livekit_ingress.proto ../../livekit_sip.proto",
"ci:publish": "pnpm publish"
"generate:proto": "protoc --es_out src/gen --es_opt target=js+dts -I=../../protobufs ../../protobufs/livekit_rtc.proto ../../protobufs/livekit_models.proto ../../protobufs/livekit_agent.proto ../../protobufs/livekit_webhook.proto ../../protobufs/livekit_egress.proto ../../protobufs/livekit_ingress.proto ../../protobufs/livekit_sip.proto",
"build": "pnpm generate:version && pnpm generate:proto"
},
"keywords": [],
"author": "LiveKit",
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion packages/js/.gitignore

This file was deleted.

Loading
Loading