From ce638a54e835fdbb2e0361376a2756f0341aaed2 Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Tue, 14 Apr 2026 17:58:03 +1000 Subject: [PATCH 1/4] Revert "Fix scm part 3" This reverts commit 6b46a64980243b4deeab6bb242af34364174dbf6. --- .github/workflows/publish-pypi.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 48610305e..759632398 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -19,6 +19,10 @@ jobs: with: fetch-depth: 0 + - name: Get tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + shell: bash + - uses: actions/setup-python@v6 with: python-version: "3.12" From 16484fb406bf6ef6cca10328f4f0e85ce58d7b56 Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Tue, 14 Apr 2026 17:58:07 +1000 Subject: [PATCH 2/4] Revert "Fix scm not working (#683)" This reverts commit 13f6efa363aa796835c60ede64586b1d56d5fd21. --- .github/workflows/publish-pypi.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 759632398..b8b812bcd 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -7,8 +7,6 @@ on: concurrency: group: publish-pypi-{{ github.sha }} cancel-in-progress: false -env: - SETUPTOOLS_SCM_LOCAL_SCHEME: no-local-version jobs: build-packages: @@ -34,6 +32,8 @@ jobs: shell: bash - name: Build package + env: + SETUPTOOLS_SCM_LOCAL_SCHEME: no-local-version run: | python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine python -m build --sdist --wheel . --outdir dist @@ -152,6 +152,10 @@ jobs: with: fetch-depth: 0 + - name: Get tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + shell: bash + - uses: actions/setup-python@v6 with: python-version: "3.12" From 17b4c5c78606ae5e313c5875af115dfcaeff124d Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Tue, 14 Apr 2026 17:58:08 +1000 Subject: [PATCH 3/4] Revert "Fix scm not working (#682)" This reverts commit 99e85afbb7a07280e7f84252e9b264f46a109706. --- .github/workflows/publish-pypi.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index b8b812bcd..7c37dc6de 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -32,8 +32,6 @@ jobs: shell: bash - name: Build package - env: - SETUPTOOLS_SCM_LOCAL_SCHEME: no-local-version run: | python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine python -m build --sdist --wheel . --outdir dist From f8fd86583e0f37b1581851f3e734236a8b071730 Mon Sep 17 00:00:00 2001 From: Casper van Elteren Date: Tue, 14 Apr 2026 18:11:40 +1000 Subject: [PATCH 4/4] Chore: redo zenodo sync (#685) --- .github/workflows/publish-pypi.yml | 49 ++++++++++++----------- tools/release/publish_zenodo.py | 6 +++ tools/release/sync_citation.py | 62 ++++++++++++++++++++++++++---- 3 files changed, 87 insertions(+), 30 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 7c37dc6de..25b8069d6 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -1,11 +1,13 @@ name: Publish to PyPI + on: pull_request: push: - tags: ["v*"] + tags: + - "v*" concurrency: - group: publish-pypi-{{ github.sha }} + group: publish-pypi-${{ github.sha }} cancel-in-progress: false jobs: @@ -17,28 +19,25 @@ jobs: with: fetch-depth: 0 - - name: Get tags - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - shell: bash - - uses: actions/setup-python@v6 with: python-version: "3.12" - - name: Sync citation metadata for release tags - if: github.event_name == 'push' + - name: Ensure clean tree before build run: | - python tools/release/sync_citation.py --tag "${GITHUB_REF_NAME}" + git diff --quiet || (git status --short && git diff && exit 1) shell: bash - name: Build package run: | - python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine + python -m pip install --upgrade pip + python -m pip install wheel setuptools setuptools_scm build twine python -m build --sdist --wheel . --outdir dist + shell: bash - name: Check files run: | - ls dist + ls -lah dist shell: bash - name: Test wheels @@ -84,7 +83,7 @@ jobs: - name: Check files run: | - ls dist + ls -lah dist shell: bash - name: Publish to TestPyPI @@ -97,11 +96,11 @@ jobs: publish-pypi: name: Publish to PyPI needs: publish-pypi-test + if: github.event_name == 'push' environment: name: prod url: https://pypi.org/project/ultraplot/ runs-on: ubuntu-latest - if: github.event_name == 'push' permissions: id-token: write contents: read @@ -114,7 +113,7 @@ jobs: - name: Check files run: | - ls dist + ls -lah dist shell: bash - name: Publish to PyPI @@ -150,17 +149,14 @@ jobs: with: fetch-depth: 0 - - name: Get tags - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - shell: bash - - uses: actions/setup-python@v6 with: python-version: "3.12" - name: Install release tooling run: | - python -m pip install --upgrade pip PyYAML + python -m pip install --upgrade pip + python -m pip install PyYAML shell: bash - name: Download artifacts @@ -169,12 +165,21 @@ jobs: name: dist-${{ github.sha }}-${{ github.run_id }}-${{ github.run_number }} path: dist - - name: Sync citation metadata for release tags + - name: Generate release citation metadata + run: | + python tools/release/sync_citation.py \ + --tag "${GITHUB_REF_NAME}" \ + --output "${RUNNER_TEMP}/CITATION.cff" + shell: bash + + - name: Check tree stayed clean run: | - python tools/release/sync_citation.py --tag "${GITHUB_REF_NAME}" + git diff --quiet || (git status --short && git diff && exit 1) shell: bash - name: Publish to Zenodo run: | - python tools/release/publish_zenodo.py --dist-dir dist + python tools/release/publish_zenodo.py \ + --dist-dir dist \ + --citation-file "${RUNNER_TEMP}/CITATION.cff" shell: bash diff --git a/tools/release/publish_zenodo.py b/tools/release/publish_zenodo.py index 754e3e8fa..db57689ce 100644 --- a/tools/release/publish_zenodo.py +++ b/tools/release/publish_zenodo.py @@ -42,6 +42,12 @@ def parse_args() -> argparse.Namespace: default=Path("CITATION.cff"), help="Path to the repository CITATION.cff file.", ) + parser.add_argument( + "--citation-file", + type=Path, + default=Path("CITATION.cff"), + help="Path to the citation metadata file to upload.", + ) parser.add_argument( "--pyproject", type=Path, diff --git a/tools/release/sync_citation.py b/tools/release/sync_citation.py index 3597ea1c4..3104ebe31 100644 --- a/tools/release/sync_citation.py +++ b/tools/release/sync_citation.py @@ -20,7 +20,16 @@ def parse_args() -> argparse.Namespace: "--citation", type=Path, default=Path("CITATION.cff"), - help="Path to the repository CITATION.cff file.", + help="Path to the source CITATION.cff file.", + ) + parser.add_argument( + "--output", + type=Path, + default=None, + help=( + "Optional output path for the synced citation file. " + "Defaults to overwriting --citation." + ), ) parser.add_argument( "--date", @@ -78,21 +87,40 @@ def replace_scalar(text: str, key: str, value: str) -> str: return updated -def sync_citation( +def build_synced_citation( citation_path: Path, *, tag: str, release_date: str | None = None, repo_root: Path | None = None, - check: bool = False, -) -> bool: +) -> tuple[str, str, bool]: repo_root = repo_root or citation_path.resolve().parent version = tag_version(tag) release_date = release_date or resolve_release_date(tag, repo_root) + original = citation_path.read_text(encoding="utf-8") updated = replace_scalar(original, "version", version) updated = replace_scalar(updated, "date-released", release_date) changed = updated != original + return original, updated, changed + + +def sync_citation( + citation_path: Path, + *, + tag: str, + output_path: Path | None = None, + release_date: str | None = None, + repo_root: Path | None = None, + check: bool = False, +) -> bool: + original, updated, changed = build_synced_citation( + citation_path, + tag=tag, + release_date=release_date, + repo_root=repo_root, + ) + if check: if changed: raise SystemExit( @@ -100,22 +128,40 @@ def sync_citation( "Run tools/release/sync_citation.py before releasing." ) return False - citation_path.write_text(updated, encoding="utf-8") + + destination = output_path or citation_path + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_text(updated, encoding="utf-8") return changed def main() -> int: args = parse_args() + destination = args.output or args.citation + changed = sync_citation( args.citation, tag=args.tag, + output_path=args.output, release_date=args.date, repo_root=Path.cwd(), check=args.check, ) - action = "Validated" if args.check else "Updated" - print(f"{action} {args.citation} for {normalize_tag(args.tag)}.") - return 0 if (args.check or changed or not changed) else 0 + + if args.check: + print(f"Validated {args.citation} for {normalize_tag(args.tag)}.") + else: + source = args.citation.resolve() + dest = destination.resolve() + if source == dest: + print(f"Updated {args.citation} for {normalize_tag(args.tag)}.") + else: + print( + f"Wrote synced citation metadata from {args.citation} " + f"to {destination} for {normalize_tag(args.tag)}." + ) + + return 0 if __name__ == "__main__":