Moving to github actions. #1
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: CI/CD Pipeline | |
on: [ push, pull_request, workflow_dispatch ] | |
env: | |
PIP_CACHE_DIR: /tmp/pipcache | |
HOME_REPO: datakortet/dkfileutils | |
jobs: | |
ci-lint: | |
name: CI:Lint | |
runs-on: ubuntu-latest | |
env: | |
LINTDIR: ./ghlint | |
steps: | |
# setup environment | |
- uses: actions/checkout@v3 | |
- name: setup directories | |
shell: bash | |
run: | | |
mkdir -p $PIP_CACHE_DIR | |
mkdir -p $LINTDIR | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- run: pip install flake8 | |
- run: flake8 dkfileutils/** --max-line-length=199 | |
docs: | |
name: CI:Docs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: setup directories | |
shell: bash | |
run: | | |
mkdir -p build | |
- run: pip install sphinx | |
- run: pip install -e . | |
- run: sphinx-build -W -b html docs build/sphinx/html | |
- run: sphinx-build -W -n -T -b man docs build/sphinx/man | |
- name: Upload docs as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Docs | |
path: build/sphinx/ | |
ci-test: | |
name: CI:Test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | |
os: [ubuntu-latest] | |
include: | |
- python-version: '3.12' | |
os: windows-latest | |
- python-version: '3.12' | |
os: macos-latest | |
steps: | |
# setup environment | |
- uses: actions/checkout@v3 | |
- name: setup global directories | |
shell: bash | |
run: mkdir -p $PIP_CACHE_DIR | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- run: pip install -r requirements.txt | |
- run: pip list | |
- run: pytest -vv --cov=dkfileutils tests | |
- name: Upload coverage to codecov.io | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN}} | |
fail_ci_if_error: false | |
cd: | |
name: CD | |
needs: ci-test | |
runs-on: ubuntu-latest | |
steps: | |
# setup environment | |
- uses: actions/checkout@v3 | |
- name: setup directories | |
shell: bash | |
run: mkdir -p $PIP_CACHE_DIR | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Cleanup | |
run: | | |
rm -rf dist | |
rm -rf build | |
- run: pip install -U build twine | |
- run: python -m build | |
- name: Upload packages as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Packages | |
path: dist/ | |
- name: Deploy to PyPI | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == env.HOME_REPO | |
shell: bash | |
run: | | |
twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/* | |
# - name: Publish package | |
# uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
# with: | |
# user: __token__ | |
# password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Create Github release | |
uses: ncipollo/release-action@v1 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == env.HOME_REPO | |
with: | |
artifacts: "dist/*" | |
owner: datakortet | |
repo: dkfileutils | |
token: ${{ secrets.GITHUB_TOKEN }} |