From 2fe3e8d1ebba2075126fdfb7ee819d5c60e9a996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= <16805946+edgarrmondragon@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:02:41 -0600 Subject: [PATCH] ci: Use `hynek/build-and-inspect-python-package` (#2142) * ci: Use `hynek/build-and-inspect-python-package` * Use dynamic versioning * Fetch tags in tests --- .github/workflows/constraints.txt | 1 + .github/workflows/release.yml | 51 ++++++++++--------------------- .github/workflows/test.yml | 6 ++++ pyproject.toml | 11 ++++--- 4 files changed, 30 insertions(+), 39 deletions(-) diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt index 9764b5cdf..cdfd9eb88 100644 --- a/.github/workflows/constraints.txt +++ b/.github/workflows/constraints.txt @@ -1,6 +1,7 @@ pip==23.3.2 poetry==1.7.1 poetry-plugin-export==1.6.0 +poetry-dynamic-versioning==1.2.0 pre-commit==3.6.0 nox==2023.4.22 nox-poetry==1.0.3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dff4f2043..6acae23e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,51 +2,32 @@ name: Release on: push: - tags: - - v* permissions: contents: write # Needed to upload artifacts to the release id-token: write # Needed for OIDC PyPI publishing jobs: - release: - name: Publish to PyPI + build: runs-on: ubuntu-latest - environment: publishing - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 with: - python-version: "3.11" - - - name: Upgrade pip - env: - PIP_CONSTRAINT: .github/workflows/constraints.txt - run: | - pip install pip - pip --version - - - name: Install Poetry - env: - PIP_CONSTRAINT: .github/workflows/constraints.txt - run: | - pipx install poetry - poetry --version - - - name: Check version - run: | - version=$(poetry version | awk '{print $2}') - tag=$(echo "${{ github.ref }}" | awk '{split($0,p,"/"); print p[3]}') - if [ "v$version" != $tag ]; then echo "Release tag and package version do not match!"; exit 1; fi; - - - name: Build - run: poetry build + fetch-depth: 0 + - uses: hynek/build-and-inspect-python-package@v2 + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + environment: + name: publishing + url: https://pypi.org/p/singer-sdk + if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist - name: Upload wheel to release uses: svenstaro/upload-release-action@v2 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0bfbadaa..5c430d871 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,6 +56,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install Poetry env: @@ -63,6 +65,7 @@ jobs: run: | pipx install poetry pipx inject poetry poetry-plugin-export + pipx inject poetry poetry-dynamic-versioning[plugin] poetry --version poetry self show plugins @@ -117,6 +120,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install Poetry env: @@ -124,6 +129,7 @@ jobs: run: | pipx install poetry pipx inject poetry poetry-plugin-export + pipx inject poetry poetry-dynamic-versioning[plugin] poetry --version poetry self show plugins diff --git a/pyproject.toml b/pyproject.toml index cb7965d09..58cf69dc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "singer-sdk" -version = "0.34.1" +version = "0.0.0" description = "A framework for building Singer taps" authors = ["Meltano Team and Contributors "] maintainers = ["Meltano Team and Contributors "] @@ -174,7 +174,6 @@ prerelease_offset = 1 tag_format = "v$major.$minor.$patch$prerelease" version_files = [ "docs/conf.py:^release =", - "pyproject.toml:^version =", "cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml:singer-sdk", "cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml:singer-sdk", "cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml:singer-sdk", @@ -230,9 +229,13 @@ module = [ "pyarrow.*", # TODO: Remove when https://github.com/apache/arrow/issues/32609 if implemented and released ] +[tool.poetry-dynamic-versioning] +enable = true +style = "pep440" + [build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +requires = ["poetry-core==1.8.1", "poetry-dynamic-versioning==1.2.0"] +build-backend = "poetry_dynamic_versioning.backend" [tool.poetry.scripts] pytest11 = { reference = "singer_sdk:testing.pytest_plugin", extras = ["testing"], type = "console" }