-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (60 loc) · 1.94 KB
/
Copy pathrelease.yaml
File metadata and controls
76 lines (60 loc) · 1.94 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
name: PyUIKit Testing + Release
on:
push:
branches: [ main ]
jobs:
# 1️⃣ Test job
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e . # editable install
pip install pytest
- name: Run tests
run: pytest tests
# 2️⃣ Release job
release:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Get current version from setup.py
id: get_version
run: |
VERSION=$(python -c "import re; f=open('setup.py'); print(re.search(r'version\s*=\s*[\"\\'](.+?)[\"\\']', f.read()).group(1))")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Read release flags
id: release_flags
run: |
FLAGS=$(python -c "from release_flag import UPLOAD_TO_PYPI, CREATE_TAG; print(f'{UPLOAD_TO_PYPI},{CREATE_TAG}')")
IFS=',' read UPLOAD TAG <<< "$FLAGS"
echo "UPLOAD_TO_PYPI=$UPLOAD" >> $GITHUB_ENV
echo "CREATE_TAG=$TAG" >> $GITHUB_ENV
- name: Build distribution
if: env.UPLOAD_TO_PYPI == 'True' || env.CREATE_TAG == 'True'
run: python -m build
- name: Publish to PyPI
if: env.UPLOAD_TO_PYPI == 'True'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}