-
Notifications
You must be signed in to change notification settings - Fork 3
128 lines (105 loc) · 3.49 KB
/
python-package.yml
File metadata and controls
128 lines (105 loc) · 3.49 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# This workflow will install Python dependencies, run tests and create release and publish
name: Python package and publish
on:
push:
branches: [ main ]
jobs:
Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
python get-poetry.py -y
- name: Configure poetry
run: |
source $HOME/.poetry/env
poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v1
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: |
source $HOME/.poetry/env
poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
- name: Install Dependencies
run: |
source $HOME/.poetry/env
poetry install
- name: Run tests
run: |
source $HOME/.poetry/env
poetry run black . --check
poetry run isort . --check
poetry run mypy ./scimschema ./tests
poetry run pytest
Release:
name: Create Release
needs: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Get version
id: vars
run: echo ::set-output name=version::$(cat scimschema/VERSION)
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.vars.outputs.version }}
release_name: Release ${{ steps.vars.outputs.version }}
body: |
Changes in this Release
draft: false
prerelease: false
Publish:
name: Publish to Pypi
needs: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
python get-poetry.py -y
- name: Configure poetry
run: |
source $HOME/.poetry/env
poetry config virtualenvs.in-project true
# - name: Publish Test
# env:
# TEST_PYPI_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
# run: |
# source $HOME/.poetry/env
# export POETRY_PYPI_TOKEN_PYPI=$TEST_PYPI_TOKEN
#
# poetry config pypi-token.testpypi $TEST_PYPI_TOKEN
# poetry config http-basic.testpypi "__token__" "${PYPI_TOKEN}"
# poetry config repositories.testpypi https://test.pypi.org/legacy/
# poetry publish --build -r testpypi --no-interaction -vvv
- name: Publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
source $HOME/.poetry/env
export POETRY_PYPI_TOKEN_PYPI=$PYPI_TOKEN
poetry config pypi-token.pypi $PYPI_TOKEN
poetry config http-basic.pypi "__token__" "${PYPI_TOKEN}"
poetry config repositories.pypi https://upload.pypi.org/legacy/
poetry publish --build -r pypi --no-interaction -vvv