Skip to content

Commit 390cfef

Browse files
Allow2CEOruvnet
andcommitted
Add CI/CD and build scripts
GitHub Actions CI (Python 3.9-3.13, pytest), publish workflow (PyPI via OIDC trusted publishing on tag push), bump-version.sh (PEP 440 version management with tag-based releases). Co-Authored-By: claude-flow <ruv@ruv.net>
1 parent bcb7466 commit 390cfef

3 files changed

Lines changed: 152 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
15+
16+
name: Python ${{ matrix.python }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python }}
25+
26+
- name: Install dependencies
27+
run: pip install -e .[dev]
28+
29+
- name: Run tests
30+
run: pytest --cov=allow2_service --cov-report=term-missing

.github/workflows/publish.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
13+
contents: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.12'
22+
23+
- name: Install build dependencies
24+
run: pip install build
25+
26+
- name: Install package with dev dependencies
27+
run: pip install -e .[dev]
28+
29+
- name: Run tests
30+
run: pytest
31+
32+
- name: Build package
33+
run: python -m build
34+
35+
- name: Publish to PyPI
36+
uses: pypa/gh-action-pypi-publish@release/v1
37+
38+
- name: Create GitHub Release
39+
uses: softprops/action-gh-release@v2
40+
with:
41+
generate_release_notes: true
42+
body: |
43+
## Installation
44+
45+
```bash
46+
pip install allow2-service
47+
```
48+
49+
See [PyPI](https://pypi.org/project/allow2-service/) for details.

scripts/bump-version.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
# bump-version.sh -- Standardised version bumping for Allow2 Python Service SDK
3+
# Usage: ./scripts/bump-version.sh [prerelease|patch|minor|major] [--preid alpha|beta|rc]
4+
#
5+
# Python uses pyproject.toml version + git tags.
6+
# PyPI reads version from pyproject.toml.
7+
#
8+
# Examples:
9+
# ./scripts/bump-version.sh prerelease --preid alpha # 2.0.0a1 -> 2.0.0a2
10+
# ./scripts/bump-version.sh patch # 2.0.0 -> 2.0.1
11+
set -euo pipefail
12+
cd "$(dirname "$0")/.."
13+
14+
BUMP="${1:-prerelease}"
15+
PREID=""
16+
if [[ "${2:-}" == "--preid" ]]; then PREID="${3:-alpha}"; fi
17+
18+
# Get latest version tag
19+
OLD=$(git tag -l 'v*' --sort=-v:refname | head -1 | sed 's/^v//')
20+
if [[ -z "$OLD" ]]; then
21+
echo "No version tags found. Create one first: git tag v2.0.0a1" >&2
22+
exit 1
23+
fi
24+
25+
# Parse: 2.0.0 or 2.0.0a1 or 2.0.0-alpha.1
26+
if [[ "$OLD" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(([a-z]+)([0-9]+))?$ ]]; then
27+
MAJOR="${BASH_REMATCH[1]}"
28+
MINOR="${BASH_REMATCH[2]}"
29+
PATCH="${BASH_REMATCH[3]}"
30+
PRE_TYPE="${BASH_REMATCH[5]:-}"
31+
PRE_NUM="${BASH_REMATCH[6]:-}"
32+
elif [[ "$OLD" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-([a-z]+)\.([0-9]+))?$ ]]; then
33+
MAJOR="${BASH_REMATCH[1]}"
34+
MINOR="${BASH_REMATCH[2]}"
35+
PATCH="${BASH_REMATCH[3]}"
36+
PRE_TYPE="${BASH_REMATCH[5]:-}"
37+
PRE_NUM="${BASH_REMATCH[6]:-}"
38+
else
39+
echo "Cannot parse version: $OLD" >&2; exit 1
40+
fi
41+
42+
case "$BUMP" in
43+
prerelease)
44+
PRE="${PREID:-${PRE_TYPE:-a}}"
45+
# Map preid to PEP 440: alpha->a, beta->b, rc->rc
46+
case "$PRE" in
47+
alpha) PEP="a" ;;
48+
beta) PEP="b" ;;
49+
rc) PEP="rc" ;;
50+
*) PEP="$PRE" ;;
51+
esac
52+
if [[ "$PRE_TYPE" == "$PEP" && -n "$PRE_NUM" ]]; then
53+
NEW="${MAJOR}.${MINOR}.${PATCH}${PEP}$((PRE_NUM + 1))"
54+
else
55+
NEW="${MAJOR}.${MINOR}.${PATCH}${PEP}1"
56+
fi
57+
;;
58+
patch) NEW="$MAJOR.$MINOR.$((PATCH + 1))" ;;
59+
minor) NEW="$MAJOR.$((MINOR + 1)).0" ;;
60+
major) NEW="$((MAJOR + 1)).0.0" ;;
61+
*) echo "Usage: $0 [prerelease|patch|minor|major] [--preid alpha|beta|rc]" >&2; exit 1 ;;
62+
esac
63+
64+
echo "$OLD -> $NEW"
65+
66+
# Update pyproject.toml
67+
sed -i "s/^version = \".*\"/version = \"$NEW\"/" pyproject.toml
68+
69+
# Update __init__.py
70+
sed -i "s/^__version__ = \".*\"/__version__ = \"$NEW\"/" allow2_service/__init__.py
71+
72+
git tag "v$NEW"
73+
echo "Tagged v$NEW -- push with: git push origin master --tags"

0 commit comments

Comments
 (0)