Replace poetry-based dependency and version management with uv an…
#1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Version and Build | |
| on: | |
| push: | |
| branches: [develop, main, 'release/**', 'hotfix/**', 'feature/**', 'issue/**', 'issues/**', 'docs/**'] | |
| workflow_dispatch: | |
| env: | |
| PYTHON_VERSION: "3.10" | |
| jobs: | |
| # First run tests | |
| run_tests: | |
| uses: ./.github/workflows/run_tests.yml | |
| secrets: | |
| codecov_token: ${{ secrets.CODECOV_TOKEN }} | |
| # Main build job | |
| build: | |
| needs: run_tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 # Need history for auto-bump script | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Install bump-my-version | |
| run: uv pip install --system bump-my-version | |
| - name: Configure git | |
| run: | | |
| git config user.name "ncompare-bot" | |
| git config user.email "ncompare@noreply.github.com" | |
| - name: Bump version | |
| id: version | |
| run: | | |
| BRANCH="${GITHUB_REF#refs/heads/}" | |
| echo "Processing branch: $BRANCH" | |
| case "$BRANCH" in | |
| develop) | |
| echo "📦 Bumping develop alpha" | |
| bump-my-version bump pre_number | |
| VENUE=sit | |
| PUBLISH=true | |
| ;; | |
| release/*) | |
| echo "🎯 Bumping release" | |
| CURRENT=$(bump-my-version show current_version) | |
| if [[ "$CURRENT" == *"a"* ]]; then | |
| echo " First release push: Alpha → RC1" | |
| bump-my-version bump pre_label | |
| # Auto-bump develop to next minor | |
| echo "" | |
| RELEASE_VERSION="${BRANCH#release/}" | |
| bash scripts/bump_develop_after_release.sh "$RELEASE_VERSION" | |
| echo "" | |
| # Return to release branch | |
| git checkout "$BRANCH" | |
| else | |
| echo " Incrementing RC" | |
| bump-my-version bump pre_number | |
| fi | |
| VENUE=uat | |
| PUBLISH=true | |
| ;; | |
| main) | |
| echo "🎉 Stripping to final release" | |
| bump-my-version bump pre_label | |
| VENUE=ops | |
| PUBLISH=true | |
| TAG=true | |
| ;; | |
| hotfix/*) | |
| echo "🔧 Bumping hotfix patch" | |
| CURRENT=$(bump-my-version show current_version) | |
| if [[ "$CURRENT" == *"rc"* ]] || [[ "$CURRENT" == *"a"* ]]; then | |
| echo " Stripping pre-release label first" | |
| bump-my-version bump pre_label | |
| fi | |
| bump-my-version bump patch | |
| VENUE=ops | |
| PUBLISH=true | |
| ;; | |
| feature/*|issue/*|issues/*|docs/*) | |
| echo "🌟 Feature branch: adding local identifier" | |
| CURRENT=$(bump-my-version show current_version) | |
| LOCAL_ID="+$(git rev-parse --short ${GITHUB_SHA})" | |
| VERSION="${CURRENT}${LOCAL_ID}" | |
| VENUE=dev | |
| PUBLISH=false | |
| ;; | |
| *) | |
| echo "⏭️ Unknown branch, no version bump" | |
| CURRENT=$(bump-my-version show current_version) | |
| VERSION="$CURRENT" | |
| VENUE=dev | |
| PUBLISH=false | |
| ;; | |
| esac | |
| # Set VERSION if not already set (for feature branches) | |
| if [ -z "$VERSION" ]; then | |
| VERSION=$(bump-my-version show current_version) | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "venue=$VENUE" >> $GITHUB_OUTPUT | |
| echo "publish=$PUBLISH" >> $GITHUB_OUTPUT | |
| echo "tag=${TAG:-false}" >> $GITHUB_OUTPUT | |
| echo "" | |
| echo "📌 Version: $VERSION" | |
| echo "🎯 Venue: $VENUE" | |
| - name: Commit version bump | |
| if: | | |
| github.ref == 'refs/heads/develop' || | |
| github.ref == 'refs/heads/main' || | |
| startsWith(github.ref, 'refs/heads/release/') || | |
| startsWith(github.ref, 'refs/heads/hotfix/') | |
| run: | | |
| if [[ -n $(git status -s) ]]; then | |
| git commit -am "Bump version to ${{ steps.version.outputs.version }} [skip ci]" | |
| git push | |
| echo "✅ Version bumped and committed" | |
| else | |
| echo "ℹ️ No version changes to commit" | |
| fi | |
| - name: Create Git tag | |
| if: | | |
| github.ref == 'refs/heads/develop' || | |
| github.ref == 'refs/heads/main' || | |
| startsWith(github.ref, 'refs/heads/release/') | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| git tag -a "$VERSION" -m "Version $VERSION" | |
| git push origin "$VERSION" | |
| echo "✅ Tagged $VERSION" | |
| - name: Install dependencies | |
| run: uv sync --extra dev | |
| - name: Build package | |
| run: uv build | |
| - name: Upload Python artifact | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: python-artifact | |
| path: dist/* | |
| - name: Publish to Test PyPI | |
| if: steps.version.outputs.publish == 'true' && steps.version.outputs.venue == 'uat' | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN_TESTPYPI }} | |
| run: uv publish --publish-url https://test.pypi.org/legacy/ | |
| - name: Publish to PyPI | |
| if: steps.version.outputs.publish == 'true' && steps.version.outputs.venue == 'ops' | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN_PYPI }} | |
| run: uv publish |