Skip to content

Commit 82cd3bd

Browse files
authored
Merge pull request #241 from OpenIPC/version-check-workflow
ci: the build workflow counts as build; a no-release label skips the version (#239)
2 parents 5b57504 + 70c051d commit 82cd3bd

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

‎.github/check-version.sh‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
# but not versionName in android/app/build.gradle. A new version must be
55
# MAJOR.MINOR.PATCH without leading zeros, greater than the base one, and
66
# have its section in CHANGELOG.md ("## <version> — YYYY-MM-DD") that the
7-
# base branch does not have yet. android/ counts as app or build (its unit
8-
# tests in android/app/src/test do not); docs, screenshots and the
9-
# workflows in .github/ need no new version. The format is checked only
10-
# when the version changes, so the 2.xx versions before MAJOR.MINOR.PATCH
11-
# stay valid until the next app change.
7+
# base branch does not have yet. android/ (without its unit tests in
8+
# android/app/src/test and its Markdown files) and the build workflow
9+
# .github/workflows/build.yml count as app or build: the workflow holds
10+
# build steps too, and the script cannot tell them from the others. Docs,
11+
# screenshots and the rest of .github/ need no new version.
12+
# NO_RELEASE=true (the pull request's `no-release` label) lets a change to
13+
# the app or the build through without a new version, for changes that
14+
# leave the APKs as they are (a test or publication step in the workflow,
15+
# a comment). The format is checked only when the version changes, so the
16+
# 2.xx versions before MAJOR.MINOR.PATCH stay valid until the next app
17+
# change.
1218
#
1319
# Usage: .github/check-version.sh [BASE] (default origin/v2; CI passes
1420
# HEAD^1, the base side of the pull request's merge commit)
@@ -33,9 +39,16 @@ ver() {
3339
new=$(ver HEAD < "$gradle")
3440
old=$(git show "$base:$gradle" | ver "$base")
3541

36-
changed=$(git diff --name-only "$base"...HEAD -- android ':(exclude)android/app/src/test')
42+
changed=$(git diff --name-only "$base"...HEAD -- android .github/workflows/build.yml \
43+
':(exclude)android/app/src/test' ':(exclude,glob)**/*.md')
3744

3845
if [ "$new" = "$old" ]; then
46+
if [ -n "$changed" ] && [ "${NO_RELEASE:-}" = true ]; then
47+
echo "::notice::the app or its build changed, versionName stays $old: the no-release" \
48+
"label says the APKs do not change"
49+
echo "$changed"
50+
exit 0
51+
fi
3952
if [ -n "$changed" ]; then
4053
echo "::error::the app or its build changed, versionName is still $old:" \
4154
"bump PATCH (fix) or MINOR (feature) and add its CHANGELOG.md section"

‎.github/workflows/build.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build
22
on:
33
push:
44
pull_request:
5+
# labeled / unlabeled: the version check reads the no-release label
6+
types: [opened, synchronize, reopened, labeled, unlabeled]
57
workflow_dispatch:
68
inputs:
79
commit_hash:
@@ -24,8 +26,9 @@ permissions:
2426
contents: read
2527

2628
jobs:
27-
# Pull requests: a change to the app or its build comes with a new versionName
28-
# (MAJOR.MINOR.PATCH) and its CHANGELOG.md section (.github/check-version.sh, #230)
29+
# Pull requests: a change to the app or its build (android/, this workflow) comes with a new
30+
# versionName (MAJOR.MINOR.PATCH) and its CHANGELOG.md section (.github/check-version.sh, #230);
31+
# the no-release label lets a change that keeps the APKs as they are through without one (#239)
2932
version:
3033
# basic keeps its own workflow and version file (app/build.gradle)
3134
if: github.event_name == 'pull_request' && github.base_ref == 'v2'
@@ -40,6 +43,9 @@ jobs:
4043
# base it was made from, so both versions come from the same base.
4144
- name: App changes come with a new version
4245
run: .github/check-version.sh HEAD^1
46+
env:
47+
# a change that leaves the APKs as they are may skip the new version
48+
NO_RELEASE: ${{ contains(github.event.pull_request.labels.*.name, 'no-release') }}
4349

4450
# Unit tests and lint; also runs for pull requests from forks (no secrets needed)
4551
test:

‎docs/testing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ CI is the reference: the project does not depend on local builds.
4747

4848
## Versions and releases
4949

50-
- Versions are **`MAJOR.MINOR.PATCH`** (`versionName` in `android/app/build.gradle`): 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. Every pull request that changes the app or its build (`android/`, except the unit tests) bumps the version as its last commit before the merge: `versionName` by that rule and `versionCode` +1. Docs-only, test-only and CI-only pull requests do not. Numbers are not reserved for open pull requests: each one takes the next number when it is merged. CI checks this on every pull request (`.github/check-version.sh`): a new number must be canonical (no leading zeros), greater than the base one, and come with its own `CHANGELOG.md` section.
50+
- Versions are **`MAJOR.MINOR.PATCH`** (`versionName` in `android/app/build.gradle`): 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. Every pull request that changes the app or its build (`android/`, except the unit tests and Markdown files, and `.github/workflows/build.yml`, which holds build steps) bumps the version as its last commit before the merge: `versionName` by that rule and `versionCode` +1. Docs-only and test-only pull requests do not. A pull request that changes the app or the build but not the APKs (a test or publication step in the workflow, a comment) takes the `no-release` label instead and keeps the version. Numbers are not reserved for open pull requests: each one takes the next number when it is merged. CI checks this on every pull request (`.github/check-version.sh`): a new number must be canonical (no leading zeros), greater than the base one, and come with its own `CHANGELOG.md` section.
5151
- Until 2.17 `v2` counted **2.xx** (+0.01 per pull request); 2.17 is followed by 2.17.1 or 2.18.0. `basic` keeps its 1.7.x line (1.07.1 is 1.7.1).
5252
- **`CHANGELOG.md`** is the change history: the version bump commit of a pull request that changes the app adds the version's section (`## <version> — <date>`, newest first) in the same pull request.
5353
- Development is continuous, so there is **no release per version** (#194). The one release, [`latest`](https://github.com/OpenIPC/decoder/releases/latest), holds the newest `v2` and `basic` builds and is updated in place by both (`.github/publish-latest.sh`, #229): each branch replaces only its own files; a `v2` build moves the `latest` tag to the commit it built and sets the title `Decoder <version>`; the notes have one line per branch with its version and commit. Every **new version** (not every build) of `v2` and `basic` is posted to the OpenIPC Telegram channel, where the older builds can be found. Builds of other branches are only workflow artifacts of their runs (90 days).

0 commit comments

Comments
 (0)