Skip to content

Use uv to build package #213

Use uv to build package

Use uv to build package #213

Workflow file for this run

name: Build
on:
push:
tags:
- '*'
pull_request:
branches:
- '*'
workflow_dispatch:
jobs:
test:
continue-on-error: ${{ contains(matrix.job-prefix, 'experimental') }}
name: ${{ matrix.job-prefix }} test ${{ matrix.os }} Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
job-prefix: ['']
os: [ubuntu-latest, windows-latest]
python-version:
- '3.10'
- '3.11'
- '3.12'
# Uncomment the following lines to test with a not-yet supported Python version
# include:
# - job-prefix: 'experimental '
# os: ubuntu-latest
# python-version: '3.12-dev'
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: '0.4.17'
- name: Test
run: uv run --python ${{ matrix.python-version }} test.py
package:
needs: test
runs-on: ubuntu-latest
outputs:
release-name: ${{ steps.gather-release-info.outputs.release-name }}
release-body: ${{ steps.gather-release-info.outputs.release-body }}
is-prerelease: ${{ steps.gather-release-info.outputs.is-prerelease }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: '0.4.17'
- name: Set up Python
run: uv python install
- name: Build Package
run: uv build
- uses: actions/upload-artifact@v4
with:
path: dist/
name: dist
- name: Gather release info
id: gather-release-info
run: python tools/gather-release-info-for-github-actions.py
publish:
needs: package
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write # for creating the release
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Reject build if release name disagrees with tag
if: format('{0}{1}', 'refs/tags/', needs.package.outputs.release-name) != github.ref
run: |
echo "Tag ${{ github.ref }} does not match release name ${{ needs.package.outputs.release-name }}"
exit 1
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ needs.package.outputs.release-body }}
prerelease: ${{ needs.package.outputs.is-prerelease }}
draft: false
- name: Publish distribution package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1