Skip to content

Commit c1423d1

Browse files
committed
Add github action
1 parent 6f930f4 commit c1423d1

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/python-publish.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build and Publish Python Wheel
2+
3+
# Trigger on every push to any branch
4+
on:
5+
push:
6+
branches:
7+
- '**' # Triggers on every branch push
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Step 1: Checkout the code
15+
- name: Checkout the code
16+
uses: actions/checkout@v3
17+
18+
# Step 2: Set up Python 3.12
19+
- name: Set up Python 3.12
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.12'
23+
24+
# Step 3: Install GCC 8
25+
- name: Install GCC 8
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y g++-8 gcc-8
29+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50
30+
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 50
31+
32+
# Step 4: Install pybind11 and build dependencies
33+
- name: Install build dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install setuptools wheel pybind11
37+
38+
# Step 5: Build the wheel
39+
- name: Build the wheel
40+
run: |
41+
python setup.py sdist bdist_wheel
42+
43+
# Step 6: Upload the wheel as an artifact
44+
- name: Upload the wheel
45+
uses: actions/upload-artifact@v3
46+
with:
47+
name: dist
48+
path: dist/
49+
50+
release:
51+
# if: github.ref_type == 'tag' # Only trigger release if the commit is tagged
52+
needs: build
53+
runs-on: ubuntu-latest
54+
55+
steps:
56+
# Step 7: Download artifact
57+
- name: Download artifact
58+
uses: actions/download-artifact@v3
59+
with:
60+
name: dist
61+
62+
# Step 8: Publish release
63+
- name: Publish release
64+
uses: ncipollo/release-action@v1
65+
with:
66+
artifacts: 'dist/*'
67+
token: ${{ secrets.GITHUB_TOKEN }} # Automatically available GitHub token
68+
tag: ${{ github.ref_name }} # The tag from the push event
69+
name: Release ${{ github.ref_name }} # Optional: Customize release name
70+
draft: false
71+
prerelease: false

0 commit comments

Comments
 (0)