# SPDX-FileCopyrightText: 2024 LiveKit, Inc. # # SPDX-License-Identifier: Apache-2.0 name: Release on: push: branches: - main - 0.x workflow_dispatch: inputs: snapshot: description: 'Publish a snapshot release' type: boolean default: false concurrency: ${{ github.workflow }}-${{ github.ref }} permissions: id-token: write # Required for OIDC contents: write # Required to create GH releases pull-requests: write # Required to interact with PRs jobs: release: name: Release runs-on: ubuntu-latest outputs: publish_outcome: ${{ steps.changesets.outcome }} published: ${{ steps.changesets.outputs.published }} published_packages: ${{ steps.changesets.outputs.publishedPackages }} steps: - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: lfs: true - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 - name: Use Node.js 20 uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 with: node-version: 24 cache: pnpm - name: Install dependencies run: pnpm install --frozen-lockfile # npm trusted publishing cannot publish a package for the first time. New packages must be # created on npm before release CI can publish subsequent versions with OIDC. - name: Verify all packages exist on npm run: | MISSING=() for pkg in $(pnpm -r --silent exec -- node -e " const p = require('./package.json'); if (!p.private) process.stdout.write(p.name + '\n'); "); do if ! npm view "$pkg" > /dev/null 2>&1; then MISSING+=("$pkg") fi done if [ ${#MISSING[@]} -gt 0 ]; then echo "::error::The following packages are not yet published on npm:" for pkg in "${MISSING[@]}"; do echo "::error:: - $pkg" done exit 1 fi echo "All packages exist on npm." - name: Create Release Pull Request or Publish to npm id: changesets if: ${{ github.event.inputs.snapshot != 'true' }} uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d # v1.9.0 with: publish: pnpm ci:publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish pre-release id: changeset-prerelease if: ${{ github.event.inputs.snapshot == 'true' }} run: | pnpm changeset version --snapshot next pnpm build pnpm publish -r --tag next --no-git-checks env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build docs if: steps.changesets.outputs.published == 'true' run: pnpm doc - name: S3 upload if: steps.changesets.outputs.published == 'true' run: aws s3 cp docs/ s3://livekit-docs/agents-js --recursive env: AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }} AWS_DEFAULT_REGION: 'us-east-1' dispatch-downstream-bumps: name: Bump agents-js in downstream repos needs: [release] if: >- always() && github.ref == 'refs/heads/main' && needs.release.outputs.publish_outcome == 'success' && needs.release.outputs.published == 'true' runs-on: ubuntu-latest steps: - name: Dispatch to internal-actions env: GH_TOKEN: ${{ secrets.SYNC_DISPATCH_TOKEN }} TARGET_REPO: ${{ vars.TARGET_REPO }} PUBLISHED_PACKAGES: ${{ needs.release.outputs.published_packages }} SOURCE_REPO: ${{ github.repository }} SOURCE_SHA: ${{ github.sha }} run: | is_stable=$(jq -r 'length > 0 and all(.[]; .version | test("^[0-9]+\\.[0-9]+\\.[0-9]+$"))' \ <<< "$PUBLISHED_PACKAGES") if [ "$is_stable" != "true" ]; then echo "::notice::Published packages are not all stable versions; skipping downstream bump." exit 0 fi if [ -z "$TARGET_REPO" ]; then echo "::error::TARGET_REPO repository variable is not configured" exit 1 fi if [ -z "$GH_TOKEN" ]; then echo "::error::SYNC_DISPATCH_TOKEN repository secret is not configured" exit 1 fi jq -n \ --arg source_repo "$SOURCE_REPO" \ --arg source_sha "$SOURCE_SHA" \ --argjson published_packages "$PUBLISHED_PACKAGES" \ '{event_type: "agents-js-published", client_payload: {source_repo: $source_repo, source_sha: $source_sha, published_packages: $published_packages}}' \ | gh api -X POST "repos/${TARGET_REPO}/dispatches" --input -