From 56e877ee1eab36df0d9cc4827c2ececf239d5096 Mon Sep 17 00:00:00 2001 From: Compot Developer Date: Sun, 18 Oct 2026 13:59:20 +0000 Subject: [PATCH] ci: run the version check in its own workflow (#66) version.yml runs .github/check-version.sh HEAD^1 on pull requests and is the only workflow that listens to labeled/unlabeled, so adding or removing a label no longer re-runs every build. build.yml goes back to the usual pull request events. The README (three languages) now says that the build workflow counts as build and names the no-release label. --- .github/check-version.sh | 5 +++-- .github/workflows/build.yml | 24 ++++---------------- .github/workflows/version.yml | 42 +++++++++++++++++++++++++++++++++++ README.md | 10 +++++---- README.ru.md | 8 ++++--- README.zh-CN.md | 8 ++++--- 6 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/version.yml diff --git a/.github/check-version.sh b/.github/check-version.sh index 96f5b4a..46b8431 100755 --- a/.github/check-version.sh +++ b/.github/check-version.sh @@ -15,8 +15,9 @@ # leave the release files as they are (a test or publication step in the # workflow, a build-script tidy-up, a comment). # -# Usage: .github/check-version.sh [BASE] (default origin/master; CI passes -# HEAD^1, the base side of the pull request's merge commit) +# Usage: .github/check-version.sh [BASE] (default origin/master; CI, +# .github/workflows/version.yml, passes HEAD^1, the base side of the pull +# request's merge commit; version.yml itself is CI, not build) # set -eu diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b13df7..c1e623e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,8 +7,8 @@ # on x86_64; plus the static musl builds the release ships: x86_64 # (ci/build-static.sh) and soft-float mipsel for OpenWrt routers # (ci/build-mipsel.sh). -# On pull requests, .github/check-version.sh checks that a change to the -# code or the build (this workflow included) comes with a new +# On pull requests, version.yml runs .github/check-version.sh: a change to +# the code or the build (this workflow included) comes with a new # PROGRAM_VERSION and its CHANGELOG.md section; the no-release label lets # a change that keeps the release files as they are through without one. # Only the head of master publishes, so a re-run of an older run never @@ -25,8 +25,6 @@ name: Build on: push: pull_request: - # labeled / unlabeled: the version check reads the no-release label - types: [opened, synchronize, reopened, labeled, unlabeled] workflow_dispatch: # The build only reads the repository and uploads artifacts. @@ -41,22 +39,8 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} jobs: - 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 - - # The checkout is the merge commit; its first parent is the base it was made from. - - name: Code changes come with a new version - env: - # a change that leaves the release files as they are may skip the new version - NO_RELEASE: ${{ contains(github.event.pull_request.labels.*.name, 'no-release') }} - run: .github/check-version.sh HEAD^1 + # The version check of pull requests runs in version.yml: a label change + # re-runs only that check, not the builds. linux: name: Linux ${{ matrix.platform.name }} diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..e11dcf0 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,42 @@ +# +# Copyright (c) OpenIPC https://openipc.org MIT License +# +# version.yml — the version check of pull requests (#42, #64, #66) +# +# A change to the code or the build (build.yml included) comes with a new +# PROGRAM_VERSION (MAJOR.MINOR.PATCH) and its CHANGELOG.md section, unless +# the no-release label says the release files do not change. A workflow of +# its own: adding or removing a label re-runs this check, not the builds. +# + +name: Version + +on: + pull_request: + # labeled / unlabeled: the check reads the no-release label + types: [opened, synchronize, reopened, labeled, unlabeled] + +permissions: + contents: read + +# a newer event of the same pull request cancels the older check +concurrency: + group: version-${{ github.ref }} + cancel-in-progress: true + +jobs: + version: + name: Version bump + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + # The checkout is the merge commit; its first parent is the base it was made from. + - name: Code changes come with a new version + env: + # a change that leaves the release files as they are may skip the new version + NO_RELEASE: ${{ contains(github.event.pull_request.labels.*.name, 'no-release') }} + run: .github/check-version.sh HEAD^1 diff --git a/README.md b/README.md index e350787..bc2399b 100644 --- a/README.md +++ b/README.md @@ -197,10 +197,12 @@ The change history of every version is in [CHANGELOG.md](CHANGELOG.md). Versions are `MAJOR.MINOR.PATCH` (`PROGRAM_VERSION` in `vectis.c`): PATCH for fixes and small changes, MINOR for a new feature, MAJOR for an incompatible change or a large update, only when the maintainer decides. A pull request that changes the code or the build (the -sources, the `Makefile`, `ci/`) raises the version as its last commit before the merge, -together with its `CHANGELOG.md` section. Changes to the docs, tests, screenshots or the -workflows in `.github/` do not. CI checks this on every pull request -(`.github/check-version.sh`). +sources, the `Makefile`, `ci/`, the build workflow `.github/workflows/build.yml`) raises the +version as its last commit before the merge, together with its `CHANGELOG.md` section. +Changes to the docs, tests, screenshots or the other workflows in `.github/` do not; a change +to the code or the build that leaves the release files as they are takes the `no-release` +label instead of a new version. CI checks this on every pull request +(`.github/check-version.sh`, run by `.github/workflows/version.yml`). ## Hardware diff --git a/README.ru.md b/README.ru.md index 6d613e2..2c0d0f4 100644 --- a/README.ru.md +++ b/README.ru.md @@ -200,9 +200,11 @@ ci/build-mipsel.sh Версия — `MAJOR.MINOR.PATCH` (`PROGRAM_VERSION` в `vectis.c`): PATCH — исправления и мелкие правки, MINOR — новая возможность, MAJOR — несовместимое изменение или крупное обновление, только по решению сопровождающего. PR, который меняет код или сборку (исходники, `Makefile`, -`ci/`), поднимает версию последним коммитом перед мержем вместе с её разделом в -`CHANGELOG.md`. Правки документации, тестов, скриншотов и workflow в `.github/` версию не -поднимают. CI проверяет это в каждом PR (`.github/check-version.sh`). +`ci/`, workflow сборки `.github/workflows/build.yml`), поднимает версию последним коммитом +перед мержем вместе с её разделом в `CHANGELOG.md`. Правки документации, тестов, скриншотов и +остальных workflow в `.github/` версию не поднимают; правка кода или сборки, после которой +файлы релиза не меняются, получает метку `no-release` вместо новой версии. CI проверяет это в +каждом PR (`.github/check-version.sh`, его запускает `.github/workflows/version.yml`). ## Оборудование diff --git a/README.zh-CN.md b/README.zh-CN.md index c6d3d74..159ee87 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -188,9 +188,11 @@ ci/build-mipsel.sh 版本号格式为 `MAJOR.MINOR.PATCH`(`vectis.c` 中的 `PROGRAM_VERSION`):PATCH 表示修复和小改动, MINOR 表示新功能,MAJOR 表示不兼容的变更或大规模更新,仅由维护者决定。修改代码或构建 -(源代码、`Makefile`、`ci/`)的 PR 需要在合并前的最后一个提交中提升版本号,并在 -`CHANGELOG.md` 中添加对应章节。仅修改文档、测试、截图或 `.github/` 中工作流的 PR 不提升 -版本号。CI 会在每个 PR 中检查这一点(`.github/check-version.sh`)。 +(源代码、`Makefile`、`ci/`、构建工作流 `.github/workflows/build.yml`)的 PR 需要在合并前的 +最后一个提交中提升版本号,并在 `CHANGELOG.md` 中添加对应章节。仅修改文档、测试、截图或 +`.github/` 中其他工作流的 PR 不提升版本号;修改代码或构建但发布文件不变的 PR 打上 +`no-release` 标签,代替新版本号。CI 会在每个 PR 中检查这一点(`.github/check-version.sh`, +由 `.github/workflows/version.yml` 运行)。 ## 硬件