Skip to content

Release

Release #25

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
npm_tag:
description: npm distribution tag (used only when publish_npm is enabled)
required: true
default: next
publish_npm:
description: Publish to npm after uploading prebuild assets (explicit opt-in)
required: true
type: boolean
default: false
upload_assets:
description: Upload prebuild assets to the GitHub release (explicit opt-in)
required: true
type: boolean
default: false
release:
types: [published]
permissions:
contents: read
jobs:
guard:
name: Validate release inputs
runs-on: ubuntu-latest
steps:
- name: Require assets for npm publication
if: github.event_name == 'workflow_dispatch' && inputs.publish_npm && !inputs.upload_assets
run: |
echo "publish_npm requires upload_assets so native installs can resolve this release"
exit 1
prebuild-linux:
name: Prebuild ${{ matrix.target }}
runs-on: ubuntu-latest
needs: guard
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- target: linux-x64-glibc
dockerfile: build-containers/Dockerfile.debian
image: webrtc-node-prebuild-debian
build_args: --build-arg NODE_VERSION=20 --build-arg DEBIAN_VERSION=bullseye
libc: glibc
- target: linux-x64-musl
dockerfile: build-containers/Dockerfile.alpine
image: webrtc-node-prebuild-alpine
build_args: --build-arg NODE_VERSION=20 --build-arg ALPINE_VERSION=3.20
libc: musl
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }}
- name: Build Linux prebuild
run: |
docker build \
-f "${{ matrix.dockerfile }}" \
${{ matrix.build_args }} \
-t "${{ matrix.image }}" .
docker run --rm \
-v "$PWD:/usr/app" \
-w /usr/app \
"${{ matrix.image }}" \
sh -lc "npm ci --ignore-scripts && npm run build -- --CDWEBRTC_NODE_STATIC_OPENSSL=ON && npm run prebuild:package -- --platform=linux --arch=x64 --libc=${{ matrix.libc }} && node -e \"const { RTCPeerConnection } = require('@webrtc-node/webrtc'); const pc = new RTCPeerConnection(); pc.close();\""
- uses: actions/upload-artifact@v7
with:
name: prebuild-${{ matrix.target }}
path: packages/webrtc/prebuild-artifacts/*
prebuild-macos:
name: Prebuild ${{ matrix.target }}
runs-on: ${{ matrix.os }}
needs: guard
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
target: darwin-x64
arch: x64
- os: macos-15
target: darwin-arm64
arch: arm64
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }}
- uses: actions/setup-node@v6
with:
node-version: 20
cache: npm
- uses: ./.github/actions/setup-native-build
- run: npm ci --ignore-scripts
- run: npm run build -- --arch=${{ matrix.arch }} --CDWEBRTC_NODE_STATIC_OPENSSL=ON
- run: npm run prebuild:package -- --platform=darwin --arch=${{ matrix.arch }}
- run: node -e "const { RTCPeerConnection } = require('@webrtc-node/webrtc'); const pc = new RTCPeerConnection(); pc.close();"
- uses: actions/upload-artifact@v7
with:
name: prebuild-${{ matrix.target }}
path: packages/webrtc/prebuild-artifacts/*
prebuild-windows:
name: Prebuild ${{ matrix.target }}
runs-on: ${{ matrix.os }}
needs: guard
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: win32-x64
arch: x64
- os: windows-11-arm
target: win32-arm64
arch: arm64
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }}
- uses: actions/setup-node@v6
with:
node-version: 20
cache: npm
- uses: ./.github/actions/setup-native-build
- run: npm ci --ignore-scripts
- run: npm run build -- --arch=${{ matrix.arch }} --CDWEBRTC_NODE_STATIC_OPENSSL=ON
- run: npm run prebuild:package -- --platform=win32 --arch=${{ matrix.arch }}
- run: node -e "const { RTCPeerConnection } = require('@webrtc-node/webrtc'); const pc = new RTCPeerConnection(); pc.close();"
- uses: actions/upload-artifact@v7
with:
name: prebuild-${{ matrix.target }}
path: packages/webrtc/prebuild-artifacts/*
validate-release:
name: Validate release artifacts
runs-on: ubuntu-latest
needs:
- prebuild-linux
- prebuild-macos
- prebuild-windows
timeout-minutes: 20
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }}
- uses: actions/setup-node@v6
with:
node-version: 24
package-manager-cache: false
registry-url: https://registry.npmjs.org
- uses: actions/download-artifact@v8
with:
pattern: prebuild-*
path: packages/webrtc/prebuild-artifacts
merge-multiple: true
- run: npm ci --ignore-scripts
- run: npm run prebuild:check
- run: npm run native:check
- name: Verify package versions and contents
run: |
set -euo pipefail
node -e "const fs = require('node:fs'); const names = ['webrtc', 'media', 'stats']; const packages = names.map(name => require('./packages/' + name + '/package.json')); const versions = new Set(packages.map(pkg => pkg.version)); if (versions.size !== 1) throw new Error('release packages must have one coordinated version'); for (const name of names) if (!fs.existsSync('./packages/' + name + '/README.md') || !fs.existsSync('./packages/' + name + '/LICENSE')) throw new Error(name + ' is missing release documentation');"
npm run package:check >/dev/null
- name: Verify release tag
env:
EVENT_NAME: ${{ github.event_name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
expected="v$(node -p "require('./packages/webrtc/package.json').version")"
if [ "$EVENT_NAME" = "release" ] && [ "$RELEASE_TAG" != "$expected" ]; then
echo "Release tag $RELEASE_TAG does not match package version $expected"
exit 1
fi
upload-assets:
name: Upload release assets
runs-on: ubuntu-latest
needs: validate-release
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }}
- uses: actions/download-artifact@v8
with:
pattern: prebuild-*
path: packages/webrtc/prebuild-artifacts
merge-multiple: true
- name: Upload prebuild release assets
if: github.event_name != 'workflow_dispatch' || inputs.upload_assets
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
tag="$RELEASE_TAG"
if [ "$EVENT_NAME" != "release" ]; then
tag="v$(node -p "require('./packages/webrtc/package.json').version")"
fi
gh release view "$tag" >/dev/null
gh release upload "$tag" packages/webrtc/prebuild-artifacts/* --clobber
publish:
name: Publish npm packages
if: github.event_name != 'workflow_dispatch' || inputs.publish_npm
runs-on: ubuntu-latest
needs: upload-assets
permissions:
contents: read
id-token: write
timeout-minutes: 20
environment: npm
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }}
- uses: actions/setup-node@v6
with:
node-version: 24
package-manager-cache: false
registry-url: https://registry.npmjs.org
- run: npm ci --ignore-scripts
- name: Publish to npm
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_NPM_TAG: ${{ inputs.npm_tag }}
RELEASE_PRERELEASE: ${{ github.event.release.prerelease }}
run: |
set -euo pipefail
npm_tag="$INPUT_NPM_TAG"
if [ "$EVENT_NAME" != "workflow_dispatch" ]; then
npm_tag="latest"
if [ "$RELEASE_PRERELEASE" = "true" ]; then
npm_tag="next"
fi
fi
npm publish -w @webrtc-node/webrtc --access public --tag "$npm_tag" --provenance
npm publish -w @webrtc-node/media --access public --tag "$npm_tag" --provenance
npm publish -w @webrtc-node/stats --access public --tag "$npm_tag" --provenance