From 8196d78526d084dc0f662765459c0bbc2b47b84d Mon Sep 17 00:00:00 2001 From: Tommy Hughes IV Date: Tue, 21 Jan 2025 13:33:59 -0600 Subject: [PATCH] chore: Change get version workflow to an action (#4951) change get version workflow to an action Signed-off-by: Tommy Hughes --- .../get-semantic-release-version/action.yml | 88 +++++++++++++++++ .../get_semantic_release_version.yml | 96 ------------------- .github/workflows/publish_helm_charts.yml | 4 +- .github/workflows/publish_images.yml | 4 +- .github/workflows/publish_java_sdk.yml | 2 +- .github/workflows/publish_python_sdk.yml | 4 +- 6 files changed, 98 insertions(+), 100 deletions(-) create mode 100644 .github/actions/get-semantic-release-version/action.yml delete mode 100644 .github/workflows/get_semantic_release_version.yml diff --git a/.github/actions/get-semantic-release-version/action.yml b/.github/actions/get-semantic-release-version/action.yml new file mode 100644 index 0000000000..baa9052795 --- /dev/null +++ b/.github/actions/get-semantic-release-version/action.yml @@ -0,0 +1,88 @@ +name: Get semantic release version +description: "" +inputs: + custom_version: # Optional input for a custom version + description: "Custom version to publish (e.g., v1.2.3) -- only edit if you know what you are doing" + required: false + token: + description: "Personal Access Token" + required: true + default: "" +outputs: + release_version: + description: "The release version to use (e.g., v1.2.3)" + value: ${{ steps.get_release_version.outputs.release_version }} + version_without_prefix: + description: "The release version to use without 'v' (e.g., 1.2.3)" + value: ${{ steps.get_release_version_without_prefix.outputs.version_without_prefix }} + highest_semver_tag: + description: "The highest semantic version tag without the 'v' prefix (e.g., 1.2.3)" + value: ${{ steps.get_highest_semver.outputs.highest_semver_tag }} +runs: + using: composite + steps: + - uses: actions/checkout@v4 + - name: Get release version + id: get_release_version + shell: bash + env: + GITHUB_TOKEN: ${{ inputs.token }} + GIT_AUTHOR_NAME: feast-ci-bot + GIT_AUTHOR_EMAIL: feast-ci-bot@willem.co + GIT_COMMITTER_NAME: feast-ci-bot + GIT_COMMITTER_EMAIL: feast-ci-bot@willem.co + run: | + if [[ -n "${{ inputs.custom_version }}" ]]; then + VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$" + echo "Using custom version: ${{ inputs.custom_version }}" + if [[ ! "${{ inputs.custom_version }}" =~ $VERSION_REGEX ]]; then + echo "Error: custom_version must match semantic versioning (e.g., v1.2.3)." + exit 1 + fi + echo "::set-output name=release_version::${{ 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 "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 + shell: bash + env: + RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }} + run: | + 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 + shell: bash + env: + RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }} + run: | + if [[ -n "${{ inputs.custom_version }}" ]]; then + HIGHEST_SEMVER_TAG="${{ inputs.custom_version }}" + echo "::set-output name=highest_semver_tag::$HIGHEST_SEMVER_TAG" + echo "Using custom version as highest semantic version: $HIGHEST_SEMVER_TAG" + else + source infra/scripts/setup-common-functions.sh + SEMVER_REGEX='^v[0-9]+\.[0-9]+\.[0-9]+(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$' + if echo "${RELEASE_VERSION}" | grep -P "$SEMVER_REGEX" &>/dev/null ; then + echo ::set-output name=highest_semver_tag::$(get_tag_release -m) + echo "Using infra/scripts/setup-common-functions.sh to generate highest semantic version: $HIGHEST_SEMVER_TAG" + fi + fi + - name: Check output + shell: bash + env: + RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }} + VERSION_WITHOUT_PREFIX: ${{ steps.get_release_version_without_prefix.outputs.version_without_prefix }} + HIGHEST_SEMVER_TAG: ${{ steps.get_highest_semver.outputs.highest_semver_tag }} + run: | + echo $RELEASE_VERSION + echo $VERSION_WITHOUT_PREFIX + echo $HIGHEST_SEMVER_TAG \ No newline at end of file diff --git a/.github/workflows/get_semantic_release_version.yml b/.github/workflows/get_semantic_release_version.yml deleted file mode 100644 index 2cdeae4025..0000000000 --- a/.github/workflows/get_semantic_release_version.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: Get semantic release version - -on: - workflow_dispatch: # Allows manual trigger of the workflow - inputs: - custom_version: # Optional input for a custom version - description: 'Custom version to publish (e.g., v1.2.3) -- only edit if you know what you are doing' - required: false - type: string - token: - description: 'Personal Access Token' - required: true - default: "" - type: string - workflow_call: # Allows trigger of the workflow from another workflow - inputs: - custom_version: # Optional input for a custom version - description: 'Custom version to publish (e.g., v1.2.3) -- only edit if you know what you are doing' - required: false - type: string - token: - description: 'Personal Access Token' - required: true - default: "" - type: string - -jobs: - get-version: - if: github.repository == 'feast-dev/feast' - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ github.event.inputs.token }} - GIT_AUTHOR_NAME: feast-ci-bot - GIT_AUTHOR_EMAIL: feast-ci-bot@willem.co - GIT_COMMITTER_NAME: feast-ci-bot - GIT_COMMITTER_EMAIL: feast-ci-bot@willem.co - outputs: - release_version: ${{ steps.get_release_version.outputs.release_version }} - version_without_prefix: ${{ steps.get_release_version_without_prefix.outputs.version_without_prefix }} - highest_semver_tag: ${{ steps.get_highest_semver.outputs.highest_semver_tag }} - steps: - - uses: actions/checkout@v4 - - name: Get release version - id: get_release_version - run: | - if [[ -n "${{ github.event.inputs.custom_version }}" ]]; then - VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$" - echo "Using custom version: ${{ github.event.inputs.custom_version }}" - 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 "::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 "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: | - 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: - RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }} - run: | - if [[ -n "${{ github.event.inputs.custom_version }}" ]]; then - HIGHEST_SEMVER_TAG="${{ github.event.inputs.custom_version }}" - echo "::set-output name=highest_semver_tag::$HIGHEST_SEMVER_TAG" - echo "Using custom version as highest semantic version: $HIGHEST_SEMVER_TAG" - else - source infra/scripts/setup-common-functions.sh - SEMVER_REGEX='^v[0-9]+\.[0-9]+\.[0-9]+(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$' - if echo "${RELEASE_VERSION}" | grep -P "$SEMVER_REGEX" &>/dev/null ; then - echo ::set-output name=highest_semver_tag::$(get_tag_release -m) - echo "Using infra/scripts/setup-common-functions.sh to generate highest semantic version: $HIGHEST_SEMVER_TAG" - fi - fi - - name: Check output - env: - RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }} - VERSION_WITHOUT_PREFIX: ${{ steps.get_release_version_without_prefix.outputs.version_without_prefix }} - HIGHEST_SEMVER_TAG: ${{ steps.get_highest_semver.outputs.highest_semver_tag }} - run: | - echo $RELEASE_VERSION - echo $VERSION_WITHOUT_PREFIX - echo $HIGHEST_SEMVER_TAG \ No newline at end of file diff --git a/.github/workflows/publish_helm_charts.yml b/.github/workflows/publish_helm_charts.yml index c427e4307c..9d28e2efd2 100644 --- a/.github/workflows/publish_helm_charts.yml +++ b/.github/workflows/publish_helm_charts.yml @@ -32,8 +32,10 @@ jobs: HELM_VERSION: v3.8.0 steps: - uses: actions/checkout@v4 + with: + submodules: 'true' - id: get-version - uses: ./.github/workflows/get_semantic_release_version.yml + uses: ./.github/actions/get-semantic-release-version with: custom_version: ${{ github.event.inputs.custom_version }} token: ${{ github.event.inputs.token }} diff --git a/.github/workflows/publish_images.yml b/.github/workflows/publish_images.yml index a3ca9a63ff..f605fb20df 100644 --- a/.github/workflows/publish_images.yml +++ b/.github/workflows/publish_images.yml @@ -35,8 +35,10 @@ jobs: REGISTRY: feastdev steps: - uses: actions/checkout@v4 + with: + submodules: 'true' - id: get-version - uses: ./.github/workflows/get_semantic_release_version.yml + uses: ./.github/actions/get-semantic-release-version with: custom_version: ${{ github.event.inputs.custom_version }} token: ${{ github.event.inputs.token }} diff --git a/.github/workflows/publish_java_sdk.yml b/.github/workflows/publish_java_sdk.yml index de909cb5eb..f89c384b12 100644 --- a/.github/workflows/publish_java_sdk.yml +++ b/.github/workflows/publish_java_sdk.yml @@ -35,7 +35,7 @@ jobs: with: submodules: 'true' - id: get-version - uses: ./.github/workflows/get_semantic_release_version.yml + uses: ./.github/actions/get-semantic-release-version with: custom_version: ${{ github.event.inputs.custom_version }} token: ${{ github.event.inputs.token }} diff --git a/.github/workflows/publish_python_sdk.yml b/.github/workflows/publish_python_sdk.yml index afacb83a36..5866eba479 100644 --- a/.github/workflows/publish_python_sdk.yml +++ b/.github/workflows/publish_python_sdk.yml @@ -30,8 +30,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: 'true' - id: get-version - uses: ./.github/workflows/get_semantic_release_version.yml + uses: ./.github/actions/get-semantic-release-version with: custom_version: ${{ github.event.inputs.custom_version }} token: ${{ github.event.inputs.token }}