Skip to content

Commit 8196d78

Browse files
authored
chore: Change get version workflow to an action (#4951)
change get version workflow to an action Signed-off-by: Tommy Hughes <tohughes@redhat.com>
1 parent 3ee27ee commit 8196d78

File tree

6 files changed

+98
-100
lines changed

6 files changed

+98
-100
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Get semantic release version
2+
description: ""
3+
inputs:
4+
custom_version: # Optional input for a custom version
5+
description: "Custom version to publish (e.g., v1.2.3) -- only edit if you know what you are doing"
6+
required: false
7+
token:
8+
description: "Personal Access Token"
9+
required: true
10+
default: ""
11+
outputs:
12+
release_version:
13+
description: "The release version to use (e.g., v1.2.3)"
14+
value: ${{ steps.get_release_version.outputs.release_version }}
15+
version_without_prefix:
16+
description: "The release version to use without 'v' (e.g., 1.2.3)"
17+
value: ${{ steps.get_release_version_without_prefix.outputs.version_without_prefix }}
18+
highest_semver_tag:
19+
description: "The highest semantic version tag without the 'v' prefix (e.g., 1.2.3)"
20+
value: ${{ steps.get_highest_semver.outputs.highest_semver_tag }}
21+
runs:
22+
using: composite
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Get release version
26+
id: get_release_version
27+
shell: bash
28+
env:
29+
GITHUB_TOKEN: ${{ inputs.token }}
30+
GIT_AUTHOR_NAME: feast-ci-bot
31+
GIT_AUTHOR_EMAIL: feast-ci-bot@willem.co
32+
GIT_COMMITTER_NAME: feast-ci-bot
33+
GIT_COMMITTER_EMAIL: feast-ci-bot@willem.co
34+
run: |
35+
if [[ -n "${{ inputs.custom_version }}" ]]; then
36+
VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$"
37+
echo "Using custom version: ${{ inputs.custom_version }}"
38+
if [[ ! "${{ inputs.custom_version }}" =~ $VERSION_REGEX ]]; then
39+
echo "Error: custom_version must match semantic versioning (e.g., v1.2.3)."
40+
exit 1
41+
fi
42+
echo "::set-output name=release_version::${{ inputs.custom_version }}"
43+
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
44+
echo "Using tag reference: ${GITHUB_REF#refs/tags/}"
45+
echo "::set-output name=release_version::${GITHUB_REF#refs/tags/}"
46+
else
47+
echo "Defaulting to branch name: ${GITHUB_REF#refs/heads/}"
48+
echo "::set-output name=release_version::${GITHUB_REF#refs/heads/}"
49+
fi
50+
- name: Get release version without prefix
51+
id: get_release_version_without_prefix
52+
shell: bash
53+
env:
54+
RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }}
55+
run: |
56+
if [[ "${RELEASE_VERSION}" == v* ]]; then
57+
echo "::set-output name=version_without_prefix::${RELEASE_VERSION:1}"
58+
else
59+
echo "::set-output name=version_without_prefix::${RELEASE_VERSION}"
60+
fi
61+
- name: Get highest semver
62+
id: get_highest_semver
63+
shell: bash
64+
env:
65+
RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }}
66+
run: |
67+
if [[ -n "${{ inputs.custom_version }}" ]]; then
68+
HIGHEST_SEMVER_TAG="${{ inputs.custom_version }}"
69+
echo "::set-output name=highest_semver_tag::$HIGHEST_SEMVER_TAG"
70+
echo "Using custom version as highest semantic version: $HIGHEST_SEMVER_TAG"
71+
else
72+
source infra/scripts/setup-common-functions.sh
73+
SEMVER_REGEX='^v[0-9]+\.[0-9]+\.[0-9]+(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$'
74+
if echo "${RELEASE_VERSION}" | grep -P "$SEMVER_REGEX" &>/dev/null ; then
75+
echo ::set-output name=highest_semver_tag::$(get_tag_release -m)
76+
echo "Using infra/scripts/setup-common-functions.sh to generate highest semantic version: $HIGHEST_SEMVER_TAG"
77+
fi
78+
fi
79+
- name: Check output
80+
shell: bash
81+
env:
82+
RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }}
83+
VERSION_WITHOUT_PREFIX: ${{ steps.get_release_version_without_prefix.outputs.version_without_prefix }}
84+
HIGHEST_SEMVER_TAG: ${{ steps.get_highest_semver.outputs.highest_semver_tag }}
85+
run: |
86+
echo $RELEASE_VERSION
87+
echo $VERSION_WITHOUT_PREFIX
88+
echo $HIGHEST_SEMVER_TAG

.github/workflows/get_semantic_release_version.yml

Lines changed: 0 additions & 96 deletions
This file was deleted.

.github/workflows/publish_helm_charts.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ jobs:
3232
HELM_VERSION: v3.8.0
3333
steps:
3434
- uses: actions/checkout@v4
35+
with:
36+
submodules: 'true'
3537
- id: get-version
36-
uses: ./.github/workflows/get_semantic_release_version.yml
38+
uses: ./.github/actions/get-semantic-release-version
3739
with:
3840
custom_version: ${{ github.event.inputs.custom_version }}
3941
token: ${{ github.event.inputs.token }}

.github/workflows/publish_images.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ jobs:
3535
REGISTRY: feastdev
3636
steps:
3737
- uses: actions/checkout@v4
38+
with:
39+
submodules: 'true'
3840
- id: get-version
39-
uses: ./.github/workflows/get_semantic_release_version.yml
41+
uses: ./.github/actions/get-semantic-release-version
4042
with:
4143
custom_version: ${{ github.event.inputs.custom_version }}
4244
token: ${{ github.event.inputs.token }}

.github/workflows/publish_java_sdk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
with:
3636
submodules: 'true'
3737
- id: get-version
38-
uses: ./.github/workflows/get_semantic_release_version.yml
38+
uses: ./.github/actions/get-semantic-release-version
3939
with:
4040
custom_version: ${{ github.event.inputs.custom_version }}
4141
token: ${{ github.event.inputs.token }}

.github/workflows/publish_python_sdk.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- uses: actions/checkout@v4
33+
with:
34+
submodules: 'true'
3335
- id: get-version
34-
uses: ./.github/workflows/get_semantic_release_version.yml
36+
uses: ./.github/actions/get-semantic-release-version
3537
with:
3638
custom_version: ${{ github.event.inputs.custom_version }}
3739
token: ${{ github.event.inputs.token }}

0 commit comments

Comments
 (0)