Skip to content

Commit 35c5926

Browse files
authored
Merge pull request #135 from mission-minded-llc/develop
feat: enable manual versioning in workflow_dispatch.
2 parents 6f55414 + 52bb33f commit 35c5926

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

.github/workflows/tag-version.yml

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
branches:
88
- main
99
workflow_dispatch:
10+
inputs:
11+
manual_version:
12+
description: "Manual version number (e.g., 1.2.3) - leave empty for auto-increment"
13+
required: false
14+
type: string
15+
pattern: '^[0-9]+\.[0-9]+\.[0-9]+$'
1016

1117
jobs:
1218
tag-version:
@@ -47,26 +53,32 @@ jobs:
4753
- name: Calculate new version
4854
id: new-version
4955
run: |
50-
CURRENT_VERSION="${{ steps.current-version.outputs.current_version }}"
51-
# Split version into parts
52-
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
53-
MAJOR="${VERSION_PARTS[0]}"
54-
MINOR="${VERSION_PARTS[1]}"
55-
PATCH="${VERSION_PARTS[2]}"
56-
57-
# Check recent commits for version bump indicators
58-
if git log --oneline -10 | grep -q "\[major\]"; then
59-
echo "Major version bump detected"
60-
NEW_MAJOR=$((MAJOR + 1))
61-
NEW_VERSION="$NEW_MAJOR.0.0"
62-
elif git log --oneline -10 | grep -q "\[minor\]"; then
63-
echo "Minor version bump detected"
64-
NEW_MINOR=$((MINOR + 1))
65-
NEW_VERSION="$MAJOR.$NEW_MINOR.0"
56+
# Check if manual version was provided via workflow_dispatch
57+
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.manual_version }}" ]; then
58+
echo "Using manual version: ${{ github.event.inputs.manual_version }}"
59+
NEW_VERSION="${{ github.event.inputs.manual_version }}"
6660
else
67-
echo "Patch version bump (default)"
68-
NEW_PATCH=$((PATCH + 1))
69-
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
61+
CURRENT_VERSION="${{ steps.current-version.outputs.current_version }}"
62+
# Split version into parts
63+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
64+
MAJOR="${VERSION_PARTS[0]}"
65+
MINOR="${VERSION_PARTS[1]}"
66+
PATCH="${VERSION_PARTS[2]}"
67+
68+
# Check recent commits for version bump indicators
69+
if git log --oneline -10 | grep -q "\[major\]"; then
70+
echo "Major version bump detected"
71+
NEW_MAJOR=$((MAJOR + 1))
72+
NEW_VERSION="$NEW_MAJOR.0.0"
73+
elif git log --oneline -10 | grep -q "\[minor\]"; then
74+
echo "Minor version bump detected"
75+
NEW_MINOR=$((MINOR + 1))
76+
NEW_VERSION="$MAJOR.$NEW_MINOR.0"
77+
else
78+
echo "Patch version bump (default)"
79+
NEW_PATCH=$((PATCH + 1))
80+
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
81+
fi
7082
fi
7183
7284
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)