Skip to content

Commit 2c22ecf

Browse files
committed
publish-legacy: fix version extraction
1 parent b8ebe01 commit 2c22ecf

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

.github/workflows/publish-legacy.yml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,27 @@ jobs:
2323
fetch-depth: 0
2424
fetch-tags: true
2525

26-
- name: Extract version from tag
26+
- name: Extract version from input tag
2727
id: get_version
2828
run: |
29-
# Extract full tag (e.g., 1.2.3 or 2.0.0-beta1)
30-
FULL_TAG=${GITHUB_REF#refs/tags/}
29+
# Get tag from workflow input
30+
FULL_TAG="${{ inputs.tag }}"
3131
32-
# Validate tag format
32+
# Validate tag format
3333
if [[ ! $FULL_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
3434
echo "ERROR: Tag '$FULL_TAG' does not match format {VERSION}"
3535
echo "Expected format: 1.2.3 or 2.0.0-beta1"
3636
exit 1
3737
fi
3838
39-
# Extract version part (strip roman numeral prefix)
40-
VERSION=${FULL_TAG}
41-
42-
# Extract commit hash (short)
43-
COMMIT_HASH=$(git rev-parse --short HEAD)
44-
45-
# Extract major version for AssemblyVersion (e.g., 1.2.3 -> 1.0.0.0)
46-
if [[ $VERSION =~ ^([0-9]+) ]]; then
47-
ASSEMBLY_VERSION="${BASH_REMATCH[1]}.0.0.0"
39+
# Verify the tag exists
40+
if ! git rev-parse "refs/tags/$FULL_TAG" >/dev/null 2>&1; then
41+
echo "ERROR: Tag '$FULL_TAG' does not exist in the repository."
42+
exit 1
4843
fi
4944
50-
# InformationalVersion = semantic version + commit hash
51-
INFORMATIONAL_VERSION="${VERSION}+${COMMIT_HASH}"
45+
# Extract version part (strip roman numeral prefix)
46+
VERSION=${FULL_TAG}
5247
5348
# Detect if this is a pre-release version
5449
if [[ $VERSION =~ - ]]; then
@@ -69,17 +64,14 @@ jobs:
6964
VERSION_CLEAN=""
7065
fi
7166
67+
echo "full_tag=$FULL_TAG" >> $GITHUB_OUTPUT
7268
echo "version=$VERSION" >> $GITHUB_OUTPUT
7369
echo "version_trimmed=$VERSION_TRIMMED" >> $GITHUB_OUTPUT
74-
echo "assembly_version=$ASSEMBLY_VERSION" >> $GITHUB_OUTPUT
75-
echo "informational_version=$INFORMATIONAL_VERSION" >> $GITHUB_OUTPUT
7670
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
7771
echo "version_clean=$VERSION_CLEAN" >> $GITHUB_OUTPUT
78-
echo "Using tag: $FULL_TAG"
72+
echo "Input tag: $FULL_TAG"
7973
echo "Version: $VERSION"
8074
echo "Version trimmed: $VERSION_TRIMMED"
81-
echo "AssemblyVersion: $ASSEMBLY_VERSION"
82-
echo "InformationalVersion: $INFORMATIONAL_VERSION"
8375
echo "Is pre-release: $IS_PRERELEASE"
8476
echo "Version clean: $VERSION_CLEAN"
8577

0 commit comments

Comments
 (0)