This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish Python Wheel | |
# Trigger on every push to any branch | |
on: | |
push: | |
branches: | |
- '**' # Triggers on every branch push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Python 3.12 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
# Step 3: Install GCC 9 | |
- name: Install GCC 9 | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y g++-9 gcc-9 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 50 | |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 50 | |
# Step 4: Install pybind11 and build dependencies | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel pybind11 | |
# Step 5: Build the wheel | |
- name: Build the wheel | |
run: | | |
if [ ! -d "past-0.7.2" ]; then | |
wget https://master.dl.sourceforge.net/project/pocc/1.6/testing/modules/past-0.7.2.tar.gz | |
tar -xvf past-0.7.2.tar.gz | |
cp setup.py ./past-0.7.2/ | |
cp bindings.cpp ./past-0.7.2/src/ | |
cp Makefile.am ./past-0.7.2/src/ | |
sed -i 's/\<restrict\>/__restrict__/g' ./past-0.7.2/past/include/past/abstract_interpretation_memory.h | |
fi | |
cd past-0.7.2 | |
python setup.py bdist_wheel | |
mv dist ../ | |
# Step 6: Upload the wheel as an artifact | |
- name: Upload the wheel | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: dist/ | |
release: | |
# if: github.ref_type == 'tag' # Only trigger release if the commit is tagged | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
# Step 7: Download artifact | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist/ # This will ensure the artifact is downloaded to the dist/ folder | |
# Step 8: Get short commit SHA (first 7 characters) | |
- name: Get short commit SHA | |
run: echo "COMMIT_HASH=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV | |
# Step 9: Publish release | |
- name: Publish release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: 'dist/*' | |
token: ${{ secrets.GITHUB_TOKEN }} # Automatically available GitHub token | |
tag: ${{ env.COMMIT_HASH }} # Use the shortened commit hash | |
name: Release ${{ github.event.head_commit.message }} # Optional: Use commit message as the release name | |
draft: false | |
prerelease: false |