Skip to content

Commit 600ef4b

Browse files
authored
Merge pull request #349 from WISE-Developers/dev
Promote dev → main: versioning scheme now patch-on-dev, minor-on-main (#348)
2 parents 94874e1 + f8591d1 commit 600ef4b

6 files changed

Lines changed: 65 additions & 84 deletions

File tree

.github/dev-build-count

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/scripts/determine-bump.sh

Lines changed: 32 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
#!/bin/bash
22
# determine-bump.sh <pr_number>
3-
# Scans commits in a PR for issue references, checks GitHub issue labels,
4-
# and returns the appropriate semver bump level.
3+
# Returns the semver bump level for a merge into main.
54
#
6-
# Returns: patch | minor | major
5+
# Returns: minor | major
76
#
8-
# Logic:
9-
# 1. PR has label "release:major" → major
10-
# 2. Any referenced issue has label "feature" or "enhancement" → minor
11-
# 3. Otherwise → patch (default, safe)
7+
# Versioning scheme (#348):
8+
# - Changes on dev bump PATCH (handled by dev-release.yml, not here)
9+
# - A PR merged into main bumps MINOR — that is what a release is
10+
# - Unless the PR carries the label "release:major", which bumps MAJOR
1211
#
13-
# Required env vars: GH_TOKEN, PR_LABELS (JSON array), REPO
12+
# The patch digit therefore counts changes accumulated during development
13+
# (0.5.13 = thirteen changes on the 0.5.x line) and the minor digit identifies
14+
# the release.
15+
#
16+
# Previously this read the labels of every issue referenced in the PR's commit
17+
# messages and returned minor for "feature"/"enhancement", patch otherwise. That
18+
# made the released version depend on issue labelling rather than on the release
19+
# itself, and produced v0.13.1 where v0.14.0 was meant.
20+
#
21+
# Required env vars: GH_TOKEN, REPO
1422
set -euo pipefail
1523

1624
PR_NUMBER="${1:-}"
17-
if [[ -z "$PR_NUMBER" ]]; then
18-
echo "patch"
19-
exit 0
20-
fi
2125

2226
if [[ -z "${GH_TOKEN:-}" ]]; then
2327
echo "ERROR: GH_TOKEN environment variable required" >&2
@@ -29,56 +33,30 @@ if [[ -z "${REPO:-}" ]]; then
2933
exit 1
3034
fi
3135

32-
# Step 1: Check for manual major override via PR label
33-
if echo "${PR_LABELS:-[]}" | grep -q '"release:major"'; then
34-
echo "major"
36+
# No PR found (e.g. a direct push to main). A release is still a release, so
37+
# minor remains the correct level.
38+
if [[ -z "$PR_NUMBER" ]]; then
39+
echo "minor"
3540
exit 0
3641
fi
3742

38-
# Step 2: Get commits from this PR via GitHub API
39-
COMMITS_JSON=$(curl -sf \
43+
# Read the PR's own labels. This used to consult $PR_LABELS, which
44+
# stable-release.yml never set — so the major override could never fire.
45+
LABELS_JSON=$(curl -sf \
4046
-H "Authorization: Bearer $GH_TOKEN" \
4147
-H "Accept: application/vnd.github.v3+json" \
42-
"https://api.github.com/repos/${REPO}/pulls/${PR_NUMBER}/commits?per_page=100" \
43-
|| echo "[]")
48+
"https://api.github.com/repos/${REPO}/pulls/${PR_NUMBER}" \
49+
|| echo '{"labels":[]}')
4450

45-
# Step 3: Extract all #NNN issue references from commit messages
46-
ISSUE_NUMBERS=$(echo "$COMMITS_JSON" | \
51+
HAS_MAJOR=$(echo "$LABELS_JSON" | \
4752
node -e "
4853
const data = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8'));
49-
const msgs = data.map(c => c.commit.message).join(' ');
50-
const matches = msgs.match(/#(\d+)/g) || [];
51-
const unique = [...new Set(matches.map(m => m.slice(1)))];
52-
unique.forEach(n => console.log(n));
54+
const labels = (data.labels || []).map(l => l.name);
55+
console.log(labels.includes('release:major') ? 'yes' : 'no');
5356
")
5457

55-
if [[ -z "$ISSUE_NUMBERS" ]]; then
56-
echo "patch"
57-
exit 0
58+
if [[ "$HAS_MAJOR" == "yes" ]]; then
59+
echo "major"
60+
else
61+
echo "minor"
5862
fi
59-
60-
# Step 4: Check labels on each referenced issue
61-
BUMP_LEVEL="patch"
62-
63-
for ISSUE_NUM in $ISSUE_NUMBERS; do
64-
LABELS_JSON=$(curl -sf \
65-
-H "Authorization: Bearer $GH_TOKEN" \
66-
-H "Accept: application/vnd.github.v3+json" \
67-
"https://api.github.com/repos/${REPO}/issues/${ISSUE_NUM}" \
68-
|| echo '{"labels":[]}')
69-
70-
HAS_FEATURE=$(echo "$LABELS_JSON" | \
71-
node -e "
72-
const data = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8'));
73-
const labels = (data.labels || []).map(l => l.name);
74-
const isFeature = labels.some(l => l === 'feature' || l === 'enhancement');
75-
console.log(isFeature ? 'yes' : 'no');
76-
")
77-
78-
if [[ "$HAS_FEATURE" == "yes" ]]; then
79-
BUMP_LEVEL="minor"
80-
break
81-
fi
82-
done
83-
84-
echo "$BUMP_LEVEL"

.github/workflows/dev-release.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,27 @@ jobs:
2323
with:
2424
node-version: '22'
2525

26-
- name: Increment dev build counter
26+
- name: Bump patch version
2727
id: version
2828
run: |
29-
CURRENT=$(node -p "require('./frontend/package.json').version")
30-
COUNT_FILE=".github/dev-build-count"
31-
BUILD_NUMBER=$(( $(cat "$COUNT_FILE") + 1 ))
32-
echo "$BUILD_NUMBER" > "$COUNT_FILE"
33-
DEV_TAG="v${CURRENT}-dev.${BUILD_NUMBER}"
34-
echo "current=${CURRENT}" >> $GITHUB_OUTPUT
35-
echo "tag=${DEV_TAG}" >> $GITHUB_OUTPUT
36-
echo "build_number=${BUILD_NUMBER}" >> $GITHUB_OUTPUT
29+
# Every change on dev bumps PATCH (#348). The patch digit counts the
30+
# changes accumulated on the current line: 0.5.13 means thirteen
31+
# changes since 0.5.0. Merging to main then bumps MINOR, which is the
32+
# release.
33+
PREVIOUS=$(node -p "require('./frontend/package.json').version")
34+
chmod +x .github/scripts/bump-version.sh
35+
NEW_VERSION=$(.github/scripts/bump-version.sh patch)
36+
echo "previous=${PREVIOUS}" >> $GITHUB_OUTPUT
37+
echo "current=${NEW_VERSION}" >> $GITHUB_OUTPUT
38+
echo "tag=v${NEW_VERSION}" >> $GITHUB_OUTPUT
39+
echo "Dev version: v${PREVIOUS} -> v${NEW_VERSION}"
3740
38-
- name: Commit build counter
41+
- name: Commit version bump
3942
run: |
4043
git config user.name "github-actions[bot]"
4144
git config user.email "github-actions[bot]@users.noreply.github.com"
42-
git add .github/dev-build-count
43-
git commit -m "chore: dev build ${{ steps.version.outputs.build_number }} [skip ci]"
45+
git add frontend/package.json
46+
git commit -m "chore: dev v${{ steps.version.outputs.current }} [skip ci]"
4447
git push
4548
4649
- name: Install dependencies
@@ -67,6 +70,5 @@ jobs:
6770
**Unstable pre-release** — not for production use.
6871
6972
Branch: `dev`
70-
Build: `${{ steps.version.outputs.build_number }}`
71-
Base version: `v${{ steps.version.outputs.current }}`
73+
Version: `v${{ steps.version.outputs.current }}` (was `v${{ steps.version.outputs.previous }}`)
7274
Commit: `${{ github.sha }}`

.github/workflows/stable-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ jobs:
9494
generate_release_notes: true
9595
files: frontend/nomad-frontend-*.tgz
9696

97-
- name: Sync version back to dev and reset build counter
97+
- name: Sync released version back to dev
9898
run: |
99+
# dev continues patch-bumping from the released version: after v0.6.0
100+
# the next change on dev is v0.6.1 (#348). There is no build counter
101+
# to reset any more - dev carries real versions.
99102
git fetch origin dev
100103
git checkout dev
101104
git merge main -m "chore: sync v${{ steps.newversion.outputs.version }} from main [skip ci]"
102-
echo "0" > .github/dev-build-count
103-
git add .github/dev-build-count
104-
git commit -m "chore: reset dev build counter after v${{ steps.newversion.outputs.version }} [skip ci]"
105105
git push origin dev

CONTRIBUTING.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,28 @@ Then create a PR on GitHub targeting the `dev` branch.
6868

6969
### 5. What Happens After Merge
7070

71-
When your PR is merged into `dev`, an **unstable pre-release** is automatically built and published to GitHub Releases. These are tagged like `v0.3.0-dev.47` and marked as pre-releases.
71+
When your change is merged into `dev`, the **patch** version is bumped and an **unstable pre-release** is automatically built and published to GitHub Releases, tagged with that version (e.g. `v0.13.2`) and marked as a pre-release.
7272

7373
## How Releases Work
7474

7575
### Unstable (dev)
7676

77-
Every merge to `dev` triggers an automatic pre-release build. No version bump occurs in `package.json`the artifact is tagged with a build number (`v0.3.0-dev.47`). These builds are for testing and are not intended for production.
77+
Every merge to `dev` bumps the **patch** version in `frontend/package.json` and publishes a pre-release. The patch digit counts the changes accumulated on the current line: `0.5.13` means thirteen changes since `0.5.0`. These builds are for testing and are not intended for production.
7878

7979
### Stable (main)
8080

8181
When the maintainer is ready to cut a stable release, they open a PR from `dev` to `main`. On merge, the CI automation:
8282

83-
1. Scans all commits in the PR for issue references (`#NNN`)
84-
2. Checks the labels on each referenced issue via the GitHub API
85-
3. Determines the version bump:
86-
- Any issue labeled `feature` or `enhancement`**minor** bump
87-
- Only `bug`/`task` labels or no issue references → **patch** bump
88-
- PR labeled `release:major`**major** bump (manual override)
89-
4. Bumps the version in `frontend/package.json`
90-
5. Creates a git tag and GitHub Release with the built tarball
83+
1. Bumps the **minor** version in `frontend/package.json` — a merge to `main` *is* the release,
84+
so `0.5.13` becomes `0.6.0`. The patch digit resets, and the minor digit identifies the
85+
released line.
86+
- Unless the PR is labeled `release:major`, which bumps **major** instead (manual override)
87+
2. Regenerates `CHANGES.md` from git history
88+
3. Creates a git tag and GitHub Release with the built tarball
89+
4. Merges the released version back into `dev`, so development continues from `0.6.1`
90+
91+
The bump level does **not** depend on issue labels. It previously did, which meant a release's
92+
version was decided by how issues happened to be labelled rather than by the release itself (#348).
9193

9294
### LTS (lts)
9395

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nomad/frontend",
3-
"version": "0.13.1",
3+
"version": "0.13.2",
44
"description": "Project Nomad - Fire Modeling GUI",
55
"private": false,
66
"type": "module",

0 commit comments

Comments
 (0)