Skip to content

Commit 3bd0367

Browse files
committed
Refine github actions
1 parent 96aa462 commit 3bd0367

11 files changed

Lines changed: 106 additions & 218 deletions

File tree

.github/workflows/README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,38 @@ This directory contains automated workflows for CI/CD.
1111
**What it does**:
1212
- Runs tests on multiple platforms (Ubuntu, macOS, Windows)
1313
- Tests with Node.js 18 and 20
14-
- Builds Python package
14+
- Tests Python package build
1515
- Lints code and checks grammar
1616

1717
**Status Badge**:
1818
```markdown
1919
![CI](https://github.com/3swordman/tree-sitter-toon/workflows/CI/badge.svg)
2020
```
2121

22-
### 2. Publish to PyPI (`publish.yml`)
22+
### 2. Build and Publish to PyPI (`publish.yml`)
2323

2424
**Triggers**:
25-
- Automatically on GitHub Release (publishes to PyPI)
26-
- Manually via workflow dispatch (choose Test PyPI or PyPI)
25+
- **Automatic**: When you push a tag (e.g., `v0.1.0`)
26+
- **Manual**: Via workflow dispatch (choose Test PyPI or PyPI)
2727

2828
**What it does**:
29-
- Builds Python package
30-
- Checks package integrity
31-
- Publishes to Test PyPI or PyPI
32-
- Uploads artifacts
29+
- Builds wheels for **all platforms**:
30+
- Linux (x86_64, aarch64) - manylinux
31+
- macOS (x86_64, arm64) - Intel and Apple Silicon
32+
- Windows (AMD64)
33+
- Builds wheels for **Python 3.10, 3.11, 3.12**
34+
- Builds source distribution
35+
- Tests all packages
36+
- Publishes to PyPI automatically
37+
38+
**Total build time**: ~30-40 minutes
3339

3440
**Manual Trigger**:
3541
1. Go to Actions tab
36-
2. Select "Publish to PyPI"
42+
2. Select "Build and Publish to PyPI"
3743
3. Click "Run workflow"
3844
4. Choose destination (testpypi/pypi)
3945

40-
### 3. Create Release (`release.yml`)
41-
42-
**Triggers**:
43-
- Automatically when you push a version tag (e.g., `v0.1.0`)
44-
- Manually via workflow dispatch
45-
46-
**What it does**:
47-
- Generates changelog from git commits
48-
- Creates GitHub Release
49-
- Marks as pre-release if version contains alpha/beta/rc
50-
5146
## Setup Required
5247

5348
### 1. PyPI API Tokens
@@ -74,19 +69,23 @@ Ensure the repository has these permissions:
7469

7570
### Publishing a Release
7671

77-
**Method 1: Tag-based (Automatic)**
72+
**Method 1: Tag-based (Automatic)** ⭐ Recommended
7873
```bash
7974
# Update version in pyproject.toml to 0.1.0
8075

8176
git add pyproject.toml
8277
git commit -m "Bump version to 0.1.0"
83-
git tag v0.1.0
8478
git push origin main
79+
80+
git tag v0.1.0
8581
git push origin v0.1.0
8682

87-
# This triggers:
88-
# 1. create-release.yml → Creates GitHub Release
89-
# 2. publish.yml → Publishes to PyPI
83+
# This automatically:
84+
# 1. Builds wheels for all platforms (Linux, macOS, Windows)
85+
# 2. Builds wheels for Python 3.10, 3.11, 3.12
86+
# 3. Builds source distribution
87+
# 4. Publishes everything to PyPI
88+
# 5. Takes ~30-40 minutes total
9089
```
9190

9291
**Method 2: Manual Release**

.github/workflows/build-wheels.yml

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

.github/workflows/ci.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
retention-days: 7
5252

5353
build-python:
54-
name: Build Python Package
54+
name: Test Python Package Build
5555
runs-on: ubuntu-latest
5656

5757
steps:
@@ -66,20 +66,13 @@ jobs:
6666
- name: Install build dependencies
6767
run: |
6868
python -m pip install --upgrade pip
69-
pip install build twine
69+
pip install build twine cibuildwheel
7070
71-
- name: Build package
72-
run: python -m build
71+
- name: Build source distribution
72+
run: python -m build --sdist
7373

7474
- name: Check package
7575
run: twine check dist/*
76-
77-
- name: Upload artifacts
78-
uses: actions/upload-artifact@v4
79-
with:
80-
name: python-dist
81-
path: dist/
82-
retention-days: 7
8376

8477
lint:
8578
name: Lint Code

.github/workflows/publish.yml

Lines changed: 72 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
name: Publish to PyPI
1+
name: Build and Publish to PyPI
22

33
on:
4-
release:
5-
types: [published]
4+
push:
5+
tags:
6+
- 'v*.*.*'
67
workflow_dispatch:
78
inputs:
89
publish_to:
@@ -15,58 +16,74 @@ on:
1516
- pypi
1617

1718
jobs:
18-
publish:
19-
name: Build and Publish Package
19+
build_wheels:
20+
name: Build wheels on ${{ matrix.os }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Build wheels
30+
uses: pypa/cibuildwheel@v2.16.5
31+
env:
32+
CIBW_BUILD: cp310-* cp311-* cp312-*
33+
CIBW_SKIP: "*-musllinux_*"
34+
CIBW_ARCHS_MACOS: x86_64 arm64
35+
CIBW_ARCHS_LINUX: x86_64 aarch64
36+
CIBW_ARCHS_WINDOWS: AMD64
37+
38+
- uses: actions/upload-artifact@v4
39+
with:
40+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
41+
path: ./wheelhouse/*.whl
42+
43+
build_sdist:
44+
name: Build source distribution
2045
runs-on: ubuntu-latest
21-
2246
steps:
23-
- name: Checkout code
24-
uses: actions/checkout@v4
25-
26-
- name: Set up Python
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: '3.10'
30-
31-
- name: Install dependencies
32-
run: |
33-
python -m pip install --upgrade pip
34-
pip install build twine setuptools wheel
35-
36-
- name: Build package (source distribution only)
37-
run: python -m build --sdist
38-
39-
# Note: Binary wheels require proper manylinux/macosx tags
40-
# Users will build locally from source distribution
41-
42-
- name: Check package
43-
run: twine check dist/*
44-
45-
- name: List built files
46-
run: |
47-
echo "::group::Built packages"
48-
ls -lh dist/
49-
echo "::endgroup::"
50-
51-
- name: Publish to Test PyPI
52-
if: github.event.inputs.publish_to == 'testpypi' || github.event_name != 'release'
53-
env:
54-
TWINE_USERNAME: __token__
55-
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
56-
run: |
57-
twine upload --repository testpypi dist/* --verbose
58-
59-
- name: Publish to PyPI
60-
if: github.event.inputs.publish_to == 'pypi' || (github.event_name == 'release' && !github.event.release.prerelease)
61-
env:
62-
TWINE_USERNAME: __token__
63-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
64-
run: |
65-
twine upload dist/* --verbose
47+
- uses: actions/checkout@v4
48+
49+
- name: Build sdist
50+
run: pipx run build --sdist
51+
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: cibw-sdist
55+
path: dist/*.tar.gz
56+
57+
upload_pypi:
58+
needs: [build_wheels, build_sdist]
59+
runs-on: ubuntu-latest
60+
environment:
61+
name: pypi
62+
url: https://pypi.org/p/tree-sitter-toon
63+
permissions:
64+
id-token: write
6665

67-
- name: Upload build artifacts
68-
uses: actions/upload-artifact@v4
69-
with:
70-
name: dist-packages
71-
path: dist/
72-
retention-days: 30
66+
steps:
67+
- uses: actions/download-artifact@v4
68+
with:
69+
pattern: cibw-*
70+
path: dist
71+
merge-multiple: true
72+
73+
- name: List all files
74+
run: ls -lh dist/
75+
76+
- name: Publish to Test PyPI
77+
if: github.event.inputs.publish_to == 'testpypi'
78+
uses: pypa/gh-action-pypi-publish@release/v1
79+
with:
80+
repository-url: https://test.pypi.org/legacy/
81+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
82+
skip-existing: true
83+
84+
- name: Publish to PyPI
85+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish_to == 'pypi'
86+
uses: pypa/gh-action-pypi-publish@release/v1
87+
with:
88+
password: ${{ secrets.PYPI_API_TOKEN }}
89+
skip-existing: true

.github/workflows/release.yml

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

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)