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
65 changes: 65 additions & 0 deletions .github/check-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/sh
#
# Copyright (c) OpenIPC https://openipc.org MIT License
#
# check-version.sh — fail a pull request that changes code or the build
# but not CAMEX_VERSION in src/version.h (#63). The new version must be
# MAJOR.MINOR.PATCH without leading zeros, greater than the base one,
# and have its section in CHANGELOG.md ("## <version> — <date>").
# src/, android/, the Makefile, ci/ and scripts/ count as code or build;
# docs, tests, screenshots and the workflows in .github/ do not need a new
# version. Same script as OpenIPC/vectis, other paths and version macro.
#
# Usage: .github/check-version.sh [BASE] (default origin/master)
#

set -eu

base=${1:-origin/master}
code="src android Makefile ci scripts"

ver() { sed -n 's/^#define CAMEX_VERSION *"\(.*\)"/\1/p'; }

new=$(ver < src/version.h)
old=$(git show "$base:src/version.h" | ver)

if ! echo "$new" | grep -Eq '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'; then
echo "::error::CAMEX_VERSION \"$new\" is not MAJOR.MINOR.PATCH"
exit 1
fi

# shellcheck disable=SC2086 # $code is a list of paths
changed=$(git diff --name-only "$base"...HEAD -- $code)

if [ "$new" = "$old" ]; then
if [ -n "$changed" ]; then
echo "::error::code or build changed, CAMEX_VERSION is still $old:" \
"bump PATCH (fix) or MINOR (feature) and add its CHANGELOG.md section"
echo "$changed"
exit 1
fi
echo "version $new unchanged, no code or build changes"
exit 0
fi

top=$(printf '%s\n%s\n' "$old" "$new" | sort -V | tail -n 1)
if [ "$top" != "$new" ]; then
echo "::error::CAMEX_VERSION $new is not greater than $old"
exit 1
fi

# $new is digits and dots only (checked above): escape the dots, require a date.
re=$(printf '%s' "$new" | sed 's/\./\\./g')
if ! grep -Eq "^## $re — [0-9]{4}-[0-9]{2}-[0-9]{2}\$" CHANGELOG.md; then
echo "::error::CHANGELOG.md has no section \"## $new — YYYY-MM-DD\""
exit 1
fi

# The section must come with this pull request, not be one the base
# branch already has (a version taken from there brings no notes).
if git show "$base:CHANGELOG.md" 2>/dev/null | grep -Eq "^## $re — "; then
echo "::error::the section \"## $new\" is already on $base: take a new version"
exit 1
fi

echo "version $old -> $new, CHANGELOG.md section found"
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ env:
# actions target Node 24 natively (checkout@v5, upload-artifact@v5, download-artifact@v5, gh-release@v3)

jobs:
# ---------------------------------------------------------------- version
# Pull requests: a change to the code or the build comes with a new
# CAMEX_VERSION (MAJOR.MINOR.PATCH) and its CHANGELOG.md section (#63)
version:
name: Version bump
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Code changes come with a new version
env:
# through the environment, not pasted into the script
BASE: ${{ github.base_ref }}
run: .github/check-version.sh "origin/$BASE"

# ------------------------------------------------------------------ linux
linux:
name: Linux ${{ matrix.target }} (musl static)
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,22 @@ The Android `versionName` and `versionCode` follow it: `scripts/sync-android-ver
(or `make apk`, which calls it) updates `android/app/build.gradle.kts` and
`android/app/src/main/AndroidManifest.xml`.

### When to bump

`CAMEX_VERSION` is `MAJOR.MINOR.PATCH`, numbers without leading zeros:

- **PATCH** — fixes and small changes; **MINOR** — a new feature (option, config field,
protocol, platform); **MAJOR** — an incompatible change (arguments, config format,
protocol, default behaviour), only when the maintainer decides.
- A pull request that changes the code or the build (`src/`, `android/`, `Makefile`,
`ci/`, `scripts/`) bumps the version as its last commit before the merge and adds
its `## X.Y.Z — YYYY-MM-DD` section to `CHANGELOG.md`. Pull requests with only docs,
tests, screenshots or workflows in `.github/` do not.
- CI checks this on every pull request (`.github/check-version.sh`, job "Version
bump"): the new version must be well-formed, greater than the one on `master` and
have its new `CHANGELOG.md` section. Until the bump commit is pushed, the check is
red by design.

### Release process

There are no version tags and no versioned releases: one release, `latest`, is
Expand Down
16 changes: 16 additions & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,22 @@ sudo rmmod camex
(или `make apk`, который его вызывает) обновляет `android/app/build.gradle.kts` и
`android/app/src/main/AndroidManifest.xml`.

### Когда поднимать версию

`CAMEX_VERSION` — `MAJOR.MINOR.PATCH`, числа без ведущих нулей:

- **PATCH** — исправления и мелкие правки; **MINOR** — новая возможность (опция, поле
конфигурации, протокол, платформа); **MAJOR** — несовместимое изменение (аргументы,
формат конфигурации, протокол, поведение по умолчанию), только по решению мейнтейнера.
- Pull request, который меняет код или сборку (`src/`, `android/`, `Makefile`, `ci/`,
`scripts/`), последним коммитом перед мержем поднимает версию и добавляет в
`CHANGELOG.md` её раздел `## X.Y.Z — YYYY-MM-DD`. Pull request только с документацией,
тестами, скриншотами или workflow в `.github/` версию не поднимает.
- CI проверяет это в каждом pull request (`.github/check-version.sh`, job «Version
bump»): новая версия должна быть правильного вида, больше версии в `master` и иметь
новый раздел в `CHANGELOG.md`. Пока коммит с версией не запушен, проверка красная —
так и задумано.

### Процесс релиза

Тегов версий и релизов по версиям нет: один релиз, `latest`, CI заменяет после
Expand Down
14 changes: 14 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,20 @@ Android 的 `versionName` 和 `versionCode` 随之变化:`scripts/sync-android
(或调用它的 `make apk`)会更新 `android/app/build.gradle.kts` 和
`android/app/src/main/AndroidManifest.xml`。

### 何时提升版本号

`CAMEX_VERSION` 为 `MAJOR.MINOR.PATCH`,各数字不带前导零:

- **PATCH** —— 修复和小改动;**MINOR** —— 新功能(选项、配置字段、协议、平台);
**MAJOR** —— 不兼容的变更(参数、配置格式、协议、默认行为),仅由维护者决定。
- 修改代码或构建(`src/`、`android/`、`Makefile`、`ci/`、`scripts/`)的 pull request,
在合并前的最后一个提交中提升版本号,并在 `CHANGELOG.md` 中添加
`## X.Y.Z — YYYY-MM-DD` 章节。只涉及文档、测试、截图或 `.github/` 中工作流的
pull request 不提升版本号。
- CI 会在每个 pull request 中检查这一点(`.github/check-version.sh`,job
“Version bump”):新版本号格式必须正确、大于 `master` 上的版本,并带有新的
`CHANGELOG.md` 章节。在推送提升版本号的提交之前,该检查为红色,这是预期行为。

### 发布流程

没有版本标签,也没有按版本的发布:只有一个发布 `latest`,每次推送到 `master`
Expand Down
Loading