diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6756721..81a66e2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -40,6 +40,7 @@ jobs: steps: - uses: actions/checkout@v7 with: + ref: ${{ github.ref }} fetch-depth: 0 persist-credentials: false @@ -50,11 +51,53 @@ jobs: - name: Install build tools run: python -m pip install --upgrade build twine + - name: Verify checked-out tag + env: + PACKAGE_DIR: ${{ needs.select-package.outputs.package }} + run: | + actual_tag="$(git describe --exact-match --tags --match="$PACKAGE_DIR-*")" + if [[ "$actual_tag" != "$GITHUB_REF_NAME" ]]; then + echo "::error::HEAD is tagged as $actual_tag, expected $GITHUB_REF_NAME" + exit 1 + fi + - name: Build ${{ needs.select-package.outputs.package }} env: PACKAGE_DIR: ${{ needs.select-package.outputs.package }} run: python -m build --outdir dist "$PACKAGE_DIR" + - name: Verify distribution metadata + env: + EXPECTED_PACKAGE: ${{ needs.select-package.outputs.package }} + EXPECTED_VERSION: ${{ needs.select-package.outputs.version }} + run: | + python - <<'PY' + import email + import os + from pathlib import Path + from zipfile import ZipFile + + wheels = list(Path("dist").glob("*.whl")) + if len(wheels) != 1: + raise RuntimeError(f"Expected one wheel, found: {wheels}") + + with ZipFile(wheels[0]) as wheel: + metadata_paths = [ + path for path in wheel.namelist() + if path.endswith(".dist-info/METADATA") + ] + if len(metadata_paths) != 1: + raise RuntimeError( + f"Expected one METADATA file, found: {metadata_paths}" + ) + metadata = email.message_from_bytes(wheel.read(metadata_paths[0])) + + actual = (metadata["Name"], metadata["Version"]) + expected = (os.environ["EXPECTED_PACKAGE"], os.environ["EXPECTED_VERSION"]) + if actual != expected: + raise RuntimeError(f"Built {actual}, expected {expected}") + PY + - name: Check distributions run: python -m twine check dist/* diff --git a/geoarrow-pandas/pyproject.toml b/geoarrow-pandas/pyproject.toml index 2b09039..609687d 100644 --- a/geoarrow-pandas/pyproject.toml +++ b/geoarrow-pandas/pyproject.toml @@ -42,7 +42,7 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] root = ".." tag_regex = '^geoarrow-pandas-(?P[0-9]+\.[0-9]+\.[0-9]+)$' -git_describe_command = "git describe --long --match='geoarrow-pandas-*'" +git_describe_command = "git describe --long --tags --match='geoarrow-pandas-*'" version_file = "src/geoarrow/pandas/_version.py" [tool.pytest.ini_options] diff --git a/geoarrow-pyarrow/pyproject.toml b/geoarrow-pyarrow/pyproject.toml index 007d29b..97dfb17 100644 --- a/geoarrow-pyarrow/pyproject.toml +++ b/geoarrow-pyarrow/pyproject.toml @@ -42,7 +42,7 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] root = ".." tag_regex = '^geoarrow-pyarrow-(?P[0-9]+\.[0-9]+\.[0-9]+)$' -git_describe_command = "git describe --long --match='geoarrow-pyarrow-*'" +git_describe_command = "git describe --long --tags --match='geoarrow-pyarrow-*'" version_file = "src/geoarrow/pyarrow/_version.py" [tool.pytest.ini_options] diff --git a/geoarrow-types/pyproject.toml b/geoarrow-types/pyproject.toml index ffd651f..82aaee0 100644 --- a/geoarrow-types/pyproject.toml +++ b/geoarrow-types/pyproject.toml @@ -42,7 +42,7 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] root = ".." tag_regex = '^geoarrow-types-(?P[0-9]+\.[0-9]+\.[0-9]+)$' -git_describe_command = "git describe --long --match='geoarrow-types-*'" +git_describe_command = "git describe --long --tags --match='geoarrow-types-*'" version_file = "src/geoarrow/types/_version.py" [tool.pytest.ini_options]