Skip to content

Commit c443a94

Browse files
authored
Merge pull request #11 from prosegrinder:chore/poetry
chore: poetry and push-button deploy
2 parents 8315a7a + dcd67a7 commit c443a94

File tree

12 files changed

+703
-741
lines changed

12 files changed

+703
-741
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Dependabot auto-approve
2+
on: pull_request
3+
4+
permissions:
5+
pull-requests: write
6+
7+
jobs:
8+
dependabot:
9+
runs-on: ubuntu-latest
10+
if: ${{ github.actor == 'dependabot[bot]' }}
11+
steps:
12+
- name: Dependabot metadata
13+
id: metadata
14+
uses: dependabot/[email protected]
15+
with:
16+
github-token: "${{ secrets.GITHUB_TOKEN }}"
17+
- name: Approve a PR
18+
run: gh pr review --approve "$PR_URL"
19+
env:
20+
PR_URL: ${{github.event.pull_request.html_url}}
21+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
22+
davidlday:
23+
runs-on: ubuntu-latest
24+
if: ${{ github.actor == 'davidlday' }}
25+
steps:
26+
- name: Approve a PR
27+
run: gh pr review --approve "$PR_URL"
28+
env:
29+
PR_URL: ${{github.event.pull_request.html_url}}
30+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/pypi-publish.yml

Lines changed: 79 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,92 @@
1-
name: Upload Python Package
1+
name: Bump, Release, and Publish
22

33
on:
4-
release:
5-
types: [created]
4+
workflow_dispatch:
5+
branches:
6+
- main
7+
inputs:
8+
newversion:
9+
description: "Bump Type (major minor patch)"
10+
required: true
11+
default: "patch"
12+
type: choice
13+
options:
14+
- patch
15+
- minor
16+
- major
17+
testpublish:
18+
description: "Publish to TestPypi"
19+
default: false
20+
type: boolean
21+
22+
concurrency:
23+
group: tag-and-release
24+
cancel-in-progress: true
625

726
jobs:
827
deploy:
928
runs-on: ubuntu-latest
1029
steps:
11-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
31+
with:
32+
persist-credentials: false
33+
fetch-depth: 0
34+
submodules: true
1235
- name: Set up Python
13-
uses: actions/setup-python@v2
36+
uses: actions/setup-python@v4
37+
- name: Install Poetry
38+
uses: snok/install-poetry@v1
1439
with:
15-
python-version: "3.x"
40+
virtualenvs-create: true
41+
virtualenvs-in-project: true
42+
installer-parallel: true
43+
- name: Bump Version
44+
run: poetry version ${{ github.event.inputs.newversion }}
45+
- name: Get New Version
46+
id: get-new-version
47+
run: |
48+
echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT
1649
- name: Install dependencies
50+
run: poetry install --with dev --no-interaction --no-root
51+
- name: Install project
52+
run: poetry install --with dev --no-interaction
53+
- name: Run tests
54+
run: |
55+
source .venv/bin/activate
56+
pytest tests/
57+
- name: Poetry Build
1758
run: |
18-
python -m pip install --upgrade pip
19-
pip install setuptools wheel twine build
20-
- name: Build Dists
59+
poetry build
60+
- name: Poetry Publish to PyPi Test
61+
if: ${{ 'true' == github.event.inputs.testpublish }}
2162
run: |
22-
python -m build
23-
- name: Publish to PyPI
24-
uses: pypa/gh-action-pypi-publish@release/v1
63+
poetry config repositories.testpypi https://test.pypi.org/legacy/
64+
poetry publish --repository testpypi --no-interaction --skip-existing
65+
env:
66+
POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.TEST_PYPI_API_TOKEN }}
67+
- name: Poetry Publish to PyPi
68+
run: |
69+
poetry publish --no-interaction
70+
env:
71+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
72+
- name: Commit & Push changes
73+
uses: actions-js/[email protected]
74+
with:
75+
author_email: [email protected]
76+
author_name: ${{ github.actor }}
77+
message:
78+
"[skip ci] bumped to ${{ steps.get-new-version.outputs.version }}"
79+
github_token: ${{ secrets.VERSION_BUMP_TAG_TOKEN }}
80+
- name: Tag version
81+
id: tag-version
82+
uses: mathieudutour/[email protected]
83+
with:
84+
custom_tag: ${{ steps.get-new-version.outputs.version }}
85+
create_annotated_tag: true
86+
github_token: ${{ secrets.VERSION_BUMP_TAG_TOKEN }}
87+
- name: Create a GitHub release
88+
uses: ncipollo/release-action@v1
2589
with:
26-
user: __token__
27-
password: ${{ secrets.PYPI_API_TOKEN }}
90+
tag: ${{ steps.tag-version.outputs.new_tag }}
91+
name: ${{ steps.tag-version.outputs.new_tag }}
92+
body: ${{ steps.tag-version.outputs.changelog }}

.github/workflows/pypi-test-publish.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/python-ci.yml

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,60 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: Python CI
52

6-
on: [push, pull_request]
3+
on: pull_request
4+
5+
concurrency:
6+
group: ci-${{ github.ref }}
7+
cancel-in-progress: true
78

89
jobs:
910
lint:
1011
runs-on: ubuntu-latest
1112
steps:
1213
- name: Check Out
13-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
15+
with:
16+
submodules: true
17+
- name: Setup Python
18+
uses: actions/setup-python@v4
19+
- name: Load pip cache
20+
uses: actions/cache@v3
21+
with:
22+
path: ~/.cache/pip
23+
key: ${{ runner.os }}-pip
24+
restore-keys: ${{ runner.os }}-pip
25+
- name: Install linters
26+
run: python -m pip install --upgrade black pylint
1427
- name: Black
15-
uses: psf/black@stable
28+
run: black . --check
1629
- name: Pylint
17-
uses: cclauss/[email protected]
18-
with:
19-
args: pip install .; pylint src/**/*.py
30+
run: pylint src/**/*.py
2031

2132
test:
33+
needs: lint
2234
runs-on: ubuntu-latest
2335
strategy:
36+
fail-fast: false
2437
matrix:
25-
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
38+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
2639
steps:
27-
- uses: actions/checkout@v2
40+
- uses: actions/checkout@v3
41+
with:
42+
submodules: true
2843
- name: Set up Python ${{ matrix.python-version }}
29-
uses: actions/setup-python@v2
44+
uses: actions/setup-python@v4
3045
with:
3146
python-version: ${{ matrix.python-version }}
32-
- name: Install dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
- name: Install module
36-
run: |
37-
pip install -e .
38-
- name: Test with pytest
39-
run: |
40-
pip install pytest
41-
pytest
42-
43-
check_build:
44-
runs-on: ubuntu-latest
45-
steps:
46-
- name: Check Out
47-
uses: actions/checkout@v2
48-
- name: Set up Python
49-
uses: actions/setup-python@v2
47+
- name: Install Poetry
48+
uses: snok/install-poetry@v1
5049
with:
51-
python-version: "3.x"
50+
virtualenvs-create: true
51+
virtualenvs-in-project: true
52+
installer-parallel: true
5253
- name: Install dependencies
54+
run: poetry install --with dev --no-interaction --no-root
55+
- name: Install project
56+
run: poetry install --with dev --no-interaction
57+
- name: Run tests
5358
run: |
54-
python -m pip install --upgrade pip
55-
pip install setuptools wheel twine build
56-
- name: Build
57-
run: python -m build
58-
- name: Check
59-
run: twine check dist/*
59+
source .venv/bin/activate
60+
pytest tests/

0 commit comments

Comments
 (0)