88 - pyproject.toml
99 workflow_dispatch :
1010
11+ permissions :
12+ contents : write # Allow the action to push to the repository
13+
1114jobs :
15+ lint-and-fix :
16+ runs-on : ubuntu-latest
17+
18+ steps :
19+ # Step 1: Checkout the code
20+ - name : Checkout code
21+ uses : actions/checkout@v2
22+
23+ # Step 2: Set up Python
24+ - name : Set up Python
25+ uses : actions/setup-python@v2
26+ with :
27+ python-version : ' 3.x'
28+
29+ # Step 3: Install dependencies
30+ - name : Install dependencies
31+ run : |
32+ python -m pip install --upgrade pip
33+ pip install pylint autopep8
34+
35+ # Step 4: Run pylint on specified files
36+ - name : Run pylint on specified files
37+ id : pylint
38+ run : |
39+ pylint_output=$(pylint $(git ls-files '*.py' | grep -vE '(^tests/|^docs/)') --output-format=text) || true
40+ echo "$pylint_output"
41+ echo "::set-output name=pylint_output::$pylint_output"
42+
43+ # Step 5: Apply autopep8 fixes
44+ - name : Apply autopep8 fixes
45+ run : |
46+ autopep8 --in-place --aggressive --aggressive $(git ls-files '*.py' | grep -vE '(^tests/|^docs/)')
47+
48+ # Step 6: Commit and push changes directly to the main branch
49+ - name : Commit and push changes to main branch
50+ run : |
51+ git config --global user.name 'github-actions[bot]'
52+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
53+ git checkout main
54+ git add .
55+ git diff --cached --quiet || git commit -m "Auto-fix Linter and apply autopep8 changes"
56+ git push origin main
57+ env :
58+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59+ build-windows :
60+ runs-on : windows-latest
61+ steps :
62+ - name : Checkout code
63+ uses : actions/checkout@v2
64+
65+ - name : Compile for Windows (32-bit & 64-bit)
66+ run : |
67+ clang -shared -m32 -o restructuredpython/lib/io32.dll restructuredpython/include/io.c
68+ clang -shared -m64 -o restructuredpython/lib/io64.dll restructuredpython/include/io.c
69+
70+ - name : Upload Windows artifacts
71+ uses : actions/upload-artifact@v4
72+ with :
73+ name : windows-libs
74+ path : restructuredpython/lib/io*.dll
75+
76+ build-linux :
77+ runs-on : ubuntu-latest
78+ steps :
79+ - name : Checkout code
80+ uses : actions/checkout@v2
81+
82+ - name : Compile for Linux (.so)
83+ run : |
84+ gcc -shared -fPIC -o restructuredpython/lib/io.so restructuredpython/include/io.c
85+
86+ - name : Upload Linux artifacts
87+ uses : actions/upload-artifact@v4
88+ with :
89+ name : linux-libs
90+ path : restructuredpython/lib/io.so
91+
92+ build-macos :
93+ runs-on : macos-latest
94+ steps :
95+ - name : Checkout code
96+ uses : actions/checkout@v2
97+
98+ - name : Compile for macOS (.dylib)
99+ run : |
100+ clang -shared -fPIC -fdeclspec -o restructuredpython/lib/io.dylib restructuredpython/include/io.c
101+
102+ - name : Upload macOS artifacts
103+ uses : actions/upload-artifact@v4
104+ with :
105+ name : macos-libs
106+ path : restructuredpython/lib/io.dylib
12107 publish :
13- runs-on : ubuntu-latest # Use an Ubuntu runner for compatibility
108+ runs-on : windows-latest
109+ needs : [build-windows, build-linux, build-macos]
14110 environment :
15- name : pypi # Optional: Define a deployment environment
111+ name : pypi
16112 permissions :
17- id-token : write # Grant permission to request an OIDC token
113+ id-token : write
18114 steps :
19115 - name : Checkout code
20116 uses : actions/checkout@v2
21117
118+ - name : Download all compiled libraries
119+ uses : actions/download-artifact@v4
120+ with :
121+ path : restructuredpython/lib/
122+
22123 - name : Set up Python
23124 uses : actions/setup-python@v2
24125 with :
@@ -29,17 +130,10 @@ jobs:
29130 python -m pip install --upgrade pip
30131 pip install twine setuptools wheel build toml
31132
32- - name : Get version from pyproject.toml
33- id : get_version
34- run : |
35- VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
36- echo "VERSION=$VERSION"
37- echo "release_version=$VERSION" >> $GITHUB_ENV
38-
39- - name : Build the package
133+ - name : Build the package with compiled shared libraries
40134 run : |
41135 python -m build
42-
136+
43137 - name : Publish package distributions to PyPI
44138 uses : pypa/gh-action-pypi-publish@release/v1
45139
@@ -48,15 +142,13 @@ jobs:
48142 uses : softprops/action-gh-release@v1
49143 with :
50144 tag_name : " v${{ env.release_version }}"
51- name : " ${{ env.release_version }}" # Use version from pyproject.toml as release title
52- prerelease : false # Mark as a pre-release (beta)
145+ name : " ${{ env.release_version }}"
53146 files : |
54147 dist/*.whl
55148 dist/*.tar.gz
56149 body : |
57150 View the [changelog](https://restructuredpython.readthedocs.io/en/latest/changelog.html) for information about this release.
58151 env :
59- GITHUB_TOKEN : ${{ secrets.GH_PAT }} # GitHub token for authentication
60-
61-
152+ GITHUB_TOKEN : ${{ secrets.GH_PAT }}
62153
154+
0 commit comments