-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (75 loc) · 2.77 KB
/
main.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Test and release
on:
pull_request: # Pull request events (default: open, synchronized, reopened) in any branch triggers the workflow.
push:
branches:
- main # Pushes to main (i.e. after a merged PR)
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Installing Poetry globally
run: pipx install poetry
- name: Installing Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: poetry
- name: Installing Poetry environment
run: poetry install
- name: Setting tag to package version
shell: bash
run: |
echo "RELEASE_NAME=$(poetry version | tr ' ' '-')" >> $GITHUB_ENV
echo "RELEASE_VERSION=$(poetry version -s)" >> $GITHUB_ENV
- name: Running pytest
id: pytest
run: poetry run pytest -v
- name: Running mypy
id: mypy
run: poetry run mypy geococo/ tests/
- name: Running ruff
id: ruff
run: poetry run ruff geococo/ tests/
- name: Checking code coverage
id: coverage
run: poetry run pytest --cov=geococo --cov-fail-under=75
- name: Build source and .whl archives with Poetry
id: build
run: poetry build
if: steps.pytest.outcome == 'success' && steps.mypy.outcome == 'success' && steps.ruff.outcome == 'success' && steps.coverage.outcome == 'success' && github.event_name == 'push'
- name: Authorize GitHub Actions to publish on PYPI
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
if: steps.build.outcome == 'success'
- name: Publish on PYPI
run: poetry publish
if: steps.build.outcome == 'success'
- name: Upload build artifacts
uses: actions/upload-artifact@v3
if: steps.build.outcome == 'success'
with:
name: ${{ env.RELEASE_NAME }}
path: dist/*
outputs:
RELEASE_NAME: ${{ env.RELEASE_NAME }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
PASSED_BUILD: ${{ steps.build.outcome }}
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Collect all artifacts
uses: actions/download-artifact@v3
id: collect
if: ${{ needs.build.outputs.PASSED_BUILD }} == 'success'
- name: Upload all artifacts to Github
uses: softprops/action-gh-release@v1
if: steps.collect.outcome == 'success'
with:
files: ${{ needs.build.outputs.RELEASE_NAME }}/*
tag_name: ${{ needs.build.outputs.RELEASE_VERSION }}
prerelease: false