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
176 changes: 176 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Release

on:
workflow_run:
workflows: [CI]
types: [completed]
workflow_dispatch:
inputs:
tag:
description: Existing incubating tag to publish
required: true
type: string

concurrency:
group: release-${{ github.event.workflow_run.head_branch || inputs.tag }}
cancel-in-progress: false

permissions:
actions: read
contents: write
id-token: write
packages: write

jobs:
publish:
if: >-
github.event_name == 'workflow_dispatch' ||
(
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'v') &&
contains(github.event.workflow_run.head_branch, '-incubating.')
)
runs-on: ubuntu-24.04
env:
RELEASE_TAG: >-
${{ github.event.workflow_run.head_branch || inputs.tag }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ env.RELEASE_TAG }}
fetch-depth: 0

- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "17"

- uses: actions/setup-node@v7
with:
node-version: "24"
registry-url: https://npm.pkg.github.com
scope: "@oxyroid"
cache: npm
cache-dependency-path: web-sdk/package-lock.json

- name: Verify tag and CI
env:
GH_TOKEN: ${{ github.token }}
CI_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
git show-ref --verify --quiet "refs/tags/$RELEASE_TAG"
tag_sha="$(git rev-list -n 1 "$RELEASE_TAG")"
if [[ -n "$CI_HEAD_SHA" ]]; then
[[ "$tag_sha" == "$CI_HEAD_SHA" ]]
elif ! gh run list \
--workflow ci.yml \
--branch "$RELEASE_TAG" \
--event push \
--status success \
--limit 20 \
--json headSha \
--jq ".[] | select(.headSha == \"$tag_sha\")" |
grep -q .; then
echo "No successful CI run found for $RELEASE_TAG" >&2
exit 1
fi
./scripts/verify-release-tag.sh "$RELEASE_TAG"

- name: Build release artifacts
run: |
release_version="${RELEASE_TAG#v}"
mkdir -p build/release
./gradlew :android-sdk:assembleRelease
cp android-sdk/build/outputs/aar/android-sdk-release.aar \
"build/release/pixdot-android-$release_version.aar"
(
cd web-sdk
npm ci
npm exec -- tsc -p tsconfig.json
npm pack --pack-destination ../build/release
)
tar \
--transform "s,^,pixdot-core-$release_version/," \
-czf "build/release/pixdot-core-$release_version.tar.gz" \
CMakeLists.txt LICENSE cmake core

- name: Publish Android package
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
run: |
release_version="${RELEASE_TAG#v}"
pom_url="https://maven.pkg.github.com/$GITHUB_REPOSITORY/io/github/oxyroid/pixdot-android/$release_version/pixdot-android-$release_version.pom"
if curl --fail --silent \
--user "$GITHUB_ACTOR:$GITHUB_TOKEN" \
"$pom_url" >/dev/null; then
echo "Android package $release_version already exists"
else
./gradlew :android-sdk:publishReleasePublicationToGitHubPackagesRepository
fi

- name: Publish Web package to GitHub Packages
env:
NODE_AUTH_TOKEN: ${{ github.token }}
run: |
release_version="${RELEASE_TAG#v}"
package="@oxyroid/pixdot@$release_version"
if npm view "$package" version \
--registry https://npm.pkg.github.com >/dev/null 2>&1; then
echo "Web package $release_version already exists"
else
npm publish \
"build/release/oxyroid-pixdot-$release_version.tgz" \
--tag incubating
fi

- uses: actions/setup-node@v7
if: ${{ env.NPM_TOKEN != '' }}
with:
node-version: "24"
registry-url: https://registry.npmjs.org
scope: "@oxyroid"

- name: Publish Web package to npmjs
if: ${{ env.NPM_TOKEN != '' }}
env:
NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }}
run: |
release_version="${RELEASE_TAG#v}"
package="@oxyroid/pixdot@$release_version"
if npm view "$package" version \
--registry https://registry.npmjs.org >/dev/null 2>&1; then
echo "Web package $release_version already exists on npmjs"
else
npm publish \
"build/release/oxyroid-pixdot-$release_version.tgz" \
--registry https://registry.npmjs.org \
--tag incubating \
--access public \
--provenance
fi

- name: Create GitHub prerelease
env:
GH_TOKEN: ${{ github.token }}
run: |
release_version="${RELEASE_TAG#v}"
(
cd build/release
sha256sum \
"pixdot-android-$release_version.aar" \
"oxyroid-pixdot-$release_version.tgz" \
"pixdot-core-$release_version.tar.gz" \
> SHA256SUMS
)
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" build/release/* --clobber
else
gh release create "$RELEASE_TAG" \
build/release/* \
--generate-notes \
--prerelease \
--title "PixDot Protocol $release_version"
fi
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A portable protocol library and BLE SDKs for compatible smart bead boards.
> [!IMPORTANT]
> This project is incubating. Protocol coverage and public APIs may change
> before the first stable release. Incubating builds use prerelease tags such
> as `v0.3.0-incubating.1`.
> as `v0.3.0-incubating.2`.

## Packages

Expand All @@ -20,6 +20,12 @@ A portable protocol library and BLE SDKs for compatible smart bead boards.
- `@oxyroid/pixdot`: Web Bluetooth transport backed by the C core through WASM.
- [Protocol reference](docs/protocol.md)

## Releases

Incubating releases provide the Android AAR, Web npm tarball, portable C core
and checksums on [GitHub Releases](https://github.com/oxyroid/pixdot-protocol/releases).
Android and Web packages are also published to GitHub Packages after CI passes.

## Architecture

`core` is the only protocol implementation. It owns packet encoding, CRC,
Expand Down
8 changes: 7 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

> [!IMPORTANT]
> 本项目仍在孵化,首个稳定版本发布前,协议覆盖范围和公开 API 可能调整。
> 孵化版本使用 `v0.3.0-incubating.1` 形式的预发布 tag。
> 孵化版本使用 `v0.3.0-incubating.2` 形式的预发布 tag。

## 组件

Expand All @@ -19,6 +19,12 @@
- `@oxyroid/pixdot`:通过 WASM 使用 C Core 的 Web Bluetooth 传输层。
- [协议参考](docs/protocol.zh-CN.md)

## 发布产物

孵化版本会在 [GitHub Releases](https://github.com/oxyroid/pixdot-protocol/releases)
提供 Android AAR、Web npm 压缩包、可移植 C Core 与校验和。CI 通过后也会将
Android 和 Web 包发布到 GitHub Packages。

## 架构

`core` 是唯一的协议实现,负责数据包编码、CRC、分帧与响应解析。Android、
Expand Down
12 changes: 10 additions & 2 deletions android-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ The library manifest declares the required BLE permissions. The caller must
grant the permissions applicable to the device's Android version before using
the scanner or client.

## Add the AAR
## Add the SDK

Build the release artifact:
Download `pixdot-android-0.3.0-incubating.2.aar` from the
[incubating release](https://github.com/oxyroid/pixdot-protocol/releases/tag/v0.3.0-incubating.2),
or use `io.github.oxyroid:pixdot-android:0.3.0-incubating.2` from the repository:

```text
https://maven.pkg.github.com/oxyroid/pixdot-protocol
```

To build the AAR locally:

```sh
ANDROID_HOME=/path/to/android-sdk ./gradlew :android-sdk:assembleRelease
Expand Down
12 changes: 10 additions & 2 deletions android-sdk/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@
库清单已声明 BLE 所需权限。调用扫描器或客户端前,调用方须授予当前
Android 版本适用的权限。

## 添加 AAR
## 添加 SDK

构建 release 产物:
从[孵化版本](https://github.com/oxyroid/pixdot-protocol/releases/tag/v0.3.0-incubating.2)
下载 `pixdot-android-0.3.0-incubating.2.aar`,或从以下仓库使用
`io.github.oxyroid:pixdot-android:0.3.0-incubating.2`:

```text
https://maven.pkg.github.com/oxyroid/pixdot-protocol
```

本地构建 AAR:

```sh
ANDROID_HOME=/path/to/android-sdk ./gradlew :android-sdk:assembleRelease
Expand Down
15 changes: 14 additions & 1 deletion android-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "io.github.oxyroid"
version = "0.3.0-incubating.1"
version = "0.3.0-incubating.2"

android {
namespace = "io.github.oxyroid.pixdot"
Expand Down Expand Up @@ -56,6 +56,19 @@ dependencies {
testImplementation("junit:junit:4.13.2")
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/oxyroid/pixdot-protocol")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: "github"
password = System.getenv("GITHUB_TOKEN") ?: ""
}
}
}
}

afterEvaluate {
publishing {
publications {
Expand Down
2 changes: 1 addition & 1 deletion ios-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The Swift package provides scanning, CoreBluetooth transport and `async/await`
commands. Protocol operations run in the repository's C core.

> This SDK is incubating. Pin `v0.3.0-incubating.1` when adding the package.
> This SDK is incubating. Pin `v0.3.0-incubating.2` when adding the package.

## Add the package

Expand Down
2 changes: 1 addition & 1 deletion ios-sdk/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Swift Package 提供设备扫描、CoreBluetooth 传输和 `async/await` 命令。协议操作
由仓库中的 C Core 执行。

> SDK 仍在孵化,添加 Package 时请固定到 `v0.3.0-incubating.1`。
> SDK 仍在孵化,添加 Package 时请固定到 `v0.3.0-incubating.2`。

## 添加 Package

Expand Down
36 changes: 36 additions & 0 deletions scripts/verify-release-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -euo pipefail

release_tag="${1:-}"
if [[ ! "$release_tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+-incubating\.[0-9]+)$ ]]; then
echo "Invalid incubating release tag: $release_tag" >&2
exit 1
fi

release_version="${BASH_REMATCH[1]}"
native_version="${release_version%%-*}"
android_version="$(
sed -n 's/^version = "\(.*\)"/\1/p' android-sdk/build.gradle.kts
)"
web_version="$(node -p "require('./web-sdk/package.json').version")"
cmake_version="$(
sed -nE \
's/^project\(PixDotProtocol VERSION ([0-9]+\.[0-9]+\.[0-9]+).*$/\1/p' \
CMakeLists.txt
)"

[[ "$android_version" == "$release_version" ]] || {
echo "Android version $android_version does not match $release_version" >&2
exit 1
}
[[ "$web_version" == "$release_version" ]] || {
echo "Web version $web_version does not match $release_version" >&2
exit 1
}
[[ "$cmake_version" == "$native_version" ]] || {
echo "CMake version $cmake_version does not match $native_version" >&2
exit 1
}

echo "Release versions match $release_tag"
6 changes: 6 additions & 0 deletions web-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ The SDK requires a browser with Web Bluetooth and a secure context. The target
GATT service UUID is required because browsers only expose services declared
during device selection.

## Install

```sh
npm install https://github.com/oxyroid/pixdot-protocol/releases/download/v0.3.0-incubating.2/oxyroid-pixdot-0.3.0-incubating.2.tgz
```

## Connect

```ts
Expand Down
6 changes: 6 additions & 0 deletions web-sdk/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Bluetooth 传输和类型化 API 绑定。
SDK 需要支持 Web Bluetooth 的浏览器和安全上下文。连接时必须提供目标 GATT
service UUID,因为浏览器只会开放设备选择阶段声明的 service。

## 安装

```sh
npm install https://github.com/oxyroid/pixdot-protocol/releases/download/v0.3.0-incubating.2/oxyroid-pixdot-0.3.0-incubating.2.tgz
```

## 连接

```ts
Expand Down
4 changes: 2 additions & 2 deletions web-sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oxyroid/pixdot",
"version": "0.3.0-incubating.1",
"version": "0.3.0-incubating.2",
"description": "Web Bluetooth SDK for PixDot smart bead boards",
"type": "module",
"sideEffects": false,
Expand Down