diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f4944c..bbc512d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,30 +23,33 @@ jobs: id: get_tag_version run: echo "::set-output name=tag_version::${GITHUB_REF#refs/tags/v}" + - name: Extract tag version without pre-release identifiers + id: get_tag_version_clean + run: | + # This extracts the version number and removes any pre-release identifiers like '-rc1' + TAG_VERSION="${GITHUB_REF#refs/tags/v}" + CLEAN_TAG_VERSION="${TAG_VERSION%%-*}" + echo "::set-output name=clean_tag_version::$CLEAN_TAG_VERSION" + - name: Get current package version id: get_package_version run: echo "::set-output name=package_version::$(poetry version --short)" - name: Verify versions match run: | - if [ "${{ steps.get_tag_version.outputs.tag_version }}" != "${{ steps.get_package_version.outputs.package_version }}" ]; then + if [ "${{ steps.get_tag_version.outputs.clean_tag_version }}" != "${{ steps.get_package_version.outputs.package_version }}" ]; then echo "Error: Tag version does not match the pyproject.toml version" exit 1 fi + - name: Set version to match the release tag + run: | + echo "Setting package version to ${{ steps.get_tag_version.outputs.clean_tag_version }}" + poetry version "${{ steps.get_tag_version.outputs.clean_tag_version }}"" + - name: Publish to PyPI env: POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} run: | poetry build poetry publish - - - name: Create GitHub Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-alpha') || contains(github.ref, '-beta') }} \ No newline at end of file