Skip to content

[nc-time-axis] QA refresh linter hooks #348

[nc-time-axis] QA refresh linter hooks

[nc-time-axis] QA refresh linter hooks #348

Workflow file for this run

# Reference:
# - https://github.com/actions/checkout
# - https://github.com/actions/download-artifact
# - https://github.com/actions/setup-python
# - https://github.com/actions/upload-artifact
# - https://github.com/pypa/build
# - https://github.com/pypa/gh-action-pypi-publish
# - https://test.pypi.org/help/#apitoken
name: ci-wheels
on:
pull_request:
push:
branches:
- "main"
- "v*x"
- "!conda-lock-auto-update"
- "!pre-commit-ci-update-config"
- "!dependabot/*"
tags:
- "v*"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-artifacts:
name: "build pypi artifacts"
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "build sdist and wheel"
run: |
# nc-time-axis is a pure python package, so simply use pypa/build
pipx run build
- name: "show sdist and wheel"
run: |
ls -l ${{ github.workspace }}/dist
- uses: actions/upload-artifact@v4
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist
test-artifacts:
needs: [build-artifacts]
name: "test wheel (${{ matrix.python-version }})"
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
env:
ENV_NAME: "ci-wheels"
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: "setup (python ${{ matrix.python-version }})"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v4
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist
- name: "test wheel (${{ matrix.python-version }})"
working-directory: ${{ github.workspace }}/dist
run: |
WHEEL=$(ls -1 *.whl)
python -m pip install "${WHEEL}[test]"
python -c "import nc_time_axis; print(f'version = {nc_time_axis.__version__}')"
python -m pytest --pyargs nc_time_axis
show-artifacts:
needs: [build-artifacts]
name: "show artifacts"
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist
- shell: bash
run: |
ls -l ${{ github.workspace }}/dist
publish-artifacts-test-pypi:
needs: [test-artifacts]
name: "Publish to Test PyPI"
runs-on: ubuntu-latest
# upload to Test PyPI for every commit on main branch
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
steps:
- uses: actions/download-artifact@v4
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
print_hash: true
publish-artifacts-pypi:
needs: [test-artifacts]
name: "Publish to PyPI"
runs-on: ubuntu-latest
# upload to PyPI for every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
name: pypi-artifacts
path: ${{ github.workspace }}/dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
print_hash: true