-
Notifications
You must be signed in to change notification settings - Fork 9
67 lines (64 loc) · 2.05 KB
/
test_and_deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Run tests and, if successful, deploy to PyPI
on:
push:
branches:
- main
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.9']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements_dev.txt
python -m pip install -e .
- name: flake8
run: flake8 src
- name: Unit tests
run: python -m pytest --doctest-modules src/osmg/
deploy:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
needs: test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Check the current version on PyPi
id: version_step_pypi
run: |
python -m pip install requests
latest=$(python src/osmg/get_latest_pypi_version.py)
echo "Latest Version found on PyPi: $latest"
echo "PYPI_VERSION=$latest" >> $GITHUB_ENV
- name: Check the current version on setup.cfg
id: version_step_setupcfg
run: |
version=$(grep '^version' setup.cfg | awk -F= '{print $2}' | tr -d '[:space:]')
echo "Version found in setup.cfg: $version"
echo "SETUPCFG_VERSION=$version" >> $GITHUB_ENV
- name: Prepare package
if: ${{ env.PYPI_VERSION != env.SETUPCFG_VERSION }}
run: |
python -m pip install --upgrade pip setuptools wheel twine
python setup.py sdist bdist_wheel
python -m twine check dist/*
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
- name: Deploy
if: ${{ env.PYPI_VERSION != env.SETUPCFG_VERSION }}
uses: pypa/gh-action-pypi-publish@release/v1