Skip to content

Commit

Permalink
chore: Adjusting the semantic version parsing in the publish
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
  • Loading branch information
franciscojavierarceo committed Dec 5, 2024
1 parent 3fbff08 commit 8e4b09b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,40 @@ jobs:
highest_semver_tag: ${{ steps.get_highest_semver.outputs.highest_semver_tag }}
steps:
- uses: actions/checkout@v4
- name: Validate custom version input
id: validate_custom_version
run: |
if [[ -n "${{ github.event.inputs.custom_version }}" ]]; then
VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$"
if [[ ! "${{ github.event.inputs.custom_version }}" =~ $VERSION_REGEX ]]; then
echo "Error: custom_version must match semantic versioning (e.g., v1.2.3)."
exit 1
fi
echo "Validated custom version: ${{ github.event.inputs.custom_version }}"
fi
- name: Get release version
id: get_release_version
run: |
if [[ -n "${{ github.event.inputs.custom_version }}" ]]; then
echo "Using custom version: ${{ github.event.inputs.custom_version }}"
echo "::set-output name=release_version::${{ github.event.inputs.custom_version }}"
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "Using tag reference: ${GITHUB_REF#refs/tags/}"
echo "::set-output name=release_version::${GITHUB_REF#refs/tags/}"
else
echo ::set-output name=release_version::${GITHUB_REF#refs/*/}
echo "Defaulting to branch name: ${GITHUB_REF#refs/heads/}"
echo "::set-output name=release_version::${GITHUB_REF#refs/heads/}"
fi
- name: Get release version without prefix
id: get_release_version_without_prefix
env:
RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }}
run: |
echo ::set-output name=version_without_prefix::${RELEASE_VERSION:1}
if [[ "${RELEASE_VERSION}" == v* ]]; then
echo "::set-output name=version_without_prefix::${RELEASE_VERSION:1}"
else
echo "::set-output name=version_without_prefix::${RELEASE_VERSION}"
fi
- name: Get highest semver
id: get_highest_semver
env:
Expand Down

0 comments on commit 8e4b09b

Please sign in to comment.