From fe503394b1409dd3c27280fc7d35afe25957226c Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Mon, 16 Nov 2026 14:22:48 +0800 Subject: [PATCH 1/4] Automate releases from webrtc-build prepare-release opens release/ when webrtc-build publishes a release (repository_dispatch webrtc-release) or by hand; release publishes the GitHub release from the merged PR with the verified binaries and their .shasum files. --- .github/scripts/prepare_release.py | 55 ++++++++++++++++++ .github/workflows/prepare-release.yml | 67 +++++++++++++++++++++ .github/workflows/publish.yml | 28 +++++++++ .github/workflows/release.yml | 84 +++++++++++++++++++++++++++ 4 files changed, 234 insertions(+) create mode 100644 .github/scripts/prepare_release.py create mode 100644 .github/workflows/prepare-release.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/scripts/prepare_release.py b/.github/scripts/prepare_release.py new file mode 100644 index 0000000..034aeb8 --- /dev/null +++ b/.github/scripts/prepare_release.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +"""Bump the android repository to a new WebRTC release. + + prepare_release.py --version 150.7871.08 [--commit ] \ + [--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 + if not re.fullmatch(r'\d+\.\d+\.\d+', v): + raise SystemExit(f'invalid version {v!r}') + path = lambda name: os.path.join(ROOT, name) + + 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}') + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..1a5074e --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,67 @@ +name: prepare-release + +# Opens release/ 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 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: + - 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 '
webrtc changes' + echo + echo "$NOTES" + echo + echo '
' + } > "$RUNNER_TEMP/body.md" + - uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.RELEASE_TOKEN || github.token }} + branch: release/${{ env.VERSION }} + commit-message: 'release: ${{ env.VERSION }}' + title: 'release: ${{ env.VERSION }}' + body-path: ${{ runner.temp }}/body.md + labels: release diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6d8b07c..4cb8091 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,9 +5,36 @@ on: # only publish on version tags tags: - v* + # Called by release.yml after it created the v 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: + needs: check + if: needs.check.outputs.ok == 'true' runs-on: ubuntu-latest defaults: run: @@ -17,6 +44,7 @@ jobs: uses: actions/checkout@v3 with: path: ./android + ref: ${{ inputs.ref || github.ref }} submodules: recursive # Gradle 9.x requires JVM 17 or later to run. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9c82a00 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,84 @@ +name: release + +# Runs when a release/ PR is merged: downloads the three aars and +# their .shasum files from the webrtc-build release m, verifies them, +# publishes them as this repository's release v, 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 + +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 From dea825be37d23561ae9d1e513080e01a5ee59c7c Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Mon, 16 Nov 2026 19:27:25 +0800 Subject: [PATCH 2/4] prepare-release: open the release PR with a GitHub App token --- .github/workflows/prepare-release.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 1a5074e..74a14c3 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -25,6 +25,18 @@ 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: @@ -59,7 +71,7 @@ jobs: } > "$RUNNER_TEMP/body.md" - uses: peter-evans/create-pull-request@v7 with: - token: ${{ secrets.RELEASE_TOKEN || github.token }} + token: ${{ steps.app.outputs.token || github.token }} branch: release/${{ env.VERSION }} commit-message: 'release: ${{ env.VERSION }}' title: 'release: ${{ env.VERSION }}' From fdc2ccda86c35aa7592617898e1d1b73660df22c Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Thu, 19 Nov 2026 09:32:36 +0800 Subject: [PATCH 3/4] release: queue pending release runs By default a newer run in the release concurrency group cancels the pending one, which would leave that merged release unpublished. queue: max keeps every waiting run (cancel-in-progress stays false). --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c82a00..745d728 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,9 @@ permissions: concurrency: group: release cancel-in-progress: false + # 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' }} From ab83c7e9418941c558a0707306deb8dab4b1a29a Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Thu, 19 Nov 2026 09:32:36 +0800 Subject: [PATCH 4/4] prepare-release: skip versions already prepared; require a two-digit patch A replayed webrtc-release notification for a release whose PR was already merged added a second CHANGES.md entry and opened a new PR for the same version. Leave the files unchanged when VERSION_NAME already matches or CHANGES.md has the entry, so no PR is opened. Outstanding release PRs are regenerated from the base branch and still update. Also require a two-digit patch, as in webrtc-build. --- .github/scripts/prepare_release.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/scripts/prepare_release.py b/.github/scripts/prepare_release.py index 034aeb8..2f2e920 100644 --- a/.github/scripts/prepare_release.py +++ b/.github/scripts/prepare_release.py @@ -36,10 +36,24 @@ def main(): args = p.parse_args() v = args.version - if not re.fullmatch(r'\d+\.\d+\.\d+', v): - raise SystemExit(f'invalid version {v!r}') + # 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 .. ' + '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)