From 7c558f60030ddd933a3468acbd9aa6133aa3b62f Mon Sep 17 00:00:00 2001 From: kdoroszko-splunk <147069837+kdoroszko-splunk@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:22:51 +0100 Subject: [PATCH] refactor: remove addonfactory-get-splunk-package-version-action (#229) This PR decommissions use of splunk/addonfactory-get-splunk-package-version-action, replacing it with the direct code. https://splunk.atlassian.net/browse/ADDON-68236 Tested here: https://github.com/splunk/test-addonfactory-repo/actions/runs/7817333993/job/21325041323 --- .../workflows/reusable-build-test-release.yml | 63 ++++++++++++++++--- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/.github/workflows/reusable-build-test-release.yml b/.github/workflows/reusable-build-test-release.yml index 88e126cc5..ae2443952 100644 --- a/.github/workflows/reusable-build-test-release.yml +++ b/.github/workflows/reusable-build-test-release.yml @@ -590,10 +590,33 @@ jobs: GITHUB_TOKEN: ${{ github.token }} - name: Determine the version to build id: BuildVersion - uses: splunk/addonfactory-get-splunk-package-version-action@v1 - with: - SemVer: ${{ steps.semantic.outputs.new_release_version }} - PrNumber: ${{ github.event.number }} + run: | + INPUT_SEMVER="${{ steps.semantic.outputs.new_release_version }}" + echo "Initial semver ${INPUT_SEMVER}" + INPUT_PRNUMBER="${{ github.event.number }}" + SEMVER_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+$' + BETA_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+$' + echo working with version $INPUT_SEMVER + if [[ $INPUT_SEMVER =~ $SEMVER_REGEX ]]; + then + echo using provided semver + VERSION=$INPUT_SEMVER + elif [[ $INPUT_SEMVER =~ $BETA_REGEX ]]; + then + VERSION=$(echo $INPUT_SEMVER | awk '{gsub("-beta\.", "-B");print}') + else + if [[ $GITHUB_EVENT_NAME != 'pull_request' ]]; + then + echo this is not a release build and NOT PR RUNID + run ID + VERSION=0.0.${GITHUB_RUN_ID} + else + echo this is not a release build and is a PR use run ID + VERSION=0.${INPUT_PRNUMBER}.${GITHUB_RUN_ID} + fi + fi + FINALVERSION="${VERSION//v}" + echo "Version to build is ${FINALVERSION}" + echo "VERSION=${FINALVERSION}" >> "$GITHUB_OUTPUT" - name: Download THIRDPARTY if: github.event_name != 'pull_request' && github.event_name != 'schedule' uses: actions/download-artifact@v3 @@ -721,10 +744,34 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} - id: BuildVersion - uses: splunk/addonfactory-get-splunk-package-version-action@v1 - with: - SemVer: ${{ steps.semantic.outputs.new_release_version }} - PrNumber: ${{ github.event.number }} + run: | + INPUT_SEMVER="${{ steps.semantic.outputs.new_release_version }}" + echo "Initial semver ${INPUT_SEMVER}" + INPUT_PRNUMBER="${{ github.event.number }}" + SEMVER_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+$' + BETA_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+$' + echo working with version $INPUT_SEMVER + + if [[ $INPUT_SEMVER =~ $SEMVER_REGEX ]]; + then + echo using provided semver + VERSION=$INPUT_SEMVER + elif [[ $INPUT_SEMVER =~ $BETA_REGEX ]]; + then + VERSION=$(echo $INPUT_SEMVER | awk '{gsub("-beta\.", "-B");print}') + else + if [[ $GITHUB_EVENT_NAME != 'pull_request' ]]; + then + echo this is not a release build and NOT PR RUNID + run ID + VERSION=0.0.${GITHUB_RUN_ID} + else + echo this is not a release build and is a PR use run ID + VERSION=0.${INPUT_PRNUMBER}.${GITHUB_RUN_ID} + fi + fi + FINALVERSION="${VERSION//v}" + echo "Version to build is $FINALVERSION" + echo "VERSION=$FINALVERSION" >> "$GITHUB_OUTPUT" - id: uccgen uses: splunk/addonfactory-ucc-generator-action@v2 with: