From 3a91c1bd16284575664e76f1a4b87daff8b92cb7 Mon Sep 17 00:00:00 2001 From: Jeremy Lau <30300826+fdxmw@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:39:56 -0700 Subject: [PATCH] Set PyRTL's Python package version from `git tag`. This avoid keeping the latest version number in two places, `pyproject.toml` and `git tag`. Simplify instructions in release/README.md. Rename some GitHub workflow jobs to clarify their purpose. --- .github/workflows/python-release.yml | 7 ++----- .github/workflows/python-test.yml | 2 +- pyproject.toml | 11 ++++++++--- release/README.md | 10 ++-------- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index 18d9b872..afbcc50e 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -14,7 +14,6 @@ on: push jobs: # Verify that distribution archives can be built on every push. build: - name: Build and upload distribution archives runs-on: ubuntu-latest steps: @@ -35,8 +34,7 @@ jobs: compression-level: 0 # Publish distribution archive to TestPyPI on tag pushes. - publish-to-testpypi: - name: Publish distribution archives on TestPyPI + publish-testpypi: # Only publish to TestPyPI on tag pushes. if: startsWith(github.ref, 'refs/tags/') needs: @@ -62,8 +60,7 @@ jobs: # Publish distribution archive to PyPI on tag pushes. The 'pypi' environment # requires manual approval on GitHub, so this job won't start automatically. - publish-to-pypi: - name: Publish distribution archives on PyPI + publish-pypi: # Only publish to PyPI on tag pushes. if: startsWith(github.ref, 'refs/tags/') needs: diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 7252fc9b..d1ec9d1a 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -5,7 +5,7 @@ on: - pull_request jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: diff --git a/pyproject.toml b/pyproject.toml index f748ea03..51d7870d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,16 +3,18 @@ # This file configures PyRTL's distribution archives, which are built and # uploaded to PyPI with GitHub actions. # -# This configuration is based on the "Packaging Python Projects" tutorial at +# This configuration is roughly based on the "Packaging Python Projects" +# tutorial at # https://packaging.python.org/en/latest/tutorials/packaging-projects/ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] name = "pyrtl" -version = "0.11.0rc1" +# hatch-vcs determines the version number from the latest git tag. +dynamic = ["version"] authors = [ {name="Timothy Sherwood", email="sherwood@cs.ucsb.edu"}, {name="John Clow"}, @@ -46,3 +48,6 @@ svg = ["graphviz"] Homepage = "http://ucsbarchlab.github.io/PyRTL/" GitHub = "https://github.com/UCSBarchlab/PyRTL" Documentation = "https://pyrtl.readthedocs.io/" + +[tool.hatch.version] +source = "vcs" diff --git a/release/README.md b/release/README.md index 3d946ec8..aaaff9da 100644 --- a/release/README.md +++ b/release/README.md @@ -38,17 +38,11 @@ numbers. $ git clone git@github.com:UCSBarchlab/PyRTL.git pyrtl $ cd pyrtl ``` -2. Edit `pyproject.toml` by updating the `version =` line to `version = - "$NEW_VERSION"` -3. Commit this change: - ```shell - $ git commit pyproject.toml - ``` -4. Tag the new version: +2. Tag the new version: ```shell $ git tag $NEW_VERSION ``` -5. Push this change to GitHub. Tags are not pushed by default, so use: +3. Push this change to GitHub. Tags are not pushed by default, so use: ```shell $ git push origin $NEW_VERSION ```