Skip to content

Update setup.py

Update setup.py #193

Workflow file for this run

name: Build Wheels
on:
workflow_dispatch:
push:
release:
types:
- created
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
#- name: Prefix wheels with branch name
# run: |
# BRANCH_NAME=$(echo "${{ github.ref }}" | sed -r "s/^refs\/heads\///")
# for wheel in wheelhouse/*.whl; do
# mv "$wheel" "wheelhouse/${BRANCH_NAME}-$(basename $wheel)"
# done
- name: Prefix wheels with branch name
if: startsWith(github.ref, 'refs/heads/')
shell: pwsh
run: |
$branchName = "${{ github.ref }}".Replace("refs/heads/", "")
Get-ChildItem -Path wheelhouse -Filter *.whl | ForEach-Object {
$newName = "${branchName}-$($_.Name)"
Rename-Item -Path $_.FullName -NewName $newName
}
- uses: actions/upload-artifact@v2
with:
name: wheels
path: wheelhouse/*.whl
publish_wheels_to_release_page:
name: Publish wheels to Release Page
needs: build_wheels
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- name: Get release info
uses: actions/github-script@v5
id: get_release_info
with:
script: |
const { upload_url } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: context.payload.release.tag_name,
});
return { upload_url: upload_url };
- uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: wheelhouse/*.whl
publish_wheels_to_pypi:
name: Publish wheels to PyPI
needs: build_wheels
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse
publish_wheels_to_gh_pages:
name: Publish wheels to GitHub Pages
runs-on: ubuntu-latest
needs: build_wheels
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- name: Checkout gh-pages branch
uses: actions/checkout@v2
with:
ref: 'gh-pages'
path: 'gh-pages'
- name: Copy wheels to gh-pages branch
run: |
mkdir -p gh-pages/wheels
cp wheelhouse/*.whl gh-pages/wheels/
- name: Create index.html for wheels directory
run: |
cd gh-pages/wheels
echo "<!DOCTYPE html>" > index.html
echo "<html>" >> index.html
echo "<head><title>Index of wheels</title></head>" >> index.html
echo "<body>" >> index.html
echo "<h1>Index of wheels</h1>" >> index.html
echo "<ul>" >> index.html
for wheel in *.whl; do
echo "<li><a href=\"$wheel\">$wheel</a></li>" >> index.html
done
echo "</ul>" >> index.html
echo "</body>" >> index.html
echo "</html>" >> index.html
- name: Commit and push wheels to gh-pages branch
run: |
cd gh-pages
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add wheels/*.whl wheels/index.html
git commit -m "Upload wheels to GitHub Pages and update index.html"
git push