Cache docker #50
Workflow file for this run
This file contains 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: 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 Poetry | |
env: | |
PIP_CONSTRAINT: .github/workflows/constraints.txt | |
run: | | |
pipx install poetry | |
pipx inject poetry poetry-dynamic-versioning[plugin] | |
poetry --version | |
poetry self show plugins | |
- name: Build a binary wheel and a source tarball | |
run: | | |
poetry build | |
ls -l dist | |
- name: Set version | |
id: set_version | |
run: | | |
version=$(poetry version --short) | |
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 |