diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b29e38..ac5c657 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,16 +35,9 @@ jobs: - name: Run tests run: | poetry run pytest tests/ -v - - # Call the version-bump workflow to bump the version before publishing - version-bump: - needs: test - uses: ./.github/workflows/version-bump.yml - # Only run on release branch when push (merge) - if: github.event_name == 'push' && github.ref == 'refs/heads/release' publish: - needs: version-bump + needs: test runs-on: ubuntu-latest # Only run on release branch when push (merge) if: github.event_name == 'push' && github.ref == 'refs/heads/release' @@ -52,7 +45,6 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: 'refs/heads/release' fetch-depth: 0 - name: Set up Python @@ -64,11 +56,57 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install poetry + python -m pip install poetry tomlkit + + - name: Extract version from pyproject.toml + id: get-version + run: | + # Python script to extract current version + python - << 'EOF' + import tomlkit + import os + + # Read current version from pyproject.toml + with open('pyproject.toml', 'r') as f: + pyproject = tomlkit.parse(f.read()) + + version = pyproject['project']['version'] + print(f"Current version: {version}") + + # Save the version to environment variables for later steps + with open(os.environ['GITHUB_ENV'], 'a') as f: + f.write(f"PACKAGE_VERSION={version}\n") + + # Set output for the workflow + with open(os.environ['GITHUB_OUTPUT'], 'a') as f: + f.write(f"version={version}\n") + EOF + + - name: Check if tag exists + id: check-tag + run: | + TAG="v${PACKAGE_VERSION}" + if git rev-parse $TAG >/dev/null 2>&1; then + echo "Tag $TAG already exists" + echo "tag_exists=true" >> $GITHUB_OUTPUT + else + echo "Tag $TAG does not exist" + echo "tag_exists=false" >> $GITHUB_OUTPUT + fi + + - name: Configure Git + if: steps.check-tag.outputs.tag_exists == 'false' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" - - name: Fetch latest changes with updated version + - name: Create and push tag + if: steps.check-tag.outputs.tag_exists == 'false' run: | - git pull origin release # Make sure we have the latest version after bump + # Create a new tag with the version from pyproject.toml + git tag -a "v${PACKAGE_VERSION}" -m "Release version ${PACKAGE_VERSION}" + # Push the tag to the remote repository + git push origin "v${PACKAGE_VERSION}" - name: Build and publish env: diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml deleted file mode 100644 index 2949981..0000000 --- a/.github/workflows/version-bump.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Version Bump - -on: - workflow_call: - outputs: - new_version: - description: "The new version number" - value: ${{ jobs.bump-version.outputs.new_version }} - push: - branches: [ release ] - -jobs: - bump-version: - runs-on: ubuntu-latest - permissions: - contents: write - # Only run on direct push to release, not when called by another workflow - if: ${{ github.event_name == 'push' || !github.event.workflow_call }} - outputs: - new_version: ${{ steps.set-version.outputs.new_version }} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.12" - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tomlkit - - - name: Configure Git - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - - name: Bump version - id: set-version - run: | - # Python script to bump version - python - << 'EOF' - import tomlkit - import re - import os - - # Read current version from pyproject.toml - with open('pyproject.toml', 'r') as f: - pyproject = tomlkit.parse(f.read()) - - current_version = pyproject['project']['version'] - print(f"Current version: {current_version}") - - # Parse version components - match = re.match(r"(\d+)\.(\d+)\.(\d+)(.*)$", current_version) - major, minor, patch, suffix = match.groups() - - # Bump patch version - new_version = f"{major}.{minor}.{int(patch) + 1}{suffix}" - print(f"New version: {new_version}") - - # Update pyproject.toml - pyproject['project']['version'] = new_version - with open('pyproject.toml', 'w') as f: - f.write(tomlkit.dumps(pyproject)) - - # Save the new version to environment variables for later steps - with open(os.environ['GITHUB_ENV'], 'a') as f: - f.write(f"NEW_VERSION={new_version}\n") - - # Set output for the workflow - with open(os.environ['GITHUB_OUTPUT'], 'a') as f: - f.write(f"new_version={new_version}\n") - EOF - - # Commit and push changes - git add pyproject.toml - git commit -m "Bump version to ${NEW_VERSION} [skip ci]" - git push - - - name: Create and push tag - run: | - # Create a new tag with the bumped version - git tag -a "v${NEW_VERSION}" -m "Release version ${NEW_VERSION}" - # Push the tag to the remote repository - git push origin "v${NEW_VERSION}" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d3e38d3..be604bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "mcphub" -version = "0.1.6" +version = "0.1.7" description = "A Python package for managing and integrating Model Context Protocol (MCP) servers with AI frameworks like OpenAI Agents, LangChain, and Autogen" readme = "README.md" authors = [