Skip to content

Commit 5b63c9c

Browse files
committed
chore: make version auto-generate in publish-socketbin workflow
Make the version input optional and auto-generate it from current UTC timestamp (YYYY.MM.DD.HHmmss format) if not provided. Users can still provide a custom version if needed. This reduces friction when publishing binaries without having to manually enter the datetime.
1 parent ef1926e commit 5b63c9c

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

.github/workflows/publish-socketbin.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version to publish (datetime format: 2025.01.22.143052)'
8-
required: true
7+
description: 'Version to publish (datetime format: 2025.01.22.143052, auto-generated if omitted)'
8+
required: false
99
type: string
1010
method:
1111
description: 'Build method to use'
@@ -134,8 +134,15 @@ jobs:
134134
id: version
135135
run: |
136136
VERSION="${{ inputs.version }}"
137-
# Remove 'v' prefix if present
138-
VERSION="${VERSION#v}"
137+
if [ -z "$VERSION" ]; then
138+
# Auto-generate version in datetime format: YYYY.MM.DD.HHmmss
139+
VERSION=$(date -u +'%Y.%m.%d.%H%M%S')
140+
echo "Generated version: $VERSION"
141+
else
142+
# Remove 'v' prefix if present
143+
VERSION="${VERSION#v}"
144+
echo "Using provided version: $VERSION"
145+
fi
139146
echo "version=${VERSION}" >> $GITHUB_OUTPUT
140147
141148
- name: Check version consistency
@@ -283,8 +290,15 @@ jobs:
283290
id: version
284291
run: |
285292
VERSION="${{ inputs.version }}"
286-
# Remove 'v' prefix if present
287-
VERSION="${VERSION#v}"
293+
if [ -z "$VERSION" ]; then
294+
# Auto-generate version in datetime format: YYYY.MM.DD.HHmmss
295+
VERSION=$(date -u +'%Y.%m.%d.%H%M%S')
296+
echo "Generated version: $VERSION"
297+
else
298+
# Remove 'v' prefix if present
299+
VERSION="${VERSION#v}"
300+
echo "Using provided version: $VERSION"
301+
fi
288302
echo "version=${VERSION}" >> $GITHUB_OUTPUT
289303
290304
- name: Update package.json for @socketbin

0 commit comments

Comments
 (0)