diff --git a/.github/semver.yml b/.github/semver.yml deleted file mode 100644 index a351a3d..0000000 --- a/.github/semver.yml +++ /dev/null @@ -1,22 +0,0 @@ -# .github/workflows/release.yml -name: Release - -on: - pull_request: - types: [closed] - -jobs: - build: - runs-on: ubuntu-latest - - if: github.event.pull_request.merged - - steps: - - name: Tag - uses: K-Phoen/semver-release-action@master - with: - release_branch: pyproject.toml - release_strategy: none - - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/semver.yml b/.github/workflows/semver.yml new file mode 100644 index 0000000..c6d5fb1 --- /dev/null +++ b/.github/workflows/semver.yml @@ -0,0 +1,48 @@ +name: Semantic Versioning for Tags + +on: + pull_request: + types: [closed] + branches: + - main + +jobs: + bump-version: + if: ${{ github.event.pull_request.merged == true $$ github.event.pull_request.base.ref == 'main' }} + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Bump Version and Tag + run: | + # Fetch the latest tags from the remote + git fetch --tags + + # Get the latest tag + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + + # Split the latest tag into parts + IFS='.' read -r -a parts <<< "${latest_tag#v}" + + # Increment the patch version + major=${parts[0]} + minor=${parts[1]} + patch=${parts[2]} + new_patch=$((patch + 1)) + + # Create a new tag + new_tag="v$major.$minor.$new_patch" + + echo "Bumping version from $latest_tag to $new_tag" + + # Tag the new version + git tag $new_tag + + # Configure GitHub token authentication + git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git + + # Push the new tag to the remote repository + git push origin $new_tag