Skip to content

Commit 35efeab

Browse files
committed
ci: add release logic
- mirror structure of RTB - use release-please - PyPI push now down by release action not Makefile
1 parent b16ab7d commit 35efeab

7 files changed

Lines changed: 152 additions & 15 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
labels:
8+
- "dependencies"

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
python-version: ["3.10", "3.11", "3.12", "3.13"]
1818

1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v6
2121

2222
- uses: mamba-org/setup-micromamba@v2
2323
with:
@@ -62,7 +62,7 @@ jobs:
6262
runs-on: ubuntu-latest
6363

6464
steps:
65-
- uses: actions/checkout@v4
65+
- uses: actions/checkout@v6
6666

6767
- uses: mamba-org/setup-micromamba@v2
6868
with:
@@ -102,6 +102,6 @@ jobs:
102102
micromamba run -n myenv coverage xml
103103
104104
- name: Upload to Codecov
105-
uses: codecov/codecov-action@v4
105+
- uses: codecov/codecov-action@v6
106106
with:
107107
file: ./coverage.xml

‎.github/workflows/commitlint.yml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Lint PR title
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
jobs:
8+
commitlint:
9+
name: Check PR title (Conventional Commits)
10+
runs-on: ubuntu-latest
11+
# Dependabot and release-please manage their own titles — skip them.
12+
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'github-actions[bot]' }}
13+
steps:
14+
- uses: amannn/action-semantic-pull-request@v5
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
with:
18+
types: |
19+
feat
20+
fix
21+
docs
22+
style
23+
refactor
24+
perf
25+
test
26+
build
27+
ci
28+
chore
29+
revert
30+
deps
31+
requireScope: false
32+
# release-please opens PRs like "chore: release 2.0.2" — allow those through
33+
ignoreLabels: |
34+
autorelease: pending
35+
autorelease: tagged
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
release-please:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: googleapis/release-please-action@v4
16+
with:
17+
config-file: release-please-config.json
18+
manifest-file: .release-please-manifest.json

‎.github/workflows/release.yml‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Build and publish to PyPI on GitHub release creation or manual trigger.
2+
# Uses OIDC trusted publishing — no stored PyPI token required.
3+
# Pure Python package — a universal wheel suffices; no cibuildwheel needed.
4+
5+
name: Release
6+
7+
on:
8+
release:
9+
types: [created]
10+
workflow_dispatch:
11+
12+
env:
13+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
14+
15+
jobs:
16+
verify_version:
17+
name: Verify tag matches package version
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v6
21+
- name: Check version
22+
# Skip check on manual workflow_dispatch runs (no release tag exists)
23+
if: github.event_name == 'release'
24+
run: |
25+
TAG="${GITHUB_REF_NAME#v}"
26+
PKG=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
27+
echo "Tag version : $TAG"
28+
echo "Package version: $PKG"
29+
[ "$TAG" = "$PKG" ] || { echo "ERROR: tag v$TAG does not match pyproject.toml version $PKG"; exit 1; }
30+
31+
build:
32+
name: Build sdist and wheel
33+
needs: verify_version
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v6
37+
38+
- uses: actions/setup-python@v6
39+
with:
40+
python-version: "3.12"
41+
42+
- name: Build sdist and wheel
43+
run: pipx run build
44+
45+
- uses: actions/upload-artifact@v4
46+
with:
47+
name: dist
48+
path: dist/
49+
50+
smoke_test:
51+
name: Smoke-test wheel
52+
needs: build
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/setup-python@v6
56+
with:
57+
python-version: "3.12"
58+
59+
- uses: actions/download-artifact@v4
60+
with:
61+
name: dist
62+
path: dist
63+
64+
- name: Install wheel (pulls deps from PyPI)
65+
run: pip install --find-links dist machinevision-toolbox-python
66+
67+
- name: Smoke test
68+
run: python -c "import machinevisiontoolbox; print('OK', machinevisiontoolbox.__version__)"
69+
70+
upload_pypi:
71+
name: Publish to PyPI
72+
needs: [build, smoke_test]
73+
runs-on: ubuntu-latest
74+
environment: pypi
75+
permissions:
76+
id-token: write # required for OIDC trusted publishing
77+
steps:
78+
- uses: actions/download-artifact@v4
79+
with:
80+
name: dist
81+
path: dist
82+
83+
- uses: pypa/gh-action-pypi-publish@release/v1
84+
with:
85+
skip_existing: true

‎.release-please-manifest.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "2.0.1"
3+
}

‎Makefile‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ help:
1414
@echo " make docs-strict - nitpicky Sphinx build with warnings treated as errors"
1515
@echo " make view - open Sphinx doco build (uses open for MacOS)"
1616
@echo " make dist - preview dist build"
17-
@echo " make pypi - build the dist, upload to PyPI, tag the release and push the tag to origin"
1817
@echo " make clean - remove dist and docs build files"
1918
@echo " make help - this message$(BLACK)"
2019

@@ -59,17 +58,6 @@ dist: .FORCE
5958
python -m build
6059
ls -lh dist/*
6160

62-
pypi: .FORCE
63-
@if ! git diff --quiet || ! git diff --cached --quiet; then \
64-
echo "Error: uncommitted changes present, aborting upload"; exit 1; \
65-
fi
66-
python -m build
67-
$(eval VERSION := $(shell grep '^version' pyproject.toml | sed 's/version = "\(.*\)"/\1/'))
68-
@echo "Uploading version $(VERSION) to PyPI"
69-
twine upload dist/*
70-
git tag v$(VERSION)
71-
git push origin v$(VERSION)
72-
7361
clean: .FORCE
7462
(cd docs; make clean)
7563
-rm -r *.egg-info

0 commit comments

Comments
 (0)