Skip to content

Commit 993f491

Browse files
committed
feat(workflows): normalise v0.0.x → v0.1.0 with opt-out checkbox
> > When the current release is v0.0.x, auto-increment now jumps to v0.1.0 > (the standard semver starting point) instead of v0.0.2, v0.0.3, etc. > > A new 'normalize_version' checkbox (default: checked) lets users opt out > and keep incrementing within v0.0.x if they prefer. Propagates from update.yml → release.yml. > > Also applies the || true fix to the PRIOR_TAG pipeline to prevent set -e failures when > only one version tag exists.
1 parent 02da8cb commit 993f491

4 files changed

Lines changed: 52 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ on:
113113
required: false
114114
type: boolean
115115
default: false
116+
normalize_version:
117+
description: 'Normalise v0.0.x to v0.1.0 (uncheck to keep v0.0.x scheme)'
118+
required: false
119+
type: boolean
120+
default: true
116121

117122
permissions:
118123
contents: write
@@ -176,8 +181,14 @@ jobs:
176181
MAJOR=${BASH_REMATCH[1]}
177182
MINOR=${BASH_REMATCH[2]}
178183
PATCH=${BASH_REMATCH[3]}
179-
VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
180-
echo "🔢 Auto-detected next version: ${VERSION} (from latest: v${LATEST})"
184+
# Normalise v0.0.x → v0.1.0 (standard semver starting point)
185+
if [[ "${{ github.event.inputs.normalize_version }}" != 'false' && "$MAJOR" -eq 0 && "$MINOR" -eq 0 ]]; then
186+
VERSION="0.1.0"
187+
echo "📐 Normalising v${LATEST} → v${VERSION} (standard semver convention)"
188+
else
189+
VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
190+
echo "🔢 Auto-detected next version: ${VERSION} (from latest: v${LATEST})"
191+
fi
181192
else
182193
echo "❌ Could not determine latest version to auto-increment"
183194
exit 1

.github/workflows/update.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ on:
8787
required: false
8888
type: boolean
8989
default: false
90+
normalize_version:
91+
description: 'Normalise v0.0.x to v0.1.0 (uncheck to keep v0.0.x scheme)'
92+
required: false
93+
type: boolean
94+
default: true
9095
check_dependencies:
9196
description: 'Check and update dependencies (package.json, requirements.txt)'
9297
required: false
@@ -200,7 +205,7 @@ jobs:
200205
while read -r t; do
201206
v="${t#v}"
202207
[[ "$v" != "$LATEST_VERSION" ]] && echo "$t" && break
203-
done)
208+
done) || true
204209
if [[ -n "$PRIOR_TAG" ]]; then
205210
CUMULATIVE_COUNT=$(git log "${PRIOR_TAG}..HEAD" --oneline | wc -l)
206211
else
@@ -242,7 +247,12 @@ jobs:
242247
git tag --list 'v*' --sort=-version:refname | grep -vE 'latest|alpha|beta|rc' | head -1)
243248
CURRENT_VERSION=${CURRENT_VERSION#v}
244249
245-
if [[ $CUMULATIVE_COUNT -ge $NEW_RELEASE_THRESHOLD ]]; then
250+
# Normalise v0.0.x → v0.1.0 (standard semver starting point)
251+
if [[ "${{ github.event.inputs.normalize_version }}" != 'false' && "$CURRENT_VERSION" =~ ^0\.0\.[0-9]+$ ]]; then
252+
echo "📐 Normalising v${CURRENT_VERSION} → v0.1.0 (standard semver convention)"
253+
RELEASE_VERSION="0.1.0"
254+
RELEASE_TYPE="new release"
255+
elif [[ $CUMULATIVE_COUNT -ge $NEW_RELEASE_THRESHOLD ]]; then
246256
# Cumulative changes across re-releases exceed ceiling — bump patch version
247257
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
248258
NEXT_VERSION="${MAJOR}.${MINOR}.$(( PATCH + 1 ))"
@@ -260,6 +270,7 @@ jobs:
260270
gh workflow run release.yml \
261271
--ref ${{ github.ref_name }} \
262272
-f version="${RELEASE_VERSION}" \
273+
-f normalize_version="${{ github.event.inputs.normalize_version || 'true' }}" \
263274
-f prerelease=false \
264275
-f draft=false
265276

workflows-templates/release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ on:
116116
required: false
117117
type: boolean
118118
default: false
119+
normalize_version:
120+
description: 'Normalise v0.0.x to v0.1.0 (uncheck to keep v0.0.x scheme)'
121+
required: false
122+
type: boolean
123+
default: true
119124

120125
permissions:
121126
contents: write
@@ -179,8 +184,14 @@ jobs:
179184
MAJOR=${BASH_REMATCH[1]}
180185
MINOR=${BASH_REMATCH[2]}
181186
PATCH=${BASH_REMATCH[3]}
182-
VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
183-
echo "🔢 Auto-detected next version: ${VERSION} (from latest: v${LATEST})"
187+
# Normalise v0.0.x → v0.1.0 (standard semver starting point)
188+
if [[ "${{ github.event.inputs.normalize_version }}" != 'false' && "$MAJOR" -eq 0 && "$MINOR" -eq 0 ]]; then
189+
VERSION="0.1.0"
190+
echo "📐 Normalising v${LATEST} → v${VERSION} (standard semver convention)"
191+
else
192+
VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
193+
echo "🔢 Auto-detected next version: ${VERSION} (from latest: v${LATEST})"
194+
fi
184195
else
185196
echo "❌ Could not determine latest version to auto-increment"
186197
exit 1

workflows-templates/update.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ on:
9090
required: false
9191
type: boolean
9292
default: false
93+
normalize_version:
94+
description: 'Normalise v0.0.x to v0.1.0 (uncheck to keep v0.0.x scheme)'
95+
required: false
96+
type: boolean
97+
default: true
9398
check_dependencies:
9499
description: 'Check and update dependencies (package.json, requirements.txt)'
95100
required: false
@@ -203,7 +208,7 @@ jobs:
203208
while read -r t; do
204209
v="${t#v}"
205210
[[ "$v" != "$LATEST_VERSION" ]] && echo "$t" && break
206-
done)
211+
done) || true
207212
if [[ -n "$PRIOR_TAG" ]]; then
208213
CUMULATIVE_COUNT=$(git log "${PRIOR_TAG}..HEAD" --oneline | wc -l)
209214
else
@@ -245,7 +250,12 @@ jobs:
245250
git tag --list 'v*' --sort=-version:refname | grep -vE 'latest|alpha|beta|rc' | head -1)
246251
CURRENT_VERSION=${CURRENT_VERSION#v}
247252
248-
if [[ $CUMULATIVE_COUNT -ge $NEW_RELEASE_THRESHOLD ]]; then
253+
# Normalise v0.0.x → v0.1.0 (standard semver starting point)
254+
if [[ "${{ github.event.inputs.normalize_version }}" != 'false' && "$CURRENT_VERSION" =~ ^0\.0\.[0-9]+$ ]]; then
255+
echo "📐 Normalising v${CURRENT_VERSION} → v0.1.0 (standard semver convention)"
256+
RELEASE_VERSION="0.1.0"
257+
RELEASE_TYPE="new release"
258+
elif [[ $CUMULATIVE_COUNT -ge $NEW_RELEASE_THRESHOLD ]]; then
249259
# Cumulative changes across re-releases exceed ceiling — bump patch version
250260
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
251261
NEXT_VERSION="${MAJOR}.${MINOR}.$(( PATCH + 1 ))"
@@ -263,6 +273,7 @@ jobs:
263273
gh workflow run release.yml \
264274
--ref ${{ github.ref_name }} \
265275
-f version="${RELEASE_VERSION}" \
276+
-f normalize_version="${{ github.event.inputs.normalize_version || 'true' }}" \
266277
-f prerelease=false \
267278
-f draft=false
268279

0 commit comments

Comments
 (0)