Skip to content
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
69 changes: 69 additions & 0 deletions .github/scripts/prepare_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
"""Bump the android repository to a new WebRTC release.

prepare_release.py --version 150.7871.08 [--commit <webrtc sha>] \
[--webrtc-repo webrtc-sdk/webrtc] [--date 2026.11.16]

Updates VERSION_NAME in gradle.properties, the dependency versions in
README.md and adds a CHANGES.md entry.
"""

import argparse
import datetime
import os
import re

ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
ARTIFACTS = ['android', 'android-prefixed', 'android-prefixed-stripped']


def sub(path: str, pattern: str, repl: str, count: int = 1, flags=0):
with open(path) as f:
text = f.read()
new, n = re.subn(pattern, repl, text, count=count, flags=flags)
if n == 0:
raise SystemExit(f'{os.path.basename(path)}: pattern not found: {pattern}')
with open(path, 'w', newline='\n') as f:
f.write(new)


def main():
p = argparse.ArgumentParser(description=__doc__.split('\n')[0])
p.add_argument('--version', required=True)
p.add_argument('--commit', default='', help='webrtc commit the binaries were built from')
p.add_argument('--webrtc-repo', default='webrtc-sdk/webrtc')
p.add_argument('--date', default=datetime.date.today().strftime('%Y.%m.%d'))
args = p.parse_args()

v = args.version
# Two-digit patch (150.7871.08, not 150.7871.8), as in webrtc-build.
if not re.fullmatch(r'\d+\.\d+\.(\d{2}|[1-9]\d{2,})', v):
raise SystemExit(f'invalid version {v!r}: expected <milestone>.<branch>.<patch> '
'with a two-digit patch, e.g. 150.7871.08')
path = lambda name: os.path.join(ROOT, name)

# A replayed notification for a release already on this branch (its
# release PR was merged) is a no-op: no file changes means no PR. An
# outstanding release PR is regenerated from the base branch, which does
# not have the version yet, so it is still updated.
with open(path('gradle.properties')) as f:
current = re.search(r'^VERSION_NAME=(.*)$', f.read(), re.M)
with open(path('CHANGES.md')) as f:
logged = re.search(rf'^\[{re.escape(v)}\] - ', f.read(), re.M)
if (current and current.group(1).strip() == v) or logged:
print(f'{v} is already prepared on this branch; nothing to do')
return

sub(path('gradle.properties'), r'^VERSION_NAME=.*$', f'VERSION_NAME={v}', flags=re.M)
for artifact in ARTIFACTS:
sub(path('README.md'), rf"(io\.github\.webrtc-sdk:{re.escape(artifact)}:)[0-9.]+", rf'\g<1>{v}', count=0)

milestone, branch, patch = v.split('.')
entry = f'[{v}] - {args.date}\n\n* Upgrade to WebRTC-SDK M{milestone}.{branch}.{patch}\n\n'
if args.commit:
entry += f'Corresponds to https://github.com/{args.webrtc_repo}/commit/{args.commit}\n\n'
sub(path('CHANGES.md'), r'(-{10,}\n)', rf'\g<1>{entry}')
Comment thread
cloudwebrtc marked this conversation as resolved.
Resolved


if __name__ == '__main__':
main()
79 changes: 79 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: prepare-release

# Opens release/<version> when webrtc-build publishes a release
# (repository_dispatch `webrtc-release`), or by hand. The PR bumps
# VERSION_NAME, README.md and CHANGES.md. Merging it runs release.yml.

on:
repository_dispatch:
types: [webrtc-release]
workflow_dispatch:
inputs:
version:
description: 'Version, e.g. 150.7871.08 (webrtc-build release m<version> must exist)'
required: true

permissions:
contents: write
pull-requests: write

env:
SOURCE_REPO: ${{ github.event.client_payload.source_repo || vars.SOURCE_REPO || 'webrtc-sdk/webrtc-build' }}
VERSION: ${{ github.event.client_payload.version || inputs.version }}

jobs:
open:
runs-on: ubuntu-latest
steps:
# Pushes and PRs made with a GitHub App token trigger workflows (the PR
# checks); GITHUB_TOKEN ones do not. Skipped when the App is not set up.
- name: Create GitHub App token
id: app
if: vars.RELEASE_APP_CLIENT_ID != ''
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
permission-issues: write
- uses: actions/checkout@v5
- name: Bump version
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
TAG="m$VERSION"
ASSETS=$(gh release view "$TAG" -R "$SOURCE_REPO" --json assets --jq '.assets[].name')
for f in libwebrtc.aar libwebrtc_prefixed.aar libwebrtc_prefixed_stripped.aar; do
for a in "$f" "$f.shasum"; do
grep -qx "$a" <<< "$ASSETS" || { echo "::error::$a missing from $SOURCE_REPO $TAG"; exit 1; }
done
done
# Built-from commit: first commit link in the release notes.
NOTES=$(gh release view "$TAG" -R "$SOURCE_REPO" --json body --jq .body)
COMMIT=$(grep -oE '/commit/[0-9a-f]{40}' <<< "$NOTES" | head -1 | cut -d/ -f3 || true)
WEBRTC_REPO=$(grep -oE 'https://github.com/[^/]+/[^/]+/commit/' <<< "$NOTES" | head -1 | cut -d/ -f4,5 || true)
python3 .github/scripts/prepare_release.py --version "$VERSION" --commit "$COMMIT" \
--webrtc-repo "${WEBRTC_REPO:-webrtc-sdk/webrtc}"
{
echo "Release WebRTC Android SDK $VERSION."
echo
echo "Binaries: [$SOURCE_REPO $TAG](https://github.com/$SOURCE_REPO/releases/tag/$TAG) (\`libwebrtc.aar\`, \`libwebrtc_prefixed.aar\`, \`libwebrtc_prefixed_stripped.aar\`)."
echo
echo "Merging publishes the GitHub release v$VERSION and the Maven artifacts."
echo
echo '<details><summary>webrtc changes</summary>'
echo
echo "$NOTES"
echo
echo '</details>'
} > "$RUNNER_TEMP/body.md"
- uses: peter-evans/create-pull-request@v7
with:
token: ${{ steps.app.outputs.token || github.token }}
branch: release/${{ env.VERSION }}
commit-message: 'release: ${{ env.VERSION }}'
title: 'release: ${{ env.VERSION }}'
body-path: ${{ runner.temp }}/body.md
labels: release
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,97 @@
# only publish on version tags
tags:
- v*
# Called by release.yml after it created the v<version> release.
workflow_call:
inputs:
ref:
description: 'Commit to publish'
type: string
required: true

jobs:
# Forks and test copies have no signing/Nexus secrets: skip instead of
# failing, and never publish from them.
check:
runs-on: ubuntu-latest
outputs:
ok: ${{ steps.check.outputs.ok }}
steps:
- id: check
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
SIGNING_KEY_ARMOR: ${{ secrets.SIGNING_KEY_ARMOR }}
run: |
if [ -n "$NEXUS_USERNAME" ] && [ -n "$SIGNING_KEY_ARMOR" ]; then
echo "ok=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::Nexus/signing secrets not set; skipping Maven publish"
fi

publish:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
needs: check
if: needs.check.outputs.ok == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./android
steps:
- name: checkout repo
uses: actions/checkout@v3
with:
path: ./android
ref: ${{ inputs.ref || github.ref }}
submodules: recursive

# Gradle 9.x requires JVM 17 or later to run.
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Download aars
run: |
./downloadAar.sh
./downloadAar_prefixed.sh
./downloadAar_prefixed_stripped.sh

- name: Check required files exist
run: |
test -f "android/libwebrtc.aar"
test -f "android-prefixed/shadow/libs/classes.jar"
test -f "android-prefixed/src/main/jniLibs/arm64-v8a/liblkjingle_peerconnection_so.so"
test -f "android-prefixed/src/main/jniLibs/armeabi-v7a/liblkjingle_peerconnection_so.so"
test -f "android-prefixed/src/main/jniLibs/x86/liblkjingle_peerconnection_so.so"
test -f "android-prefixed/src/main/jniLibs/x86_64/liblkjingle_peerconnection_so.so"
test -f "android-prefixed-stripped/shadow/libs/classes.jar"
test -f "android-prefixed-stripped/src/main/jniLibs/arm64-v8a/liblkjingle_peerconnection_so.so"
test -f "android-prefixed-stripped/src/main/jniLibs/armeabi-v7a/liblkjingle_peerconnection_so.so"
test -f "android-prefixed-stripped/src/main/jniLibs/x86/liblkjingle_peerconnection_so.so"
test -f "android-prefixed-stripped/src/main/jniLibs/x86_64/liblkjingle_peerconnection_so.so"

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Create gpg key and import into gradle properties
run: |
echo $GPG_KEY_ARMOR | base64 --decode > ./release.asc
gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc
sed -i -e "s,nexusUsername=,nexusUsername=$NEXUS_USERNAME,g" gradle.properties
sed -i -e "s,nexusPassword=,nexusPassword=$NEXUS_PASSWORD,g" gradle.properties
sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties
sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties
sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties
sed -i -e "s,STAGING_PROFILE_ID=,STAGING_PROFILE_ID=$STAGING_PROFILE_ID,g" gradle.properties
env:
GPG_KEY_ARMOR: ${{ secrets.SIGNING_KEY_ARMOR }}
GPG_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
GPG_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
STAGING_PROFILE_ID: ${{ secrets.STAGING_PROFILE_ID }}

- name: Assemble
run: ./gradlew assemble

- name: Publish to sonatype
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: release

# Runs when a release/<version> PR is merged: downloads the three aars and
# their .shasum files from the webrtc-build release m<version>, verifies them,
# publishes them as this repository's release v<version>, then runs
# publish.yml (Maven Central), which downloads them from that release.

on:
pull_request:
types: [closed]
branches: [main]
workflow_dispatch:
inputs:
version:
description: 'Version to (re)publish from the default branch'
required: true

permissions:
contents: write

concurrency:
group: release
cancel-in-progress: false
Comment thread
cloudwebrtc marked this conversation as resolved.
Resolved
# Queue every waiting release: by default a newer run cancels the pending
# one, which would leave that merged release unpublished.
queue: max

env:
SOURCE_REPO: ${{ vars.SOURCE_REPO || 'webrtc-sdk/webrtc-build' }}

jobs:
github-release:
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/'))
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.v.outputs.ref }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
- name: Version
id: v
env:
INPUT: ${{ inputs.version || github.event.pull_request.head.ref }}
run: |
set -euo pipefail
VERSION="${INPUT#release/}"
PROP=$(sed -n 's/^VERSION_NAME=//p' gradle.properties)
[ "$PROP" = "$VERSION" ] || { echo "::error::VERSION_NAME $PROP != $VERSION"; exit 1; }
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "ref=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Download and verify aars
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.v.outputs.version }}
run: |
set -euo pipefail
mkdir -p dist && cd dist
for f in libwebrtc.aar libwebrtc_prefixed.aar libwebrtc_prefixed_stripped.aar; do
gh release download "m$VERSION" -R "$SOURCE_REPO" -p "$f" -p "$f.shasum"
done
shasum -a 256 -c *.shasum
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.v.outputs.version }}
run: |
set -euo pipefail
{
echo "WebRTC Android SDK $VERSION, built by [$SOURCE_REPO m$VERSION](https://github.com/$SOURCE_REPO/releases/tag/m$VERSION)."
echo
gh release view "m$VERSION" -R "$SOURCE_REPO" --json body --jq .body
} > "$RUNNER_TEMP/notes.md"
if gh release view "v$VERSION" >/dev/null 2>&1; then
gh release upload "v$VERSION" dist/* --clobber
else
gh release create "v$VERSION" dist/* --target "${{ steps.v.outputs.ref }}" --title "v$VERSION" --notes-file "$RUNNER_TEMP/notes.md"
fi

publish:
needs: github-release
uses: ./.github/workflows/publish.yml
with:
ref: ${{ needs.github-release.outputs.ref }}
secrets: inherit