Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,58 @@ name: Publish Python 🐍 distributions 📦 to PyPI

on:
release:
# • `released` reacts to stable releases
# • `prereleased` reacts to pre-releases
# • `published` reacts to both
types: [published]

jobs:
build-n-publish:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
permissions:
id-token: write # for trusted publishing

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: actions/setup-python@v5

- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come it worked until now without this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have no clue, maybe it was a change in the way github action checkouts the source? I could have a look how we got to this point, but I also think that we started without this and it got added at some point

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weren't the scm tools dropped since then? 👀 if it's related to setuptools_scm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setuptools_scm is still around (

setup(use_scm_version={"version_scheme": "no-guess-dev"})
,
[tool.setuptools_scm]
).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pass fetch-depth to the checkout action?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually checking the options they have, but I was not able to combine it with the first fetch --prune --unshallow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of that command? If you simply want to do a full clone so that setuptools_scm works properly, you can set fetch-depth to 0. Or is there something else here?


- name: Build a source tarball and a binary wheel
# https://pypa-build.readthedocs.io
run: |
python -m pip install build
python -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish:
name: Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/specfile/
permissions:
id-token: write # for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish 📦 to PyPI
# https://github.com/pypa/gh-action-pypi-publish
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
Loading