feat: change license of project to MIT #189
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: Python Wheels | |
on: | |
issue_comment: | |
types: | |
- created | |
workflow_dispatch: | |
jobs: | |
build_sdist: | |
name: Build 🐍 sdist | |
if: ${{(startsWith(github.event.comment.body, '/build_wheels') && github.event.issue.pull_request) || github.event_name == 'workflow_dispatch'}} | |
runs-on: ubuntu-20.04 | |
steps: | |
# ref: https://github.com/actions/checkout/issues/331#issuecomment-707103442 | |
- name: Get pull request | |
if: ${{ github.event.issue.pull_request }} | |
uses: actions/github-script@v7 | |
id: get-pr | |
with: | |
script: | | |
const request = { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
} | |
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`) | |
try { | |
const result = await github.rest.pulls.get(request) | |
return result.data | |
} catch (err) { | |
core.setFailed(`Request failed with error ${err}`) | |
} | |
- name: Checkout MR | |
if: ${{ github.event.issue.pull_request }} | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }} | |
ref: ${{ fromJSON(steps.get-pr.outputs.result).head.sha }} | |
submodules: true | |
- name: Checkout | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Trigger response | |
if: ${{ github.event.issue.pull_request }} | |
uses: actions/github-script@v7 | |
id: trigger-response | |
with: | |
script: | | |
const msg = 'Triggered [building of 🐍 sdist](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) via action...' | |
try { | |
const result = await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: msg, | |
}) | |
return result.data | |
} catch (err) { | |
core.setFailed(`Request failed with error ${err}`) | |
} | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Dependencies | |
run: python -m pip install scikit-build twine | |
- name: Build sdist | |
id: build-sdist | |
run: python setup.py sdist | |
- name: Check metadata | |
id: check-metadata | |
run: twine check dist/* | |
- name: Notify via comment | |
if: ${{ github.event.issue.pull_request }} | |
uses: actions/github-script@v7 | |
env: | |
STEP_STATUS: ${{steps.check-metadata.outcome}} | |
with: | |
script: | | |
try { | |
const result = await github.rest.issues.getComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{fromJSON(steps.trigger-response.outputs.result).id}}, | |
}) | |
var msg = result.data.body + ' <strong class="text-emphasized mr-2">${{steps.test-step.name}}</strong> ' | |
if(process.env.STEP_STATUS == 'success') | |
msg += 'successful :heavy_check_mark:' | |
else | |
msg += 'failed :x:' | |
github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{fromJSON(steps.trigger-response.outputs.result).id}}, | |
body: msg, | |
}) | |
} catch (err) { | |
core.setFailed(`Request failed with error ${err}`) | |
} | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
retention-days: 2 | |
build_wheels: | |
name: Build 🐍 wheels on ${{ matrix.os }} | |
if: ${{(startsWith(github.event.comment.body, '/build_wheels') && github.event.issue.pull_request) || github.event_name == 'workflow_dispatch'}} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-20.04, macos-11, windows-2019] | |
steps: | |
# ref: https://github.com/actions/checkout/issues/331#issuecomment-707103442 | |
- name: Get pull request | |
if: ${{ github.event.issue.pull_request }} | |
uses: actions/github-script@v7 | |
id: get-pr | |
with: | |
script: | | |
const request = { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
} | |
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`) | |
try { | |
const result = await github.rest.pulls.get(request) | |
return result.data | |
} catch (err) { | |
core.setFailed(`Request failed with error ${err}`) | |
} | |
- name: Checkout MR | |
if: ${{ github.event.issue.pull_request }} | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }} | |
ref: ${{ fromJSON(steps.get-pr.outputs.result).head.sha }} | |
submodules: true | |
- name: Checkout | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Trigger response | |
if: ${{ github.event.issue.pull_request }} | |
uses: actions/github-script@v7 | |
id: trigger-response | |
with: | |
script: | | |
const msg = 'Triggered [building of 🐍 wheels on ${{matrix.os}}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) via action...' | |
try { | |
const result = await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: msg, | |
}) | |
return result.data | |
} catch (err) { | |
core.setFailed(`Request failed with error ${err}`) | |
} | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Dependencies | |
run: | | |
python -m pip install cibuildwheel | |
- name: Build wheels | |
id: build-wheels | |
env: | |
CIBW_SKIP: "cp36-*" | |
CIBW_BEFORE_BUILD_MACOS: > | |
brew install openblas && | |
export OPENBLAS="$(brew --prefix openblas)" && | |
python -m pip install numpy | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: "python -m pytest {project}/test" | |
run: | | |
python -m cibuildwheel --output-dir wheelhouse | |
- name: Notify via comment | |
if: ${{ github.event.issue.pull_request }} | |
uses: actions/github-script@v7 | |
env: | |
STEP_STATUS: ${{steps.build-wheels.outcome}} | |
with: | |
script: | | |
try { | |
const result = await github.rest.issues.getComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{fromJSON(steps.trigger-response.outputs.result).id}}, | |
}) | |
var msg = result.data.body + ' <strong class="text-emphasized mr-2">${{steps.test-step.name}}</strong> ' | |
if(process.env.STEP_STATUS == 'success') | |
msg += 'successful :heavy_check_mark:' | |
else | |
msg += 'failed :x:' | |
github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{fromJSON(steps.trigger-response.outputs.result).id}}, | |
body: msg, | |
}) | |
} catch (err) { | |
core.setFailed(`Request failed with error ${err}`) | |
} | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./wheelhouse/*.whl | |
retention-days: 2 |