Skip to content

Update CI.yml

Update CI.yml #20

Workflow file for this run

name: Build and Deploy Wheels
on:
push:
tags:
- 'v*.*.*' # Trigger on version tags
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-2019]
python-version: ['3.8']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: test-env
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: |
python -m pip install --upgrade pip
pip install setuptools wheel cmake requests numpy
pip install --upgrade setuptools wheel requests numpy
- name: Install Visual Studio Build Tools
if: runner.os == 'Windows'
run: |
conda install -c conda-forge vs2019_win-64
pip install cmake
shell: powershell
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y python3-pip cmake gcc g++
python3 -m pip install --upgrade pip
pip install setuptools wheel requests numpy
pip install --upgrade setuptools wheel requests numpy
- name: Install Phreeqc
run: python setup.py compile_phreeqc
- name: Set platform tag
id: set-platform-tag
shell: pwsh
run: |
if ($env:RUNNER_OS -eq "Linux") {
echo "plat-name=manylinux2014_x86_64" >> $GITHUB_ENV
} elseif ($env:RUNNER_OS -eq "Windows") {
echo "plat-name=win_amd64" >> $GITHUB_ENV
} else {
echo "plat-name=unknown" >> $GITHUB_ENV
}
- name: Build wheel
run: python setup.py bdist_wheel --plat-name ${{ env.plat-name }} --python-tag=py3
- name: Upload wheel to artifact
uses: actions/upload-artifact@v4
with:
name: wheel-${{ runner.os }}
path: dist/*.whl
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download wheel artifacts (Windows)
uses: actions/download-artifact@v4
with:
name: wheel-Windows
path: dist/windows
- name: Download wheel artifacts (Linux)
uses: actions/download-artifact@v4
with:
name: wheel-Linux
path: dist/linux
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install twine
run: pip install twine
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
for file in dist/**/*.whl; do
if twine check $file; then
PACKAGE_NAME=$(basename $file | sed -E 's/(.*)-([0-9]+.*)-.*/\1/')
PACKAGE_VERSION=$(basename $file | sed -E 's/.*-([0-9]+.*)-.*/\1/')
if ! curl -s -f https://pypi.org/project/$PACKAGE_NAME/$PACKAGE_VERSION/ > /dev/null; then
twine upload $file
else
echo "$file already exists on PyPI. Skipping upload."
fi
else
echo "$file failed the check. Skipping upload."
fi
done