Skip to content

Commit 0da6660

Browse files
ladvochiroshihorie
andauthored
Release automation (#579)
- Add version and platform compatibility badges from [Swift Package Index](https://swiftpackageindex.com/) to README - Automatically updated on each release - Add [nanpa](https://github.com/nbsp/nanpa) configuration - Custom script bumps version across repo (currently Podspec, README, and LiveKitSDK class) - GitHub publish workflow (based on workflow from livekit/rust-sdks) - Create workflow to push new releases to Cocopods when a release is published on GitHub I have also added changeset files to my currently open PRs (#565, #576, and #573) that can be used to test this configuration. --------- Co-authored-by: Hiroshi Horie <[email protected]>
1 parent 5b031c8 commit 0da6660

File tree

7 files changed

+88
-0
lines changed

7 files changed

+88
-0
lines changed

.github/workflows/bump.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Bump version
2+
on:
3+
workflow_dispatch:
4+
env:
5+
PACKAGE_NAME: client-sdk-swift
6+
jobs:
7+
bump:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
ssh-key: ${{ secrets.NANPA_KEY }}
15+
- uses: nbsp/ilo@v1
16+
with:
17+
packages: ${{ env.PACKAGE_NAME }}

.github/workflows/cocoapods.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Push to Cocoapods
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types: [published]
6+
env:
7+
PODSPEC_FILE: LiveKitClient.podspec
8+
jobs:
9+
build:
10+
runs-on: macos-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Install Cocoapods
14+
run: gem install cocoapods
15+
- name: Validate Podspec
16+
run: pod lib lint --allow-warnings
17+
- name: Publish to CocoaPods
18+
run: pod trunk push ${{ env.PODSPEC_FILE }} --allow-warnings --verbose
19+
env:
20+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

.nanpa/.keep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Add changeset files in this directory.
2+
3+
See nanpa documentation for more info:
4+
https://github.com/nbsp/nanpa/blob/trunk/doc/nanpa-changeset.5.scd

.nanparc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version 2.1.1
2+
name client-sdk-swift
3+
custom ./scripts/replace_version.sh

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
Use this SDK to add realtime video, audio and data features to your Swift app. By connecting to <a href="https://livekit.io/">LiveKit</a> Cloud or a self-hosted server, you can quickly build applications such as multi-modal AI, live streaming, or video calls with just a few lines of code.
1515
<!--END_DESCRIPTION-->
1616

17+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Flivekit%2Fclient-sdk-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/livekit/client-sdk-swift)
18+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Flivekit%2Fclient-sdk-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/livekit/client-sdk-swift)
19+
1720
## Docs & Example app
1821

1922
> [!NOTE]
File renamed without changes.

scripts/replace_version.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
# This script is invoked by nanpa with the new version set in VERSION.
3+
# ed is used instead of sed to make this script POSIX compliant (run on Mac or Linux runner).
4+
5+
if [ -z "${VERSION}" ]; then
6+
echo "Error: VERSION is not set. Exiting..."
7+
exit 1
8+
fi
9+
10+
replace() {
11+
ed -s "$1" >/dev/null
12+
if [ $? -ne 0 ]; then
13+
echo "Error: unable to replace version in $1" >&2
14+
exit 1
15+
fi
16+
}
17+
18+
# 1. Podspec version & tag
19+
# -----------------------------------------
20+
replace ./LiveKitClient.podspec <<EOF
21+
,s/spec.version = "[^"]*"/spec.version = "${VERSION}"/g
22+
,s/:tag => "[^"]*"/:tag => "${VERSION}"/g
23+
w
24+
q
25+
EOF
26+
27+
# 2. README.md, installation guide
28+
# -----------------------------------------
29+
replace ./README.md <<EOF
30+
,s/upToNextMajor("[^"]*")/upToNextMajor("${VERSION}")/g
31+
w
32+
q
33+
EOF
34+
35+
# 3. LiveKitSDK class, static version constant
36+
# -----------------------------------------
37+
replace ./Sources/LiveKit/LiveKit.swift <<EOF
38+
,s/static let version = "[^"]*"/static let version = "${VERSION}"/g
39+
w
40+
q
41+
EOF

0 commit comments

Comments
 (0)