Skip to content

Commit 5856f9d

Browse files
authored
fix: fix ci action (#51)
1 parent ef23bdc commit 5856f9d

File tree

14 files changed

+119
-90
lines changed

14 files changed

+119
-90
lines changed

.github/workflows/_build.yml

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
1-
name: _Build
1+
name: 15. _Build Distribution
22

33
on:
44
workflow_call:
5+
inputs:
6+
os_json:
7+
description: 'JSON string of OS to build on'
8+
required: false
9+
type: string
10+
default: '["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]'
11+
python_json:
12+
description: 'JSON string of Python versions'
13+
required: false
14+
type: string
15+
default: '["3.9", "3.10", "3.11", "3.12"]'
516
workflow_dispatch:
17+
inputs:
18+
os_json:
19+
description: 'JSON string of OS to build on'
20+
required: false
21+
default: '["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]'
22+
python_json:
23+
description: 'JSON string of Python versions'
24+
required: false
25+
default: '["3.9", "3.10", "3.11", "3.12"]'
626

727
jobs:
828
build-linux:
929
name: Build distribution on Linux (glibc 2.31) py${{ matrix.python-version }}
30+
# Only run if inputs.os_json contains 'ubuntu' or 'linux'
31+
if: contains(inputs.os_json, 'ubuntu') || contains(inputs.os_json, 'linux')
1032
runs-on: ubuntu-latest
1133
container: ubuntu:20.04
1234
env:
1335
DEBIAN_FRONTEND: noninteractive
1436
TZ: Etc/UTC
1537
strategy:
38+
fail-fast: false
1639
matrix:
17-
include:
18-
- python-version: '3.9'
19-
python-full: '3.9.18'
20-
- python-version: '3.10'
21-
python-full: '3.10.13'
22-
- python-version: '3.11'
23-
python-full: '3.11.8'
24-
- python-version: '3.12'
25-
python-full: '3.12.2'
26-
40+
python-version: ${{ fromJson(inputs.python_json) }}
41+
2742
steps:
2843
- name: Install system dependencies (Linux)
2944
run: |
@@ -39,10 +54,25 @@ jobs:
3954
- uses: actions/checkout@v4
4055
with:
4156
submodules: recursive
57+
fetch-depth: 0 # Required for setuptools_scm to detect version from git tags
4258

43-
- name: Build CPython ${{ matrix.python-full }} (Linux)
59+
- name: Build CPython (Dynamic Selection)
4460
run: |
45-
PYTHON_FULL="${{ matrix.python-full }}"
61+
# Map short version to full version for our specific build environment
62+
declare -A PYTHON_MAP
63+
PYTHON_MAP["3.9"]="3.9.18"
64+
PYTHON_MAP["3.10"]="3.10.13"
65+
PYTHON_MAP["3.11"]="3.11.8"
66+
PYTHON_MAP["3.12"]="3.12.2"
67+
68+
PYTHON_VERSION="${{ matrix.python-version }}"
69+
PYTHON_FULL="${PYTHON_MAP[$PYTHON_VERSION]}"
70+
71+
if [ -z "$PYTHON_FULL" ]; then
72+
echo "Error: Unknown python version $PYTHON_VERSION"
73+
exit 1
74+
fi
75+
4676
PYTHON_PREFIX="/opt/python/${PYTHON_FULL}"
4777
PYTHON_BIN="${PYTHON_PREFIX}/bin/python${{ matrix.python-version }}"
4878
if [ ! -x "$PYTHON_BIN" ]; then
@@ -80,7 +110,7 @@ jobs:
80110
run: uv sync
81111

82112
- name: Install build dependencies
83-
run: uv pip install setuptools pybind11 cmake wheel build
113+
run: uv pip install setuptools setuptools_scm pybind11 cmake wheel build
84114

85115
- name: Build package
86116
run: uv run python -m build
@@ -116,16 +146,23 @@ jobs:
116146

117147
build-other:
118148
name: Build distribution on ${{ matrix.os }}
149+
# Filter out ubuntu-latest from this job since it's handled by build-linux
150+
if: ${{ matrix.os != 'ubuntu-latest' }}
119151
runs-on: ${{ matrix.os }}
120152
strategy:
153+
fail-fast: false
121154
matrix:
122-
os: [macos-latest, macos-15-intel, windows-latest]
123-
python-version: ['3.9', '3.10', '3.11', '3.12']
155+
os: ${{ fromJson(inputs.os_json) }}
156+
python-version: ${{ fromJson(inputs.python_json) }}
157+
# Exclude ubuntu-latest from this matrix if it was passed in inputs
158+
exclude:
159+
- os: ubuntu-latest
124160

125161
steps:
126162
- uses: actions/checkout@v4
127163
with:
128164
submodules: recursive
165+
fetch-depth: 0 # Required for setuptools_scm to detect version from git tags
129166

130167
- name: Set up Python
131168
uses: actions/setup-python@v6
@@ -156,7 +193,7 @@ jobs:
156193
run: uv sync
157194

158195
- name: Install build dependencies
159-
run: uv pip install setuptools pybind11 cmake wheel build
196+
run: uv pip install setuptools setuptools_scm pybind11 cmake wheel build
160197

161198
- name: Build package
162199
run: uv run python -m build

.github/workflows/_codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: _CodeQL
1+
name: 14. _CodeQL Scan
22

33
on:
44
workflow_call:

.github/workflows/_lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: _Lint
1+
name: 11. _Lint Checks
22

33
on:
44
workflow_call:

.github/workflows/_publish.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: _Publish
1+
name: 16. _Publish Distribution
22

33
on:
44
workflow_call:
@@ -77,11 +77,19 @@ jobs:
7777
actions: read # Required for downloading artifacts from other runs
7878

7979
steps:
80-
- name: Download all the dists
80+
- name: Download all the dists (Same Run)
81+
if: inputs.build_run_id == ''
8182
uses: actions/download-artifact@v4
8283
with:
83-
# Use provided build_run_id, or fallback to current github.run_id (for same-workflow execution)
84-
run-id: ${{ inputs.build_run_id || github.run_id }}
84+
pattern: python-package-distributions-*
85+
path: dist/
86+
merge-multiple: true
87+
88+
- name: Download all the dists (Cross Run)
89+
if: inputs.build_run_id != ''
90+
uses: actions/download-artifact@v4
91+
with:
92+
run-id: ${{ inputs.build_run_id }}
8593
github-token: ${{ secrets.GITHUB_TOKEN }}
8694
pattern: python-package-distributions-*
8795
path: dist/
@@ -107,11 +115,19 @@ jobs:
107115
actions: read # Required for downloading artifacts from other runs
108116

109117
steps:
110-
- name: Download all the dists
118+
- name: Download all the dists (Same Run)
119+
if: inputs.build_run_id == ''
120+
uses: actions/download-artifact@v4
121+
with:
122+
pattern: python-package-distributions-*
123+
path: dist/
124+
merge-multiple: true
125+
126+
- name: Download all the dists (Cross Run)
127+
if: inputs.build_run_id != ''
111128
uses: actions/download-artifact@v4
112129
with:
113-
# Use provided build_run_id, or fallback to current github.run_id (for same-workflow execution)
114-
run-id: ${{ inputs.build_run_id || github.run_id }}
130+
run-id: ${{ inputs.build_run_id }}
115131
github-token: ${{ secrets.GITHUB_TOKEN }}
116132
pattern: python-package-distributions-*
117133
path: dist/

.github/workflows/_test_full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: _Test Full
1+
name: 13. _Test Suite (Full)
22

33
on:
44
workflow_call:

.github/workflows/_test_lite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: _Test Lite
1+
name: 12. _Test Suite (Lite)
22

33
on:
44
workflow_call:

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI (Main Branch)
1+
name: 02. Main Branch Checks
22

33
on:
44
push:

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pull Request Checks
1+
name: 01. Pull Request Checks
22

33
on:
44
pull_request:

.github/workflows/release.yml

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to PyPI
1+
name: 03. Release
22

33
on:
44
release:
@@ -15,59 +15,23 @@ on:
1515
- testpypi
1616
- pypi
1717
- both
18+
os_json:
19+
description: 'JSON string of OS to build on (Manual only)'
20+
required: false
21+
type: string
22+
default: '["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]'
23+
python_json:
24+
description: 'JSON string of Python versions (Manual only)'
25+
required: false
26+
type: string
27+
default: '["3.9", "3.10", "3.11", "3.12"]'
1828

1929
jobs:
20-
check-version:
21-
name: Verify Version
22-
runs-on: ubuntu-latest
23-
steps:
24-
- uses: actions/checkout@v4
25-
26-
- name: Set up Python
27-
uses: actions/setup-python@v6
28-
with:
29-
python-version: '3.11'
30-
31-
- name: Verify Tag matches pyproject.toml
32-
run: |
33-
python -c "
34-
import tomllib
35-
import os
36-
import sys
37-
38-
with open('pyproject.toml', 'rb') as f:
39-
data = tomllib.load(f)
40-
41-
proj_version = data['project']['version']
42-
ref = os.environ.get('GITHUB_REF', '')
43-
event_name = os.environ.get('GITHUB_EVENT_NAME', '')
44-
45-
print(f'Project version: {proj_version}')
46-
print(f'GitHub Ref: {ref}')
47-
print(f'Event Name: {event_name}')
48-
49-
# Strict check only for Release events or when a Tag is pushed
50-
if event_name == 'release' or ref.startswith('refs/tags/'):
51-
if ref.startswith('refs/tags/'):
52-
tag = ref.split('/')[-1]
53-
clean_tag = tag[1:] if tag.startswith('v') else tag
54-
55-
if clean_tag != proj_version:
56-
print(f'::error::Git Tag ({tag}) does not match pyproject.toml version ({proj_version})')
57-
sys.exit(1)
58-
59-
print(f'✅ Verification Successful: Tag {tag} matches project version {proj_version}')
60-
else:
61-
print('⚠️ Release event triggered but REF is not a tag? This is unexpected.')
62-
else:
63-
print(f'ℹ️ Manual trigger ({event_name}) on branch/commit. Skipping strict Tag vs Version check.')
64-
print(f' Current pyproject.toml version is: {proj_version}')
65-
print(' Make sure this is the version you intend to build/publish.')
66-
"
67-
6830
build:
69-
needs: [check-version]
7031
uses: ./.github/workflows/_build.yml
32+
with:
33+
os_json: ${{ inputs.os_json || '["ubuntu-latest", "macos-latest", "macos-15-intel", "windows-latest"]' }}
34+
python_json: ${{ inputs.python_json || '["3.9", "3.10", "3.11", "3.12"]' }}
7135

7236
publish:
7337
needs: [build]

.github/workflows/schedule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Weekly Security Scan
1+
name: 04. Weekly Security Scan
22

33
on:
44
schedule:

0 commit comments

Comments
 (0)