Skip to content

pypi

pypi #37

Workflow file for this run

name: pypi
# 任务触发
on:
# 当 提交到当前仓库时立即运行
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
source-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Setup Python"
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: "Build source"
run: |
pip install --upgrade pip &&
pip install build &&
python -m build --sdist
- name: Get version
id: version
uses: frabert/replace-string-action@v2
with:
pattern: 'refs/tags/v(.+)'
string: ${{ github.ref }}
replace-with: 'v$1'
- uses: actions/upload-artifact@v3
with:
name: build_${{ steps.version.outputs.replaced }}
path: dist/*.tar.gz
retention-days: 1
manylinux-build:
runs-on: ubuntu-latest
needs: ["source-build"]
strategy:
matrix:
py_version: ['cp38-cp38', 'cp39-cp39', 'cp310-cp310']
steps:
- uses: actions/checkout@v3
- name: Get version
id: version
uses: frabert/replace-string-action@v2
with:
pattern: 'refs/tags/v(.+)'
string: ${{ github.ref }}
replace-with: 'v$1'
- uses: actions/download-artifact@v3
with:
name: build_${{ steps.version.outputs.replaced }}
path: dist/
- name: Build on manylinux2010
uses: GCS-ZHN/python-wheels-manylinux-build@v1.1
with:
python-versions: ${{ matrix.py_version }}
build-requirements: |
versioneer[toml]
cmake>=3.18
scikit-build>=0.13
setuptools>=42
system-packages: zlib-devel
source: dist/*.tar.gz
- uses: actions/upload-artifact@v3
with:
name: build_${{ steps.version.outputs.replaced }}
path: dist/*-manylinux*.whl
retention-days: 1
win-build:
runs-on: windows-2022
needs: ["source-build"]
strategy:
matrix:
py_version: ['3.7', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v3
- name: "Setup Miniconda"
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.py_version }}
auto-update-conda: true
activate-environment: "diamond4py"
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.1
- name: "Build and test for Windows"
shell: powershell
run: |
python -m pip install --upgrade pip;
pip install build "setuptools>=42" "scikit-build>=0.13" "cmake>=3.18,<=3.25.2" "ninja" "versioneer[toml]";
conda install -c anaconda zlib ;
python -m build --wheel --no-isolation;
Get-ChildItem -Path dist -Filter diamond4py*whl | ForEach-Object{ pip install "dist\$_" };
pushd test; python test.py; popd
- name: Get version
id: version
uses: frabert/replace-string-action@v2
with:
pattern: 'refs/tags/v(.+)'
string: ${{ github.ref }}
replace-with: 'v$1'
- uses: actions/upload-artifact@v3
with:
name: build_${{ steps.version.outputs.replaced }}
path: dist/*
retention-days: 1
release:
needs: ["manylinux-build", "win-build"]
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- name: Get version
id: version
uses: frabert/replace-string-action@v2
with:
pattern: 'refs/tags/v(.+)'
string: ${{ github.ref }}
replace-with: 'v$1'
- uses: actions/download-artifact@v3
with:
name: build_${{ steps.version.outputs.replaced }}
path: dist/
- name: Release to GitHub
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*
draft: true
- name: Relase to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository_url: ${{ vars.PYPI_URL }}
packages_dir: dist/