From 00031d530dff177a2cadab37cde42df9bd86c88e Mon Sep 17 00:00:00 2001 From: TheTechromancer Date: Fri, 6 Dec 2024 19:17:14 -0500 Subject: [PATCH 1/2] troubleshoot auto tagging --- .github/workflows/tests.yml | 28 +++++++++++++--------------- pyproject.toml | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8d655fa..d1c717c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,39 +55,37 @@ jobs: id: get_version run: | VERSION=$(poetry version --short) - echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "VERSION=$VERSION" | tee -a $GITHUB_ENV - name: Fetch latest tag run: | git fetch --tags LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "v0.0.0") - echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + echo "LATEST_TAG=$LATEST_TAG" | tee -a $GITHUB_ENV - name: Detect version change run: | # Retrieve and strip "v" prefix if present + PREVIOUS_VERSION="${{ env.LATEST_TAG }}" CURRENT_VERSION="${{ env.VERSION }}" - LATEST_VERSION="${{ env.LATEST_TAG }}" - CURRENT_VERSION="${CURRENT_VERSION#v}" - LATEST_VERSION="${LATEST_VERSION#v}" + + echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" + echo "CURRENT_VERSION=$CURRENT_VERSION" # Extract major.minor for comparison - CURRENT_MAJOR_MINOR=$(echo "$CURRENT_VERSION" | cut -d '.' -f 1-2) - LATEST_MAJOR_MINOR=$(echo "$LATEST_VERSION" | cut -d '.' -f 1-2) + CURRENT_MAJOR_MINOR=$(echo "${CURRENT_VERSION#v}" | cut -d '.' -f 1-2) + PREVIOUS_MAJOR_MINOR=$(echo "${PREVIOUS_VERSION#v}" | cut -d '.' -f 1-2) # Compare versions - if [ "$CURRENT_MAJOR_MINOR" == "$LATEST_MAJOR_MINOR" ]; then - echo "VERSION_CHANGE=false" >> $GITHUB_ENV + if [ "$CURRENT_MAJOR_MINOR" == "$PREVIOUS_MAJOR_MINOR" ]; then + echo "VERSION_CHANGE=false" | tee -a $GITHUB_ENV else - echo "VERSION_CHANGE=true" >> $GITHUB_ENV + echo "VERSION_CHANGE=true" | tee -a $GITHUB_ENV fi shell: bash - env: - VERSION: ${{ env.VERSION }} # dynamically passed VERSION variable - LATEST_TAG: ${{ env.LATEST_TAG }} # dynamically passed LATEST_TAG variable - name: Build PyPi package - if: github.ref == 'refs/heads/main' && env.VERSION_CHANGE == 'true' + if: github.ref == 'refs/heads/main' run: python -m build - name: Publish PyPi package - if: github.ref == 'refs/heads/main' && env.VERSION_CHANGE == 'true' + if: github.ref == 'refs/heads/main' uses: pypa/gh-action-pypi-publish@release/v1.5 with: password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 3296347..a0b183d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ lint.ignore = ["E402", "E713", "E721", "E741", "F401", "F403", "F405"] [tool.poetry-dynamic-versioning] enable = true metadata = false -format-jinja = 'v3.1.{{ distance }}' +format-jinja = 'v3.0.{{ distance }}' [build-system] requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] From f4cea12b8aed8e45c984c98b73ee8d92b86c3971 Mon Sep 17 00:00:00 2001 From: TheTechromancer Date: Fri, 6 Dec 2024 19:20:42 -0500 Subject: [PATCH 2/2] main->master --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d1c717c..cadb6b2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -82,15 +82,15 @@ jobs: fi shell: bash - name: Build PyPi package - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/master' run: python -m build - name: Publish PyPi package - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/master' uses: pypa/gh-action-pypi-publish@release/v1.5 with: password: ${{ secrets.PYPI_API_TOKEN }} - name: Tag the release if major or minor version changed - if: github.ref == 'refs/heads/main' && env.VERSION_CHANGE == 'true' + if: github.ref == 'refs/heads/master' run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com"