Skip to content

Commit e82889c

Browse files
authored
Use setuptools_scm to produce a version number dynamically (#97)
This will generate a version number automatically from tags in the repository. It will also produce a distinct development tag for each commit we make to the repository. This allows pushing intermediate package snapshots to TestPyPI in between official tags.
1 parent 008ea25 commit e82889c

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

.github/workflows/build-and-publish-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v5
1313
with:
14+
fetch-depth: 0 # fetch all history including tags -- necessary to determine the version from SCM
1415
persist-credentials: false
1516
- name: Set up Python
1617
uses: actions/setup-python@v5
@@ -29,8 +30,7 @@ jobs:
2930

3031
publish-to-testpypi:
3132
runs-on: ubuntu-latest
32-
if: startsWith(github.ref, 'refs/tags/') # only publish to test.PyPI on tag pushes (for the time being)
33-
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' # only publish to test.PyPI on pushes to main
33+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' # only publish to test.PyPI on pushes to main
3434

3535
name: Publish LNT to TestPyPI
3636
needs: [build]

.github/workflows/build-docker.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
21+
with:
22+
fetch-depth: 0 # fetch all history including tags -- necessary to determine the version from SCM
2123

2224
- name: Log in to the Container registry
2325
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
@@ -32,3 +34,4 @@ jobs:
3234
with:
3335
push: ${{ github.event_name == 'push' }}
3436
tags: ghcr.io/${{github.repository}}:latest
37+
context: . # use the current directory as context, as checked out by actions/checkout -- needed for setuptools_scm

.github/workflows/tox.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0 # fetch all history including tags -- necessary to determine the version from SCM
1820
- name: Set up Python ${{ matrix.python-version }}
1921
uses: actions/setup-python@v6
2022
with:

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["setuptools >= 74.1"]
2+
requires = ["setuptools>=80", "setuptools-scm>=8"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "llvm-lnt"
7-
version = "0.4.3"
7+
dynamic = ["version"]
88
description = "LLVM Nightly Test Infrastructure"
99
readme = "README.md"
1010
license = "LicenseRef-Apache-2.0-with-LLVM-exception"
@@ -98,6 +98,9 @@ find = {namespaces = false}
9898
"migrations/*.py"
9999
]
100100

101+
[tool.setuptools_scm]
102+
# This section is needed with older versions of Python, although it can be empty.
103+
101104
[tool.flake8]
102105
ignore = ["E712", "E402", "E711", "E266", "W605", "E126", "E226", "W504"]
103106
max-line-length = 120

0 commit comments

Comments
 (0)