Build and release python package with uv and GitHub Actions workflows
Tag and release python package with uv and GitHub Actions workflows The goal of this article is to build and release python package using uv (for building and publishing) and github actions (for automation). Build and publish name: Package on: push: tags: - "v*.*.*" workflow_dispatch: jobs: build: name: "Build and publish package" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # for git-versionning - name: Install the latest version of uv uses: astral-sh/setup-uv@v6 with: enable-cache: true - name: Build dist run: uv build - name: Publish packages run: uv publish --token ${{ secrets.TWINE_PASSWORD }} [Optional] Deploy to server jobs: deploy: needs: - build runs-on: ubuntu-latest steps: - name: Deploy to the server uses: https://github.com/appleboy/ssh-action@master with: host: ${{ vars.HOST_MACHINE }} username: ${{ secrets.HOST_SSH_USER }} key: ${{ secrets.HOST_SSH_KEY }} script: | pip install --force-reinstall <package> [Optional] Custom PyPI Package Registry If you are using custom PyPI Package Registry/Index (such as gitea), you can use uv.index entry in pyproject.toml: ...