Skip to content

Skip pip-compile in pre-commit.ci #61

Skip pip-compile in pre-commit.ci

Skip pip-compile in pre-commit.ci #61

Workflow file for this run

name: Build
on:
push:
workflow_dispatch:
inputs:
publish:
description: "Publish to PyPI?"
required: true
default: false
type: boolean
tag:
description: "Tag to use for release"
required: true
jobs:
build:
name: Build wheel and sdist
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag || github.ref }}
- uses: actions/[email protected]
with:
python-version: "3.11"
- name: Upgrade pip
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pip install pip
pip --version
- name: Install Hatch
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
hatch --version
- name: Build a binary wheel and a source tarball
run: |
hatch build
ls -l dist
- name: Set version
id: set_version
run: |
version=$(hatch version)
echo "version=$version" >> "$GITHUB_OUTPUT"
- uses: actions/[email protected]
with:
name: dist
path: dist
publish:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.publish == 'true'
runs-on: ubuntu-latest
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/citric
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Check version
run: |
version=${{ needs.build.outputs.version }}
tag=$(echo "${{ github.event.inputs.tag || github.ref }}" | awk '{split($0,p,"/"); print p[3]}')
if [ $version != $tag ]; then echo "Release tag and package version do not match!"; exit 1; fi;
- uses: actions/[email protected]
with:
name: dist
path: dist
- uses: pypa/[email protected]
# Move this up when PyPI supports signing
sign:
name: Sign the distribution package
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- uses: actions/[email protected]
with:
name: dist
path: dist
- uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- uses: svenstaro/upload-release-action@v2
with:
file: dist/**
tag: ${{ needs.build.outputs.version }}
overwrite: false
file_glob: true