Skip to content

Commit 96d4826

Browse files
chore: switch to tag-based releases
1 parent 7a643cf commit 96d4826

6 files changed

Lines changed: 85 additions & 33 deletions

File tree

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
name: Run Tests
1+
name: CI
22

33
on:
4-
pull_request:
54
push:
6-
branches:
7-
- master
5+
branches: [ master ]
6+
paths-ignore:
7+
- "README.md"
8+
tags:
9+
- "v*.*"
10+
pull_request:
11+
branches: [ master ]
812

913
jobs:
1014
lint:
@@ -33,8 +37,6 @@ jobs:
3337
POSTGRES_DB: postgres
3438
ports:
3539
- 5432:5432
36-
# The official postgres image does not expose a default Docker HEALTHCHECK,
37-
# so we define one explicitly for the GitHub Actions service container.
3840
options: >-
3941
--health-cmd "pg_isready -U postgres"
4042
--health-interval 10s
@@ -63,5 +65,37 @@ jobs:
6365
make install-test
6466
6567
- name: Run tests
66-
run: |
67-
make test
68+
run: make test
69+
70+
release:
71+
needs: tests
72+
runs-on: ubuntu-24.04
73+
74+
environment:
75+
name: pypi
76+
url: https://pypi.org/p/postgresql-proxy
77+
78+
permissions:
79+
id-token: write
80+
81+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
82+
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@v4
86+
with:
87+
fetch-depth: 0
88+
89+
- name: Set up Python
90+
uses: actions/setup-python@v5
91+
with:
92+
python-version: "3.13"
93+
94+
- name: Build release
95+
run: make dist
96+
97+
- name: List artifacts
98+
run: ls -lah dist/
99+
100+
- name: Publish package distributions to PyPI
101+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,6 @@ venv.bak/
111111

112112
# private config information
113113
config.yml
114+
115+
# Hatch VCS hook generates this file during build
116+
postgresql_proxy/version.py

Makefile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@ install: ## Install dependencies in local virtualenv folder
2020
(test `which virtualenv` || $(PIP_CMD) install virtualenv) && \
2121
(test -e $(VENV_DIR) || virtualenv $(VENV_OPTS) $(VENV_DIR)) && \
2222
($(VENV_RUN) && $(PIP_CMD) install --upgrade pip) && \
23-
(test ! -e requirements.txt || ($(VENV_RUN); $(PIP_CMD) install -r requirements.txt))
23+
(test ! -e requirements.txt || ($(VENV_RUN); $(PIP_CMD) install -r requirements.txt)) && \
24+
($(VENV_RUN); $(PIP_CMD) install -e .)
2425

25-
publish: ## Publish the library to the central PyPi repository
26-
($(VENV_RUN); pip install twine; python ./setup.py sdist && twine upload dist/*)
26+
dist: clean ## Build distribution packages
27+
python -m pip install -U build hatchling hatch-vcs
28+
python -m build
29+
30+
clean: ## Remove build artifacts
31+
rm -rf dist build *.egg-info postgresql_proxy/version.py
32+
33+
publish: dist ## Publish the library to the central PyPi repository
34+
($(VENV_RUN); pip install twine; twine upload dist/*)
2735

2836
install-test: install ## Install test dependencies in local virtualenv
2937
($(VENV_RUN); $(PIP_CMD) install -r $(TEST_REQS))
@@ -85,12 +93,12 @@ start-pg-and-test: ## Start local PostgreSQL container, run all tests, and clean
8593
exit $$status
8694

8795
ACT_CMD ?= act
88-
ACT_WORKFLOW ?= .github/workflows/tests.yml
96+
ACT_WORKFLOW ?= .github/workflows/build.yml
8997
ACT_JOB ?= tests
9098
ACT_PULL ?= false
9199
ACT_CONTAINER_ARCH ?= linux/arm64
92100

93101
test-act: ## Run the CI test workflow locally with act
94102
$(ACT_CMD) -W $(ACT_WORKFLOW) -j $(ACT_JOB) --pull=$(ACT_PULL) --container-architecture $(ACT_CONTAINER_ARCH)
95103

96-
.PHONY: usage install install-test install-lint clean publish lint start-postgres stop-postgres test test-act start-pg-and-test
104+
.PHONY: usage install install-test install-lint dist clean publish lint start-postgres stop-postgres test test-act start-pg-and-test

postgresql_proxy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from postgresql_proxy.version import __version__ # noqa

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[build-system]
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "postgresql-proxy"
7+
dynamic = ["version"]
8+
description = "Postgresql Proxy"
9+
readme = "README.md"
10+
requires-python = ">=3.10"
11+
license = { text = "Apache-2.0" }
12+
classifiers = [
13+
"Programming Language :: Python :: 3",
14+
"Programming Language :: Python :: 3.13",
15+
"License :: OSI Approved :: Apache Software License",
16+
"Topic :: Software Development :: Testing",
17+
]
18+
19+
[tool.ruff]
20+
exclude = ["postgresql_proxy/version.py"]
21+
22+
[tool.hatch.version]
23+
source = "vcs"
24+
25+
[tool.hatch.build.hooks.vcs]
26+
version-file = "postgresql_proxy/version.py"

setup.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)