Skip to content

Commit 9a1f519

Browse files
committed
chore: Improve version detection for UI publish
Signed-off-by: ntkathole <[email protected]>
1 parent 43f3d52 commit 9a1f519

File tree

1 file changed

+63
-6
lines changed

1 file changed

+63
-6
lines changed

.github/workflows/publish_web_ui.yml

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: publish web ui
33
on:
44
workflow_dispatch: # Allows manual trigger of the workflow
55
inputs:
6+
current_version:
7+
description: 'Current version to bump from (e.g., v1.2.3). If not provided, will auto-detect from git tags'
8+
required: false
9+
type: string
610
custom_version: # Optional input for a custom version
711
description: 'Custom version to publish (e.g., v1.2.3) -- only edit if you know what you are doing'
812
required: false
@@ -19,6 +23,10 @@ on:
1923
type: boolean
2024
workflow_call: # Allows trigger of the workflow from another workflow
2125
inputs:
26+
current_version:
27+
description: 'Current version to bump from (e.g., v1.2.3). If not provided, will auto-detect from git tags'
28+
required: false
29+
type: string
2230
custom_version: # Optional input for a custom version
2331
description: 'Custom version to publish (e.g., v1.2.3) -- only edit if you know what you are doing'
2432
required: false
@@ -43,11 +51,60 @@ jobs:
4351
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4452
steps:
4553
- uses: actions/checkout@v4
46-
- id: get-current-version
54+
- name: Determine current version
55+
id: get-current-version
4756
if: github.event.inputs.custom_version != ''
48-
uses: ./.github/actions/get-semantic-release-version
49-
with:
50-
token: ${{ github.event.inputs.token || github.token }}
57+
shell: bash
58+
run: |
59+
if [[ -n "${{ github.event.inputs.current_version }}" ]]; then
60+
# Use provided current version
61+
CURRENT_VERSION_RAW="${{ github.event.inputs.current_version }}"
62+
echo "Using provided current version: $CURRENT_VERSION_RAW"
63+
64+
else
65+
# Auto-detect current version from git tags
66+
echo "No current version provided, auto-detecting from git tags..."
67+
source infra/scripts/setup-common-functions.sh
68+
69+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
70+
# If running from a tag, get the previous tag
71+
CURRENT_TAG="${GITHUB_REF#refs/tags/}"
72+
echo "Running from tag: $CURRENT_TAG"
73+
74+
# Get all tags, sort them, find the one before current tag
75+
PREVIOUS_TAG=$(git tag -l | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | grep -B1 "^${CURRENT_TAG}$" | head -1)
76+
77+
if [[ -z "$PREVIOUS_TAG" ]]; then
78+
echo "Error: Could not find previous version before $CURRENT_TAG"
79+
exit 1
80+
fi
81+
82+
echo "Found previous version: $PREVIOUS_TAG"
83+
CURRENT_VERSION_RAW="$PREVIOUS_TAG"
84+
85+
else
86+
# If running from branch, get the latest released version
87+
LATEST_TAG=$(get_tag_release -s)
88+
89+
if [[ -z "$LATEST_TAG" ]]; then
90+
echo "Error: No semantic version tags found in repository"
91+
exit 1
92+
fi
93+
94+
echo "Latest released version: $LATEST_TAG"
95+
CURRENT_VERSION_RAW="$LATEST_TAG"
96+
fi
97+
fi
98+
99+
# Remove 'v' prefix once at the end if present
100+
if [[ "$CURRENT_VERSION_RAW" =~ ^v ]]; then
101+
CURRENT_VERSION="${CURRENT_VERSION_RAW:1}"
102+
else
103+
CURRENT_VERSION="$CURRENT_VERSION_RAW"
104+
fi
105+
106+
echo "version_without_prefix=$CURRENT_VERSION" >> $GITHUB_OUTPUT
107+
echo "Final current version (without prefix): $CURRENT_VERSION"
51108
- name: Setup Node.js
52109
uses: actions/setup-node@v3
53110
with:
@@ -57,7 +114,7 @@ jobs:
57114
env:
58115
CUSTOM_VERSION: ${{ github.event.inputs.custom_version }}
59116
run: |
60-
# Get current version from action output (already normalized without 'v' prefix)
117+
# Get current version from previous step
61118
CURRENT_VERSION="${{ steps.get-current-version.outputs.version_without_prefix }}"
62119
63120
# Normalize custom version (next version) by removing 'v' prefix if present
@@ -66,7 +123,7 @@ jobs:
66123
NEXT_VERSION="${NEXT_VERSION:1}"
67124
fi
68125
69-
echo "Using current version from action: $CURRENT_VERSION"
126+
echo "Using current version: $CURRENT_VERSION"
70127
echo "Using next version (custom): $NEXT_VERSION"
71128
python ./infra/scripts/release/bump_file_versions.py ${CURRENT_VERSION} ${NEXT_VERSION}
72129
- name: Install yarn dependencies

0 commit comments

Comments
 (0)