Skip to content

Commit

Permalink
ci: Use hynek/build-and-inspect-python-package (meltano#2142)
Browse files Browse the repository at this point in the history
* ci: Use `hynek/build-and-inspect-python-package`

* Use dynamic versioning

* Fetch tags in tests
  • Loading branch information
edgarrmondragon authored Jan 10, 2024
1 parent a79cff8 commit 2fe3e8d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 39 deletions.
1 change: 1 addition & 0 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -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
51 changes: 16 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Poetry
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install poetry
pipx inject poetry poetry-plugin-export
pipx inject poetry poetry-dynamic-versioning[plugin]
poetry --version
poetry self show plugins
Expand Down Expand Up @@ -117,13 +120,16 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Poetry
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install poetry
pipx inject poetry poetry-plugin-export
pipx inject poetry poetry-dynamic-versioning[plugin]
poetry --version
poetry self show plugins
Expand Down
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
maintainers = ["Meltano Team and Contributors <[email protected]>"]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit 2fe3e8d

Please sign in to comment.