diff --git a/_release-pypi/action.yml b/_release-pypi/action.yml index 644cfbe4d..44b9eaef6 100644 --- a/_release-pypi/action.yml +++ b/_release-pypi/action.yml @@ -148,6 +148,52 @@ runs: name: ${{ inputs.library-name }}-artifacts path: ${{ inputs.library-name }}-artifacts + - name: "Verify tag and artifacts version match" + shell: bash + env: + ARTIFACT_DIR: ${{ inputs.library-name }}-artifacts + run: | + + if [[ ! -d "${ARTIFACT_DIR}" ]]; then + echo "Artifact directory not found: ${ARTIFACT_DIR}" + exit 1 + fi + + # Extract version from git tag (strip refs/tags/ and optional leading 'v') + TAG_VERSION="${GITHUB_REF_NAME#v}" + echo "Git tag version: ${TAG_VERSION}" + + # Find first wheel or sdist + ARTIFACT_FILE="$(ls "${ARTIFACT_DIR}"/*.whl "${ARTIFACT_DIR}"/*.tar.gz 2>/dev/null | head -n 1)" + + if [[ -z "${ARTIFACT_FILE}" ]]; then + echo "No wheel or sdist found in ${ARTIFACT_DIR}" + exit 1 + fi + echo "Found artifact: ${ARTIFACT_FILE}" + + # Extract version from filename + # Examples: + # ansys_project-1.2.3-py3-none-any.whl + # ansys_project-1.2.3.tar.gz + ARTIFACT_VERSION="$(basename "${ARTIFACT_FILE}" \ + | sed -E 's/^[^0-9]+//; s/-.*$//; s/\.(tar\.gz|whl)$//')" + + if [[ -z "${ARTIFACT_VERSION}" ]]; then + echo "Failed to extract version from artifact filename" + exit 1 + fi + echo "Artifact version: ${ARTIFACT_VERSION}" + + if [[ "${TAG_VERSION}" != "${ARTIFACT_VERSION}" ]]; then + echo "Version mismatch!" + echo " Git tag version: ${TAG_VERSION}" + echo " Artifact version: ${ARTIFACT_VERSION}" + exit 1 + fi + + echo "Version check passed: tag and artifact versions match." + - name: "Display the structure of downloaded files" shell: bash run: ls -R diff --git a/doc/source/changelog/1111.added.md b/doc/source/changelog/1111.added.md new file mode 100644 index 000000000..18fe79f8d --- /dev/null +++ b/doc/source/changelog/1111.added.md @@ -0,0 +1 @@ +Check version match diff --git a/release-github/action.yml b/release-github/action.yml index e9e6a613f..491cb99e5 100644 --- a/release-github/action.yml +++ b/release-github/action.yml @@ -312,6 +312,62 @@ runs: # ------------------------------------------------------------------------ + - uses: ansys/actions/_logging@main + if: inputs.only-code == 'false' + with: + level: "INFO" + message: > + Verify that the tag version and the artifact version agree. + + - name: "Verify tag and artifacts version agree" + if: inputs.only-code == 'false' + shell: bash + env: + ARTIFACT_DIR: dist/${{ inputs.library-name }}-artifacts + run: | + + if [[ ! -d "${ARTIFACT_DIR}" ]]; then + echo "Artifact directory not found: ${ARTIFACT_DIR}" + exit 1 + fi + + # Extract version from git tag (strip refs/tags/ and optional leading 'v') + TAG_VERSION="${GITHUB_REF_NAME#v}" + echo "Git tag version: ${TAG_VERSION}" + + # Find first wheel or sdist + ARTIFACT_FILE="$(ls "${ARTIFACT_DIR}"/*.whl "${ARTIFACT_DIR}"/*.tar.gz 2>/dev/null | head -n 1)" + + if [[ -z "${ARTIFACT_FILE}" ]]; then + echo "No wheel or sdist found in ${ARTIFACT_DIR}" + exit 1 + fi + echo "Found artifact: ${ARTIFACT_FILE}" + + # Extract version from filename + # Examples: + # ansys_project-1.2.3-py3-none-any.whl + # ansys_project-1.2.3.tar.gz + ARTIFACT_VERSION="$(basename "${ARTIFACT_FILE}" \ + | sed -E 's/^[^0-9]+//; s/-.*$//; s/\.(tar\.gz|whl)$//')" + + if [[ -z "${ARTIFACT_VERSION}" ]]; then + echo "Failed to extract version from artifact filename" + exit 1 + fi + echo "Artifact version: ${ARTIFACT_VERSION}" + + if [[ "${TAG_VERSION}" != "${ARTIFACT_VERSION}" ]]; then + echo "Version mismatch!" + echo " Git tag version: ${TAG_VERSION}" + echo " Artifact version: ${ARTIFACT_VERSION}" + exit 1 + fi + + echo "Version check passed: tag and artifact versions match." + + # ------------------------------------------------------------------------ + - uses: ansys/actions/_logging@main if: inputs.additional-artifacts != '' with: