Skip to content

Commit cff84bc

Browse files
author
Anonymous Committer
committed
chore: add GitHub Actions workflows for release automation and dynamic versioning configuration
1 parent 0aecaa4 commit cff84bc

File tree

3 files changed

+125
-1
lines changed

3 files changed

+125
-1
lines changed

.github/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
categories:
6+
- title: Features
7+
labels:
8+
- feature
9+
- enhancement
10+
- title: Fixes
11+
labels:
12+
- fix
13+
- bug
14+
- bugfix
15+
- title: Documentation
16+
labels:
17+
- docs
18+
- documentation
19+
- title: Maintenance
20+
labels:
21+
- chore
22+
- refactor
23+
- dependencies
24+
- title: Other Changes
25+
labels:
26+
- "*"

.github/workflows/release.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
19+
- name: Clean build artifacts
20+
run: rm -rf dist build ./*.egg-info
21+
22+
- name: Install dependencies
23+
run: python -m pip install -e '.[dev]' build twine 'packaging>=24.2'
24+
25+
- name: Verify tag matches package version
26+
env:
27+
GITHUB_REF_NAME: ${{ github.ref_name }}
28+
run: |
29+
python - <<'PY'
30+
import os
31+
from pathlib import Path
32+
33+
tag = os.environ["GITHUB_REF_NAME"]
34+
if not tag.startswith("v"):
35+
raise SystemExit(f"Release tags must start with 'v': {tag}")
36+
37+
namespace: dict[str, str] = {}
38+
exec(Path("justoneapi/_version.py").read_text(), namespace)
39+
package_version = namespace["__version__"]
40+
tag_version = tag.removeprefix("v")
41+
42+
if tag_version != package_version:
43+
raise SystemExit(
44+
f"Tag version {tag_version} does not match package version {package_version}"
45+
)
46+
47+
print(f"Validated release tag {tag} for package version {package_version}")
48+
PY
49+
50+
- name: Normalize OpenAPI
51+
run: python scripts/normalize_openapi.py
52+
53+
- name: Generate SDK
54+
run: python scripts/generate_sdk.py
55+
56+
- name: Ensure generated artifacts are committed
57+
run: git diff --exit-code -- openapi/public-api.normalized.json justoneapi/generated
58+
59+
- name: Run tests
60+
run: python -m pytest
61+
62+
- name: Build distributions
63+
run: python -m build
64+
65+
- name: Check distributions
66+
run: python -m twine check dist/*
67+
68+
- name: Upload distributions
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: python-dist
72+
path: dist/*
73+
74+
publish:
75+
needs: build
76+
runs-on: ubuntu-latest
77+
permissions:
78+
contents: write
79+
id-token: write
80+
81+
steps:
82+
- name: Download distributions
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: python-dist
86+
path: dist
87+
88+
- name: Publish to PyPI
89+
uses: pypa/gh-action-pypi-publish@release/v1
90+
91+
- name: Create GitHub release
92+
env:
93+
GH_TOKEN: ${{ github.token }}
94+
GITHUB_REF_NAME: ${{ github.ref_name }}
95+
run: gh release create "$GITHUB_REF_NAME" dist/* --generate-notes --title "$GITHUB_REF_NAME"

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "justoneapi"
3-
version = "2.0.0"
3+
dynamic = ["version"]
44
description = "OpenAPI-driven Python SDK for Just One API"
55
authors = [{ name = "Just One API", email = "support@justoneapi.com" }]
66
readme = "README.md"
@@ -24,6 +24,9 @@ build-backend = "setuptools.build_meta"
2424
[tool.setuptools.packages.find]
2525
include = ["justoneapi*"]
2626

27+
[tool.setuptools.dynamic]
28+
version = { attr = "justoneapi._version.__version__" }
29+
2730
[tool.pytest.ini_options]
2831
addopts = "-ra"
2932
testpaths = ["tests"]

0 commit comments

Comments
 (0)